Looping Music Tutorial

10 posts (showing 1-10)
Porter

Market Level 4Community Level 0
3406 posts

I figured I might as well share what I know about looping music in flash with others to help all these games have wonderful looping soundtracks, yay for that.

First off, from my experiences to get a proper loop you must use a .WAV format of the file your using. From what I've heard and know, mp3's create a small lag between restarting the song for reasons unknown to man, or at least myself.

You also obviously need a track that loops, or one that could be made into a loop, if you have a decent ear it shouldn't be to hard to pick out a track and recognize a loop could be made from it, I've done so with a few tracks in my game Dominus Void found here, http://www.flashgamelicense.com/view_game.php?game_id=1441 It's already sponsored so no shameless self promotion here, just an example of looped music that was not created to loop in the first place, tracks 1 and 4 to be specific. You can find the originals below to see what I did to them.

http://www.newgrounds.com/audio/listen/124949

http://www.newgrounds.com/audio/listen/144931

Anyway, the best program in my opinion currently would be Audacity, you can download it at the link below, it's the best program for just mixing sounds, music and small changes, it's a rather powerful program for being free.

http://audacity.sourceforge.net/download/windows

You may also want to get some of the additional downloads llisted slightly lower down on that page below the main download link, the lame MP3 encoder is also very usefull seeing as a lot of the time .mp3 files are what you'll want to be using.

So now we have audacity, if you don't, stop reading my wonderful tutorial and follow the links above and download/install it. So you'll need to take your loopable music, or music you want to loop and cut the music up so that it will loop corectly when you test it in audacity. The <strong> BEST </strong> way to tell if your music is looping is to copy and paste the entire track (your loop) at the end of the track (so it's 2x the length, the second half being the first half placed directly after the first) and play it from the beginning, if it sounds perfect, get rid of the coppied and pasted part and export the file as a .WAV, again .mp3 creates a lag and even if it sounds perfect in audacity, it WILL lag in flash and create a gap that does not loop perfectly. The entire process of making the track loop in audactiy CAN be rather tedious sometimes, but use your ear and you'll get it eventually, I suggest zooming in as well when you get close to a good loop, the added accuracy really helps.

Next you'll import the file into flash, preferable call the music through AS, if you don't know how to do so I made another tutorail found below,

http://www.flashgamelicense.com/view_thread.php?thread_id=1179&last_read_post_id=5870

I suggest lowering the quality significantly because it's a .WAV file and has a much larger file size then a .mp3. Set the compression ro RAW, then I would suggest messing with the settings here. Go to properties and mess with the sample rate and "convert stereo to mono". Change these to the lowest settings possible while still maintaining good sound quality in your .swf file and your all set. Sometimes changing these settings can create a pop noise when repeating, or simply just kill the quality of your music, more times then not though it lowers the file size greatly and you won't notice a change. Just play with it :)

That should be all, hope I helped a few people understand how to do this a bit more, if you have any questions or additions post em here, I'll gladly update this with new information.

posted 2008-07-20T22:42:47-07:00 | edited 2008-07-20T23:44:25-07:00
FrozenHaddock

Market Level 0Community Level 2
104 posts

Ahh, I checked my audio in audacity after I heard it had a lag when imported into Flash, it runs fine in both audacity and wmp, and I've no idea where this tiny delay is coming from...

posted 2008-07-20T22:55:04-07:00
Porter

Market Level 4Community Level 0
3406 posts

Is it .WAV format or .mp3?

posted 2008-07-20T23:10:59-07:00
FrozenHaddock

Market Level 0Community Level 2
104 posts

It's a .WAV

posted 2008-07-20T23:13:40-07:00
Porter

Market Level 4Community Level 0
3406 posts

Are you calling the music through code or is it on the timeline set to loop?

posted 2008-07-20T23:17:16-07:00
FrozenHaddock

Market Level 0Community Level 2
104 posts

It's on the timeline, set to event - loop.

posted 2008-07-20T23:21:50-07:00
Porter

Market Level 4Community Level 0
3406 posts

I don't really know what to say, I just tried to put mine on the timeline to see if that was the problem (I call my music through code) but it wasn't, it worked fine. My only thought is that it doesn't loop <strong> perfectly </strong> In audacity or whatever program your exporting it from. If you can upload the music file somewhere to where I can download it, I'll try messing with it myself in audacity and see if it works as a good loop. What are your settings on the music under properties? "convert stereo to mono" and the sample rate.

posted 2008-07-20T23:33:52-07:00
FrozenHaddock

Market Level 0Community Level 2
104 posts

http://www.flashkit.com/loops/Techno-Dance/Techno/_Pike_-SaxxonPi-7536/index.php

That thar is my loop, seems fine to me.

posted 2008-07-20T23:38:56-07:00
Porter

Market Level 4Community Level 0
3406 posts

I found the problem, it's really easily fixable. I did this part of my tutorial,

"The BEST way to tell if your music is looping is to copy and paste the entire track (your loop) at the end of the track (so it's 2x the length, the second half being the first half placed directly after the first) and play it from the beginning, if it sounds perfect, get rid of the coppied and pasted part and export the file as a .WAV"

If you use the zoom tool and zoom like 4-5 times you can get really close and grab all of the emptyness that caused this.

If you do this, you can see a line of emptyness in the sound waves in audacity, this is your really quick gap you hear. There's also a bit at the very beginning of the file. I just corrected the file for you, you can download it below.

I can't find a good place to upload the .WAV file I just saved, so drop me your email address in a PM and I'll send it to you, it works perfectly.

posted 2008-07-20T23:56:48-07:00 | edited 2008-07-20T23:58:25-07:00
FrozenHaddock

Market Level 0Community Level 2
104 posts

Thank you very much, that loops perfectly!

:)

posted 2008-07-21T01:50:26-07:00