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

Playing sound samples

The openFrameworks' ofSoundPlayer class is designed for playing and controlling sound samples. The basic usage of the ofSoundPlayer sound object is the following:

  • Loading a sound sample, specifying its filename using:
    sound.loadSound( fileName );
  • Playing the sample using:
    sound.play();
  • Updating the sound engine using the global function:
    ofSoundUpdate();

    You need to call the ofSoundUpdate(); function in testApp::update() for all the samples to play correctly.

There are a number of functions for controlling sample playback. They are as follows:

  • The stop() function stops sample playing.
  • The getIsPlaying() function returns true if our sample is currently playing.
  • The setPaused( pause ) function enables or disables pause in sample playing, ...

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