Pure Data

The Amplifier

The next step in our synthesizer is to create the audio amplifier, which will change the gain of the signal. Whatever method you use to create your envelope, if you are using it to control the amplitude of a signal you will want to make sure the output is an audio signal as well. This is done to avoid clicks in the audio.

Using a Slider

In the two examples below, an audio signal from the Sine Wave Oscillator [osc~] is being changed manually, via a slider, in the same way as the Volume knob on your home stereo might work. In the first example, the numbers from the slider, which go from 0-127, are divided by 127 with a Division [/] object, to get them within the range of 0-1. These numbers are sent directly to the right inlet of the Audio Multiplication [*~] object, so that every audio sample coming from the [osc~] is multiplied by a number between 0-1. This will reduce the volume of each sample. "0" means no sound, "1" means full volume. However, these changes in volume will have clicks in them, as each number from the slider is sent to the [*~].


Using [line~], [vline~] and [tabread4~]

In the second example, the numbers from the slider are sent to an Audio Ramp object [line~], after being packed together into a message by [pack] with the number 50. What this message, which might appear as "0.76 50" for example, tells line is that it should ramp to the next number in 50 milliseconds. This is known as Interpolation, which is to smoothly transition from one value to another by providing (or guessing) all the values in between. Since the [line~] object is an audio object, the signal it sends out should cleanly control the volume of the audio signal.


If you use [line] to make your envelope, you can make an audio signal by using the audio object [line~] instead.


[vline~] outputs an audio signal already.


And to read a table and get an audio signal out, the [tabread4~] object is useful. Note that [tabread4~] responds better when controlled with an audio signal as well, so [line~] is used instead of [line].