Mercurial > hg > beaglert
comparison 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 |
comparison
equal
deleted
inserted
replaced
523:42f6af3a5f1d | 524:9f455f01edd5 |
---|---|
99 - connect the 2nd middle pin of the pot to analogIn 0. | 99 - connect the 2nd middle pin of the pot to analogIn 0. |
100 - connect another 10K pot in the same way but with the middle pin connected to analogIn 1. | 100 - connect another 10K pot in the same way but with the middle pin connected to analogIn 1. |
101 | 101 |
102 The important thing to notice is that audio is sampled twice as often as analog | 102 The important thing to notice is that audio is sampled twice as often as analog |
103 data. The audio sampling rate is 44.1kHz (44100 frames per second) and the | 103 data. The audio sampling rate is 44.1kHz (44100 frames per second) and the |
104 analog sampling rate is 22.05kHz (22050 frames per second). On line 62 you might | 104 analog sampling rate is 22.05kHz (22050 frames per second). Notice that we are |
105 notice that we are processing the analog data and updating frequency and | 105 processing the analog data and updating frequency and amplitude only on every |
106 amplitude only on every second audio sample, since the analog sampling rate is | 106 second audio sample, since the analog sampling rate is half that of the audio. |
107 half that of the audio. | 107 |
108 ```` | |
109 if(!(n % gAudioFramesPerAnalogFrame)) { | |
110 // Even audio samples: update frequency and amplitude from the matrix | |
111 frequency = map(analogRead(context, n/gAudioFramesPerAnalogFrame, gSensorInputFrequency), 0, 1, 100, 1000); | |
112 amplitude = analogRead(context, n/gAudioFramesPerAnalogFrame, gSensorInputAmplitude); | |
113 } | |
114 ```` | |
108 | 115 |
109 Note that the pin numbers are stored in the variables `gAnalogInputFrequency` and | 116 Note that the pin numbers are stored in the variables `gAnalogInputFrequency` and |
110 `gAnalogInputAmplitude`. These are declared in the main.cpp file; if you look in | 117 `gAnalogInputAmplitude`. These are declared in the main.cpp file; if you look in |
111 that file you will see that they have the values of 0 and 1. Bear in mind that | 118 that file you will see that they have the values of 0 and 1. Bear in mind that |
112 these are analog input pins which is a specific header! | 119 these are analog input pins which is a specific header! |