Mercurial > hg > beaglert
comparison examples/04-Audio/tremolo/render.cpp @ 534:e2364e1711c2 prerelease
Updated doxygen for the tremolo audio example.
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Thu, 23 Jun 2016 21:22:02 +0100 |
parents | 2ec36efb2c52 |
children | 58652b93ef7e |
comparison
equal
deleted
inserted
replaced
533:2ec36efb2c52 | 534:e2364e1711c2 |
---|---|
84 ----------------------- | 84 ----------------------- |
85 | 85 |
86 This sketch demonstrates how to make a simple tremolo effect with one potiometer to | 86 This sketch demonstrates how to make a simple tremolo effect with one potiometer to |
87 control the rate of the effect. A tremolo effect is a simple type of amplitude modulation | 87 control the rate of the effect. A tremolo effect is a simple type of amplitude modulation |
88 where the amplitude of one signal is continuous modulated by the amplitude of another. | 88 where the amplitude of one signal is continuous modulated by the amplitude of another. |
89 This is achieved by multiplying to signals together. | 89 This is achieved by multiplying two signals together. |
90 | 90 |
91 In this example we want to create a tremolo effect like that you would find in a guitar | 91 In this example we want to create a tremolo effect like that you would find in a guitar |
92 effects box so our first signal will be our audio input into which we could plug a guitar | 92 effects box so our first signal will be our audio input into which we could plug a guitar |
93 or external sound source. This will be our 'carrier' signal. | 93 or external sound source. This will be our 'carrier' signal. |
94 | 94 |
96 in this case a sinetone which we will generate in the same way as the 01-Basic/sinetone example. | 96 in this case a sinetone which we will generate in the same way as the 01-Basic/sinetone example. |
97 The frequency of this sinetone is determined by a global variable, `gFrequency`. Again, the | 97 The frequency of this sinetone is determined by a global variable, `gFrequency`. Again, the |
98 sinetone is produced by incrementing the phase of a sine function on every audio frame. | 98 sinetone is produced by incrementing the phase of a sine function on every audio frame. |
99 | 99 |
100 In `render()` you'll see two nested for loop structures, one for audio and the other for the | 100 In `render()` you'll see two nested for loop structures, one for audio and the other for the |
101 analogs. You should be pretty familiar with this structure by now. In the first of these for loops | 101 analogs. You should be pretty familiar with this structure by now. In the first of these loops |
102 we deal with all the audio -- in the second with reading the analog input channels. We read the | 102 we deal with all the audio -- in the second with reading the analog input channels. We read the |
103 value of analog input 0 and map it to an appropriate range for controlling the frequency | 103 value of analog input 0 and map it to an appropriate range for controlling the frequency |
104 of the sine tone. | 104 of the sine tone. |
105 | 105 |
106 The lfo is then mulitplied together with the audio input and sent to the audio output. | 106 The lfo is then mulitplied together with the audio input and sent to the audio output. |
107 | |
108 Hardware | |
109 ----------------------- | |
110 - connect a 10K pot to 3.3V and GND on its 1st and 3rd pins. | |
111 - connect the 2nd middle pin of the pot to analogIn 0. | |
112 | |
107 */ | 113 */ |