Mercurial > hg > beaglert
diff examples/03-Analog/analog-input/render.cpp @ 524:9f455f01edd5 prerelease
Doxygen updates
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Thu, 23 Jun 2016 10:19:24 +0100 |
parents | 1cec96845a23 |
children | bfcbeb437869 |
line wrap: on
line diff
--- a/examples/03-Analog/analog-input/render.cpp Thu Jun 23 04:31:09 2016 +0100 +++ b/examples/03-Analog/analog-input/render.cpp Thu Jun 23 10:19:24 2016 +0100 @@ -101,10 +101,17 @@ The important thing to notice is that audio is sampled twice as often as analog data. The audio sampling rate is 44.1kHz (44100 frames per second) and the -analog sampling rate is 22.05kHz (22050 frames per second). On line 62 you might -notice that we are processing the analog data and updating frequency and -amplitude only on every second audio sample, since the analog sampling rate is -half that of the audio. +analog sampling rate is 22.05kHz (22050 frames per second). Notice that we are +processing the analog data and updating frequency and amplitude only on every +second audio sample, since the analog sampling rate is half that of the audio. + +```` +if(!(n % gAudioFramesPerAnalogFrame)) { + // Even audio samples: update frequency and amplitude from the matrix + frequency = map(analogRead(context, n/gAudioFramesPerAnalogFrame, gSensorInputFrequency), 0, 1, 100, 1000); + amplitude = analogRead(context, n/gAudioFramesPerAnalogFrame, gSensorInputAmplitude); +} +```` Note that the pin numbers are stored in the variables `gAnalogInputFrequency` and `gAnalogInputAmplitude`. These are declared in the main.cpp file; if you look in