Question

I am wanting use the native android ndk and OpenSL ES to play multiple sounds simultaneously. I've taken a look at the native-audio example in the ndk but haven't been able to figure out how to generalize it so that I can play different audio clips, possibly at the same time. Most of the examples that I've been able to find online via the last 50 or so search attempts that I've made with google often seem to be dependent on additional code such as a third party library, are written in Java (I am searching for a native solution), or else just don't seem to be designed to handle multiple sounds at once.

If it makes any difference to how to approach this, for each sound I am wanting to play, I already have some raw pcm data (little endian) in memory that is ready to be played, and for each one I know its sampling rate, bits per sample (8 or 16), and number of channels (either 1 or 2).

Any assistance that anyone can offer would be greatly appreciated. Thanks in advance.

Was it helpful?

Solution

You can create multiple simple buffer queue Audioplayers. You should have a mechanism to know when the queue has finished playing so you can utilize free ones from the pool. You can use the callback mechanism to do that. The native-audio example covers this callback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top