O'Reilly logo

Getting Started with C++ Audio Programming for Game Development by David Gouveia

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 a sound

Now that we have all of the audio data stored in memory, we are ready to begin playing the sound. In order to do so we must essentially take each of the values stored in the data array, and send them in order to the audio card (in our case, using the callback method that we created earlier).

If the format, sampling rate, and number of channels in the audio data are the same as the output, then this process is as simple as copying values from one array to another. However, the process becomes significantly more complicated if they differ in any way, in particular:

  • If our audio data has a different sampling rate from the output, we need to resample the data so that it matches the sampling rate of the output, or the sound will play ...

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