comparison examples/basic_analog_input/render.cpp @ 372:db2fe4e1b88e prerelease

Doxygen content added to each example render.cpp. References to AnalogReadFrame etc. removed from doxygen content.
author Robert Jack <robert.h.jack@gmail.com>
date Thu, 09 Jun 2016 18:16:05 +0100
parents 1feb9c23ac57
children 9dc5a0ccad25
comparison
equal deleted inserted replaced
371:361d0c2335cf 372:db2fe4e1b88e
1 /*
2 ____ _____ _ _
3 | __ )| ____| | / \
4 | _ \| _| | | / _ \
5 | |_) | |___| |___ / ___ \
6 |____/|_____|_____/_/ \_\.io
7
8 */
9
1 /* 10 /*
2 * render.cpp 11 * render.cpp
3 * 12 *
4 * Created on: Oct 24, 2014 13 * Created on: Oct 24, 2014
5 * Author: parallels 14 * Author: parallels
6 */ 15 */
7 16
17 /**
18 \example 3_analog_input
19
20 Connecting potentiometers
21 -------------------------
22
23 This sketch produces a sine tone, the frequency and amplitude of which are
24 affected by data received on the analog pins. Before looping through each audio
25 frame, we declare a value for the frequency and amplitude of our sine tone
26 (line 55); we adjust these values by taking in data from analog sensors
27 (for example potentiometers) with `analogRead()`.
28
29 - connect a 10K pot to 3.3V and GND on its 1st and 3rd pins.
30 - connect the 2nd middle pin of the pot to analogIn 0.
31 - connect another 10K pot in the same way but with the middle pin connected to analogIn 1.
32
33 The important thing to notice is that audio is sampled twice as often as analog
34 data. The audio sampling rate is 44.1kHz (44100 frames per second) and the
35 analog sampling rate is 22.05kHz (22050 frames per second). On line 62 you might
36 notice that we are processing the analog data and updating frequency and
37 amplitude only on every second audio sample, since the analog sampling rate is
38 half that of the audio.
39
40 Note that the pin numbers are stored in the variables `gAnalogInputFrequency` and
41 `gAnalogInputAmplitude`. These are declared in the main.cpp file; if you look in
42 that file you will see that they have the values of 0 and 1. Bear in mind that
43 these are analog input pins which is a specific header!
44 */
8 45
9 #include <Bela.h> 46 #include <Bela.h>
10 #include <Utilities.h> 47 #include <Utilities.h>
11 #include <rtdk.h> 48 #include <rtdk.h>
12 #include <cmath> 49 #include <cmath>