Play sound IMMEDIATELY after other sound finishes
Hi, I have a song for my game, and I have it broken up into 2 chunks, 1 for the intro (which will play once), then once that one is done playing, the next one plays in a loop.
The problem I'm having is I'm doing something like 'Music#1 is NOT playing', play music#2. Problem is that there's a bit of a pause between the music being played. I'm guessing it's at 1/65th of a second (the game is set to run at 65 fps).
Is there any way to get it to run the event the instant the sound finishes?
Re: Play sound IMMEDIATELY after other sound finis
If your using Direct Show, you can probably compare the total time with the current time and when the first track has a couple milliseconds left, go to the next track. If your using audio player built into MMF2 and your audio is in the start up screen, you can speed up the frame rate so that the pause is even faster.
Re: Play sound IMMEDIATELY after other sound finis
it's not quick enough. This is a hit and miss area that is affected by multiple codecs being installed. If you have FFDshow for instance and it's configured to resample, filter any audio, then you'll have issues with getting a quick responce.
Re: Play sound IMMEDIATELY after other sound finis
Are you using music (MIDI) or samples (the rest)? If a sample, it'd be best to use 2 channels. If music, then I'm clueless. :(
Re: Play sound IMMEDIATELY after other sound finis
I'm using OGG files and I'm playing them with the built in 'sound object' that is always there.
Use 2 channels? How would that make a difference?
Re: Play sound IMMEDIATELY after other sound finis
It will require some precise sound editing.
But the technique is to play both samples the same time in 2 separate channels and muting the loop version. Once the intro has stopped, you raise the volume of the other channel.
But like I said, it'll require some editing to the sound.
Re: Play sound IMMEDIATELY after other sound finis
A very simple and somewhat primitive solution would be to make it one file and just have the second part of the music repeating in the sound file, so that all you have to do is play the whole file and it will keep playing through. This wouldn't work if your game takes a long time because the sound file would have to be huge. You will obviously need sound editing software like Audacity to combined the tracks and loop the second one.
Re: Play sound IMMEDIATELY after other sound finis
Quote:
Originally Posted by MetalGeo
It will require some precise sound editing.
But the technique is to play both samples the same time in 2 separate channels and muting the loop version. Once the intro has stopped, you raise the volume of the other channel.
But like I said, it'll require some editing to the sound.
The intro and the loop are not the same length. The intro is shorter than the loop.
Quote:
Originally Posted by Brandon
A very simple and somewhat primitive solution would be to make it one file and just have the second part of the music repeating in the sound file, so that all you have to do is play the whole file and it will keep playing through. This wouldn't work if your game takes a long time because the sound file would have to be huge. You will obviously need sound editing software like Audacity to combined the tracks and loop the second one.
I would like it to repeat infinitely, not just the number of times it loops inside the sound file. That would take up too much space anyways.
The only thing I would need to do this is a true event like 'sound finishes playing'.
Re: Play sound IMMEDIATELY after other sound finis
Quote:
Originally Posted by LazyCoder
The intro and the loop are not the same length. The intro is shorter than the loop.
That's what I meant with editing, silly. :)
The loop will have to be twice as long, but that shouldn't be a problem. Easily edited in tools like Goldwave. Just going to need to edit the begin and the end of the loop.
Honestly, it's much easier than it sounds. :D
Edit: I made a visual tutorial.
http://img444.imageshack.us/img444/5...editingks8.png
Keep in mind though. If the intro is longer than the original loop, it's merely a different step. But still basically the same.
Hope this helps. :D
Re: Play sound IMMEDIATELY after other sound finis
The way I did it was have all the game's music in one huge ogg and when I want a song to loop, I simply change the position of the sound file. It's really easy, actually.
Re: Play sound IMMEDIATELY after other sound finis
Oh ok. I get what you're saying now.
I just don't think it should be this complicated to get a sound to loop.