O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

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 sounds

The technique presented to play BGM from a MIME source is very practical but sadly, not flexible enough. Recreating an AudioPlayer object is not necessary and accessing asset files each time is not good in term of efficiency.

So when it comes to playing sounds quickly in response to an event and generating them dynamically, we need to use a sound buffer queue. Each sound is preloaded or even generated into a memory buffer, and placed into a queue when playback is requested. No need to access a file at runtime!

A sound buffer, in current OpenSL ES Android implementation, can contain PCM data. PCM, which stands for Pulse Code Modulation, is a data format dedicated to the representation of digital sounds. It is the format used in CD ...

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