2 Songs At the Same Time

Am I correct that only 1 streaming audio may be playing at a time, so there’s no way to crossfade between them?

I’ve never actually thought about doing something like that in MonoGame. I know games like Full Auto 2: Battlelines do it as there are different segments for each game state (1st place, last place, damaged vehicle, etc) and the game blends between each theme as the race goes on, but of course, that game probably predates MonoGame by years.

That’s something I’ll have to try at some point though.

There are a few factors here. On mobile platforms, streaming songs are played using the media player provided by the OS, which maps to the hardware-supported playback. Therefore only one streaming song can be played on those platforms.

The other factor is that the XNA MediaPlayer API provides static methods for song playback, so essentially there is one MediaPlayer object, and therefore does not understand multiple songs playing at the same time. This could perhaps be extended to support multiple songs playing back simultaneously, but would need to be planned so it does not break existing functionality.

If @T_F_G didn’t care about mobile, perhaps something like NAudio would be of use? You’d be losing out on Content Pipeline, but theoretically it should support these more advanced features.

Plus, it works in both .NET Framework and Mono if I recall correctly.

Hmm… thank you guys. That’s interesting. I understand the reasons now.

I currently only support Mac and PC, but I do want to keep my options open. But maybe I will do that NAudio just for certain platforms .

Actually, while trying to put together a little GTK# app to test out this type of idea, I found that NAudio actually does not work on anything but Windows.

I figured this out because my app was crashing with DllNotFoundExceptions and then I googled “naudio linux” (my primary dev env is Linux. I hate Windows) and found that almost all of NAudio is reliant on Windows APIs.

I’m not giving up though. I will find a cross-platform audio lib that can do multiple songs at once with crossfading. I’ll post it here when I’m done. Not only to help @T_F_G out but because this is a feature I really want for my game as well and I would like to have Linux compatibility in my game given that our entire programming team runs some form of Linux.

Edit: Just found CSCore. It’s a lot like NAudio, but it has support for Mac OS, and they’re apparently working on Linux support. We’ll see what the future holds…

1 Like