[SDL_mix 3.x] Flac crossfade

Is it possible to play 2 Flac files in parallel with SDL_mix?

I couldn’t do it when I uploaded the music with Mix_LoadMUS. With Mix_Music I can only play one piece at a time. I could switch to Mix_Chunk, but there is no option for fade in/out, which is what you need for crossfading.

Or would you have to use SDL_sound ?

Maybe you can use Mix_FadeInChannel and Mix_FadeOutChannel?

1 Like

Thanks for the tip. I was fooled by what WAV in Mix_LoadWAV means. This can also load Flac, I always thought it only works *.wav.

This way I can run 2 pieces in parallel:

Mix_FadeInChannel(1, chunk1, 1, 3000);
Mix_FadeOutChannel(1, 3000);
Mix_FadeInChannel(2, chunk2, 1, 3000);
Mix_FadeOutChannel(2, 3000);

But I can’t find an alternative to the following, which works with “Music”.

Mix_MusicDuration(...);
Mix_SetMusicPosition(...);
Mix_GetMusicPosition(...);

It’s a little off topic.
Does anyone know of another library that can do this?
It doesn’t necessarily have to be SDL.
I’ve thought about FFmpeg, but at first glance it just looks like a stream generation. Playback is then done via SDL_Audio. Then I come up against the limitations of SDL_mix again.

My goal is a simple media player that can load Flac and MP3 and the songs should have a smooth transition of around 3 seconds.

Since it didn’t work with SDL_mix, I switched to gstreamer, which meets my requirements.
It’s a shame, I would have liked to stay with SDL.
The only thing that doesn’t work (yet) is that it also runs under Windows.