This sketch demonstrates how to make a simple tremolo effect with one poteniometer to control the rate of the effect. A tremolo effect is a simple type of amplitude modulation where the amplitude of one signal is continuous modulated by the amplitude of another. This is achieved by multiplying two signals together.
In this example we want to create a tremolo effect like that you would find in a guitar effects box so our first signal will be our audio input into which we could plug a guitar or external sound source. This will be our ‘carrier’ signal.
The second signal that we will use, the ‘modulator’, will be a low freqeuncy oscillator (LFO), in this case a sinetone which we will generate in the same way as the 01-Basic/sinetone example. The frequency of this sinetone is determined by a global variable, `gFrequency`. Again, the sinetone is produced by incrementing the phase of a sine function on every audio frame.
In `render()` you’ll see two nested for loop structures, one for audio and the other for the analogs. You should be pretty familiar with this structure by now. In the first of these loops we deal with all the audio — in the second with reading the analog input channels. We read the value of analog input 0 and map it to an appropriate range for controlling the frequency of the sine tone.
The lfo is then mulitplied together with the audio input and sent to the audio output.
- connect a 10K pot to 3.3V and GND on its 1st and 3rd pins.
- connect the 2nd middle pin of the pot to analogIn 0.