Shocking

Literally the only thing left to do before Don’t Look Back is finished is to implement the music and sound effects into the game – I figured this wouldn’t be a big deal, but unfortunately I’ve run into problems 🙁

It turns out that because of the way MP3 files work, it’s almost impossible to make them loop cleanly – which destroys the ambient background effects… And Flash 9 supports only MP3s, so I can’t even use WAVs instead.

There are two things I’m going to try, probably: First I’m going to attempt to crossfade a repeating ambient background sound effect into itself as it finishes – I sorta have this working already, but it’s a bit messy and you can clearly hear the intersection at the end of the sample, so it’s not really much of an improvement… Maybe if I spend enough time tweaking it it’ll sound ok, though.

The other possibility is to take a different approach to the sound design – instead of a 10 second raining sample say, I could come up with a load of small rain samples that each play once randomly – this way I wouldn’t have the looping problem. But I’ve got no idea if that’ll actually work.

Even if this does fix the ambient sounds, a far more serious problem is that I can’t cleanly loop the music. I don’t really know how to fix this – I don’t know if I even can.

* 4 Comments

4 Comments so far

  1. reallyjoel on February 7th, 2009

    I don’t understand why the MP3-format would pose any problems for looping. If the wave-file loops, the MP3-file will loop just as well. Just a couple of days ago, I made a background loop for a flash game using an MP3, and it works just fine.

  2. Kian on February 7th, 2009

    Have you tried giving Sound.play () a start time offset? Getting mp3s to loop in flash can be a real pain… Anyway, I can’t wait for the release, what little I have seen is fantastic!

  3. Terry on February 7th, 2009

    I don’t understand why the MP3-format would pose any problems for looping. If the wave-file loops, the MP3-file will loop just as well. Just a couple of days ago, I made a background loop for a flash game using an MP3, and it works just fine.

    I was pretty surprised – a bit of reading up on the problem indicates that is an issue inherent to how MP3 compression works (basically, it uses discrete frame buffer sizes which leave split second delays as unavoidable).

    As for why it works for you; from what I read on the problem, if you import a wav file into the Flash IDE it’ll encode and embed it as an MP3 for you in the library with some meta information storing the exact start and end points of the song, which is (probably) why it loops cleanly from there. However, as I’m using Flex that’s not really an option for me 🙁

    I’ve also read that you can get around this by creating a SWF in the Flash IDE that contains all your WAVs which are then encoded like above, and you can then embed this SWF into the Flex flash project. I may try doing this with a trial version if my other attempts don’t work…

    Andreas Kämper over at TIGSource said that he fixed this problem by using events tied to a flash timer to start and stop the music at an appropriate time, which is a bit like the crossfading thing I mentioned in the post but if it works, might get rid of the problem for me. It’s the easiest thing I can do at this point so I’m going to try it out first before I try anything else 🙂

    Have you tried giving Sound.play () a start time offset? Getting mp3s to loop in flash can be a real pain… Anyway, I can’t wait for the release, what little I have seen is fantastic!

    That might fix the delay at the start, thanks 🙂

    And cheers! I’m going to try my best to have it finished tonight 🙂

  4. andrew on March 6th, 2009

    don’t look back == very nice game!

    it know it’s about a month late, but the trick is the flash knows how to loop .WAV files if any only if *it* does the MP3 compression (at export time), and not you. (it internally compensates for the MP3 frame breaks). so, try adding the raw looping .WAV files into the library, and then have flash do the MP3 compression via the global publish settings — that should do the trick. one note is that this will make your library quite large, and your export times will go through the roof, so it’s best to do that towards the end of your project.

    – andrew

Leave a reply