SDL2 mixer playing WAVE (.WAV) files corruptedly

The issue can be seen just by playing a longer WAV than you usually would, like instead of 2-3 seconds, play a wav that is 40-50 seconds or a few minutes. The sound will start getting corrupted with beep or different sounds, if you keep waiting the sound will start to play in tones randomly like the sound will get deeper randomly or more thin out of nowhere, and eventually it will start to jump to anywhere in the sound randomly,

This does not happen in any other formats, .ogg or so do play it very well, and the wav file i tried is not corrupted, i have tried to play many different wav files, if it is long enough, it starts to happen.

I dont do anything else than initializing SDL and mixer, then loading my wav and playing it.
I am not sure if mixer allows you to play with the freq or other settings, would be good if that is the thing for WAV, but I am sure it is not a feature, or on purpose.


You don’t need SDL_mixer to play WAV files, core SDL2 has the functions needed for that: SDL_LoadWAV(), SDL_QueueAudio(), SDL_PauseAudioDevice() etc. Have you tried playing your WAV file that way?

Thank you for your answer, I did not try using that no and also that require extra work to balance things to work with the left of the code, as I still be needing mixer for other formats like OGG, so I need to emulate channels for WAV part.

Still quite curious as to why it behaves like that in mixer with WAV files.

1 Like