To view this content, you need to install Java from java.com

This sketch demonstrates how to use the getGain and setGain methods of a Controller object. The class used here is an AudioOutput but you can also get and set the gain of AudioSample, AudioSnippet, AudioInput, and AudioPlayer objects. getGain and setGain will get and set the gain of the DataLine that is being used for input or output, but only if that line has a gain control. A DataLine is a low-level JavaSound class that is used for sending audio to, or receiving audio from, the audio system. You will notice in this sketch that you will hear the gain changing (if it's available) but you will not see any difference in the waveform being drawn. The reason for this is that what you see in the output's sample buffers is what it sends to the audio system. The system makes the gain change after receiving the samples.

Source code: getSetGain waveform

Built with Processing