-
Book Overview & Buying
-
Table Of Contents
Mastering openFrameworks: Creative Coding Demystified
By :
The way to input sound data from a microphone or other audio input device is similar to the sound output considered earlier, with small changes:
Add a sound stream object and function for the audio input to the testApp class declaration as follows:
ofSoundStream soundStream; void audioReceived( float *input, int bufferSize, int nChannels );
At the end of the testApp::setup() function definition, add the following:
soundStream.setup( this, 0, 1, 44100, 512, 4 );
Here, this is a pointer to our testApp object which will receive the microphone's sound data by calling our testApp::audioReceived function.
Subsequently, 0 is the number of output channels (hence, no output), 1 is the number of input channels (hence, mono input), 44100 is a sample rate, that is, the received number of audio samples per second.
The last two parameters 512 and 4 are the size of the buffer for audio samples and the number of buffers.
Add function definition as follows:
void testApp::audioReceived(
...
Change the font size
Change margin width
Change background colour