Mix sdl2 trouble playing multiple sounds simultanious

closed account (N8RzwA7f)
Hello,

I'm having some trouble playing music and chunks at the same time.
I wrote a frequency change function that changes the frequency for either music or chunks before either mix_playmusic or mix_playchannel.

but if I do this in the frequency change function: Mix_CloseAudio(); mix_openaudio , the voice sounds like chipmunks.
I call this function before mix_playmusic or mix_playchannel .

if I remove closeaudio , the voice sounds normal , but teh music stops as soon as voice has played (and it should continue in the background)

any ideas? :)
Why do you want to change the frequency? Most programs use the same frequency throughout the whole run of a program, unless they want to provide the user with an option to change it.

The docs says you need to call Mix_CloseAudio before calling Mix_OpenAudio again otherwise the new settings will not be used.

If you use Mix_CloseAudio and Mix_OpenAudio to change the frequency you will have to reload every Mix_Chunk and Mix_Music from file again otherwise they might sound like chipmunks (happens when you increase the frequency). You will also have to call Mix_PlayMusic etc. to start playing everything again.
Last edited on
closed account (N8RzwA7f)
Thank for the reply.
I have to change the frequency between my music files and chunks or either will sound bad. Either the music is to slow or the voices sound like chipmunks. And i did incude mix_closeaudio ,but that didnt work?

Why would reloading every file make a difference?

closed account (N8RzwA7f)
any ideas anyone?
closed account (N8RzwA7f)
I could do it finally with the default frequency rate and a higher sampling rate, so no need for seperate openaudio calls
The frequency is the sample rate. When you call Mix_LoadWAV or Mix_LoadMUS it will automatically convert to the sample rate that was set when Mix_OpenAudio was called.
Topic archived. No new replies allowed.