O'Reilly logo

Mastering openFrameworks: Creative Coding Demystified by Denis Perevalov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using a microphone

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:

  1. 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 );
  2. 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required