Changing music without a brief pause?

This forum is currently in read-only mode.
From the Asset Store
In this template the music plays without looping in your game
  • I have concerns regarding music.

    I'm porting my game from Multimedia Fusion 2, where I used OGG format files for music not only because that was all it supported but because I want to keep myself out of legal issues. They are loaded externally because I'd like to have my players able to replace the music if they want.

    However, as the documentation states, XAudio2 does not do OGG as music unless you have the codec for it. I figured it would not be much of an issue to have players install this codec, and I already had it installed, so I decided to try that out.

    But there are problems with it. Namely, when loading these OGG files it cuts off about the first half-second of each file. That sounds funny, but I can't add a half-second gap to compensate because the files are designed to loop.

    So, I tried the backup plan, loading the music as a sound, which also conveniently eliminates the pesky codec. I locked up the first channel and let the music go on that. However, this causes the game to skip 20-30 frames (at 60 fps v-synced) while it loads because as the documentation states it decompresses the OGG first. I tried making it pre-cache the files, but this only works the first time the music is loaded-- after a song is switched out it seems to dump it from the cache meaning if I want to reload a song (and I do) it'll freeze again.

    I'm guessing it is overall an OGG problem, as it requires either a codec or decompression before playing, but I am in a rather tight spot. I cannot really use any other music format. My game will probably be sold, which automatically knocks MP3 and WMA off the list. Both require licensing fees, and MP3's for instance is $2500 per title for games. WMA's is less, but still is inacceptable for a game being built on zero budget. That leaves WAV, which is freaking huge-- not good for digital distribution and it could even overflow the size of a CD if I tried to put the game on CD. OGG is essentially the only choice I have apart from MOD music, which I would prefer not using because I have actual music software at my disposal that gives me much more freedom.

    So how exactly can I switch between musics quickly without either losing the beginning of the tune or having the game freeze for a sec?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I guess it's a problem in the codec if it cuts off the start, nothing I can do about that. But I might be able to do something about the load-pause in a build or two.

    You could seriously consider MP3, you know. As far as I remember from reading the MP3 license, you need only pay once you've sold 5000 copies or something. By then, you must've made some profit

  • Without knowing exactly what is going on, but this may help, if the ogg files get dumped after their first play you should check your Cache property for XAudio2; change that to 'All'.

    Do you still get pauses every time that way?

  • This is a bit unrelated, but I guess it'd help too:

    Can we get an iTunes-like effect for fading in and out of music tracks? So, a couple of seconds before the current track stops the volume of the track decreases until the volume is at 0 when the track ended. Then, we reverse the same effect for the new track. A couple of seconds into the next track, we raise the volume of it until it's at 100% again.

    That way, we'd not have problems with a track ending - pause - another one beginning, it'd be a much subtler change.

    It'd be cool if we could also have the option for 'ducking', whichs means that we could have a sample in a channel and set the ducking for the main music track. So, if I get to the boss and he says something or starts screaming, the main music track decreases it's volume up until the sample is over. I guess Wikipedia explains it better than I do:

    http://en.wikipedia.org/wiki/Ducking

    This'd be cool. It could help making the whole music stuff very dynamic, so we'd enter a boss area, he'd start talking or whatever and the current music track would decrease in volume, thanks to ducking. Then when he'd start attacking, we'd fade into a new music track for the boss fight without any abrupt endings. It'd be like the visual transitions, just for music.

  • This is a bit unrelated, but I guess it'd help too:

    Can we get an iTunes-like effect for fading in and out of music tracks? So, a couple of seconds before the current track stops the volume of the track decreases until the volume is at 0 when the track ended. Then, we reverse the same effect for the new track. A couple of seconds into the next track, we raise the volume of it until it's at 100% again.

    That way, we'd not have problems with a track ending - pause - another one beginning, it'd be a much subtler change.

    It'd be cool if we could also have the option for 'ducking', whichs means that we could have a sample in a channel and set the ducking for the main music track. So, if I get to the boss and he says something or starts screaming, the main music track decreases it's volume up until the sample is over. I guess Wikipedia explains it better than I do:

    http://en.wikipedia.org/wiki/Ducking

    This'd be cool. It could help making the whole music stuff very dynamic, so we'd enter a boss area, he'd start talking or whatever and the current music track would decrease in volume, thanks to ducking. Then when he'd start attacking, we'd fade into a new music track for the boss fight without any abrupt endings. It'd be like the visual transitions, just for music.

    The first idea seems like it could be accomplished relatively easily already via events, but the second indeed sounds very useful; I'd suggest it in the feature request forum so it doesn't get lost .

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)