OpenAL: how to play several sounds at the same time and mix them?

I used to use SDL_Mixer, and it correctly performs this task: when I play one sound with one function call 10 times in a row, all sounds are mixed. But in OpenAL, when I play a sound using alSourcePlay (), it just plays a single sound without mixing with previous sounds.

So how can I play more than one sound at a time?

+4
source share
1 answer

You need one sound source.

The buffer contains the original sound samples and can supply one or more sources (simultaneously and simultaneously). The listener determines where your β€œear” is (there is only one!). The source is one instance of sound, given the location in space, the volume, the buffer to pull samples from, etc.

So, for two sounds simultaneously, you need 2 sources.

+10
source

All Articles