XCOM 2
Not enough ratings
How To Create Loops For Music Packs
By nintendoeats
A set of instructions for editing pre-existing music files into looping tracks which can be used with Music Modding System.
   
Award
Favorite
Favorited
Unfavorite
Introduction
This is intended as a companion to my guide on how to build a music pack. It covers adjusting volume, choosing the correct sample rate, snipping out intros and adjusting the beginning and ends of the tracks to merge seamlessly. The only things you need are Audacity, your music files and some kind of software that can convert your tracks to downsampled WAV files. I use Foobar2000, because it is my mostest favouritest program ever. Also because it is absurdly powerful for batch processing files.

I am going to add a section on more fine-grained techniques of making things loop correctly soon. At present, this guide is more focused on the process and theory.

Note: I have been working on a very complex set of loops and have learned a ton. While nothing in this guide is actually wrong, I have learned some things which supplant it. I will update it at some point.
Titles!
Your file titles must not contain any spaces or odd characters! UDK will not accept them! I format my names like this: Loop_SongTitle, Intro_SongTitle, Single_SongTitle etc. etc. Do whatever makes sense to you.
Downsampling
This process can be done at any time, but if you do it at the beginning then you won't need to think about it any more.

WAV files are raw, uncompressed audio data. They are also the only thing that UDK will accept. This makes music packs quite large, which is bad for the end user. Storage, RAM usage and bandwidth consumption all go up with file size. Fortunately, some files can literally be chopped in half by cutting the sample frequency from the typical 44.1 KHz down to 22.05 KHz. This isn't free though: audio quality can be reduced significantly if you aren't careful.

Audio files can be thought of as collections of frequencies. In order to store a frequency (say 1 KHz) you need to use a sample rate which is twice as fast (2 KHz). The upshot is that any file which doesn't contain significant information about 11 KHz can be stored perfectly well with a 22KHz sample rate. What we need to do then is check each file to find out if it contains any high frequency information we want to preserve.

Drag-and-drop your file into Audacity. Select the whole song and go to Analyze -> Plot Spectrum. You will get a chart something like the one below.


As you can see, this song contains quite a bit of information above 11 KHz (11000 on the chart, not actually labelled in this case). It is therefore safer to not downsample it. I would therefore move on to loop editing, or analyze another file. If your plot doesn't contain these high frequencies, add it to a list of tracks to be downsampled. I just drop them into a playlist in Foobar 2000, but your process will vary depending on what software you are using.

Another thing you can see from that image is that it goes up to 20 KHz but the center is only 1 KHz. The scale is not linear, so it is easy to underestimate the differences on the right hand of the chart. If there are frequencies only a little bit to the right of 11 KHz they may actually be at 13 or 14 KHz. When in doubt, hover your cursor over that point in the graph and it will tell you what frequency that point in the graph represents.

Audacity won't analyze more than about 4 minutes at once, so as you can see above I started with just one section. If this came out clean I would have selected another section and clicked "Replot". Rinse, repeat.
Limiting & Normalizing
In order to match the volume levels of the other in-game music we need to normalize our new tracks. If they are from a modern-ish game this shouldn't be a big deal, but sometimes you will need to apply a "limiter" which brings the loud sections down.

Normalization is just a matter of going to Effects -> Normalize and setting it to 0dB. This will amplify the song so that the loudest section is as loud as it can possible be. You can do this in batch using Audacity's chain feature if you like. Just be sure that you normalize AFTER limiting is applied.


The example above has been normalized to 0dB, but notice how almost nothing is actually near the top of the chart. The two big spikes are so loud that everything else needs to be made quieter to compensate. In-game this track would sound very quiet. The solution is to use Effects -> Limiter which essentially acts as a set of hedge trimmers for your track. See below that same track with a limiter of -4dB applied and then normalized to 0dB. Everything is nice and even.


Be careful with limiting. The more you apply, the less difference there will be between the loudest and softest instruments. Only apply the amount you need to get a track that is loud enough throuhgout.

If you are snipping out an intro section from a track, be sure to apply limiting and normalization to the entire track at once. You cannot normalize the intro and loop seperately, else one will almost certainly come out louder than the other.
Looping!
Once you have a track ready to go you can start chopping it up. I am going to assume from here that you have a track which contains an intro followed by something that can be made to loop endlessly.

1. Select the whole track
2. CTRL + C to copy it
3. CTRL + scroll wheel to zoom out a bit
4. Click outside your selection
5. Click on the end of the track (it should snap to the end when your cursor is close)
6. CTRL + V to paste your tack duplicate
7. CTRL + scroll wheel to zoom in on the join

Now is where it becomes a creative process. If you are snipping out an intro, select that portion minus a little bit from your pasted track and delete it. We will get it back later. Right now the focus is on making these two tracks loop. Identify the points where they should meet and start chopping! The exact process depends on your tracks, but your main concerns are likely to be matching beat and choose your joining points by where those two things are the same, or nearly the same. Once you get those it's just a matter of having the waveforms join properly.

In order to loop without a noticeable click you want everything to be going in the correct direction. If the left-hand wave is going down, the right-hand wave should meet it and continue heading down at roughly the same speed. I try to match flat bits at the center line, but that isn't always possible. Fortunately you can use Effects -> Repair on small sections to make the waveforms meet up properly.

One trick I notice was used in Earthbound quite a bit was having something sudden like a drum hit act as the start of a loop. It doesn't really matter what was playing before if you loop into something loud and aggressive. That tip may or may not be useful in your particular case.

Once you have the two sides looping nicely, you need to re-assemble everything. Remember that we have been editing the end of one clip and the beginning of another, so we need to join the two things up. We also need to clip out the intro.

Assembling and Saving Your Loop
8. Select your right-hand track
9. CTRL + X to cut it out
10. Click on the Audacity background (the grey area behind the tracks)
11. CTRL + V to paste your clip as a new track
12. Ensure that the tracks line up exactly
13. Select from a random point in the center of the new track all the way to the right
14. Delete that section
15. Select from the left of the other track to that same point (the cursor should snap when you are close)
16. CTRL + ALT + K to "Split Delete" which removes your selection without moving the rest of the track
17. Select both tracks by CTRL + clicking their information panels
18. Tracks -> Mix and Render
19. Select the new track and File -> Export -> Export as WAV. This is your complete loop

Snipping and Saving Your Intro
20. Drag the original music file into your project alongside the loop (if you applied limiting/normalization to your project, make sure that the this track has those applied with the same settings)
21. Select a point where something dramatic happens in the waveform and line the two tracks up exactly, down to the sample. See below for what this looks like zoomed quite far in. Your loop should start right about where you originally snipped out the intro section


22. Select the area from the point where the loop starts
23. Delete it
24. Listen to the intro up through the point where it transitions into the loop
25. If the transition is clean, select the intro track and File -> Export -> Export Selected Audio
26. If the transition is NOT clean you need to adjust the intro section using the same techniques as looping. Try to avoid modifying the looped section. If you do, you will need to ensure that it still loops properly
Thank You!
I hope this guide has been helpful. Creating loops is an art form and as such you will undoubtedly encounter situations not covered here. If you are having trouble with a particular track, please feel free to leave a comment and I'd be happy to work through it with you. You may have noticed that I rather enjoy this :). If you want to fall further down the audio rabbit hole, I maintain an absurdly detailed guide on cleaning files of noise and music.

Good luck looping!
5 Comments
Musterduck 22 Mar, 2021 @ 6:06pm 
thank you so much, that helps a lot
nintendoeats  [author] 22 Mar, 2021 @ 6:03pm 
@Jackass it has literally been years since I wrote this, but I think what you want is to press F5 to get the tool that lets you move tracks around.
Musterduck 22 Mar, 2021 @ 5:53pm 
I'm new to this and got up to step 21 and now I'm terribly confused. How do I go about lining the tracks up? The way you phrase it I'm assuming there's a way to orient the track on the bottom so that the intro hangs off rather than the ending, but I'm not seeing it. Or do you just eyeball it like step 12?
nintendoeats  [author] 8 Dec, 2020 @ 5:26pm 
Thanks!
JcDentonQ 8 Dec, 2020 @ 6:38am 
Thanks for the guides, well explicated and complete. :cozyrealmroyale: