Ray C
Ray C

Reputation: 617

How to play multiple sounds like SDL_Mixer does, but natively in SDL2?

In my last question I figured out how to play sounds natively in SDL2: How to lower the quality and specs of a wav file on linux

The issue I have now is wanting to mimic the 1 music and many sounds thing that SDL_Mixer does. A theory is I can use different channels, mono, stereo etc to play multiple sounds. Another theory is to look deep into the SDL Audio functions and try and find someway to play many sounds. I thought even using threads may work, but the problem with that is I find overwriting the default audio device seems to remove my old sound.

Has anyone done this or have any idea of playing multiple sounds with background music natively in SDL2 using the SDL_OpenAudioDevice with WAV files?

Upvotes: 1

Views: 1939

Answers (1)

Ray C
Ray C

Reputation: 617

Having dug into the code for a bit, the answer is not to use SDL_memset(stream, 0, len); as described here which was silencing the sound. It appears at first glance that you can mix in other sounds without it overwriting. Will post later if I find changes in the answer.

Upvotes: 1

Related Questions