Mercurial > hg > beaglert
diff projects/basic_analog_input/render.cpp @ 269:ac8eb07afcf5
Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places.
Empty project added as a default project.
Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Tue, 17 May 2016 15:40:16 +0100 |
parents | 72726dd4f66c |
children | 5433c83ce04e |
line wrap: on
line diff
--- a/projects/basic_analog_input/render.cpp Wed May 11 10:29:23 2016 +0100 +++ b/projects/basic_analog_input/render.cpp Tue May 17 15:40:16 2016 +0100 @@ -1,3 +1,12 @@ +/* + ____ _____ _ _ +| __ )| ____| | / \ +| _ \| _| | | / _ \ +| |_) | |___| |___ / ___ \ +|____/|_____|_____/_/ \_\.io + + */ + /* * render.cpp * @@ -5,6 +14,30 @@ * Author: parallels */ +/** +\example 3_analog_input + +Connecting potentiometers +------------------------- + +This sketch produces a sine tone, the frequency and amplitude of which are +affected by data received on the analog pins. Before looping through each audio +frame, we declare a value for the frequency and amplitude of our sine tone +(line 55); we adjust these values by taking in data from analog sensors +(for example, a potentiometer). + +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. + +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 +that file you will see that they have the values of 0 and 1. Bear in mind that +these are analog input pins which is a specific header! +*/ #include <BeagleRT.h> #include <Utilities.h> @@ -31,6 +64,7 @@ // // Return true on success; returning false halts the program. + bool setup(BeagleRTContext *context, void *userData) { if(context->analogFrames == 0 || context->analogFrames > context->audioFrames) {