Finding Trim Points in WAV Files

From vgmrips

To know where to trim if vgmlpfnd and vgm2txt aren't enough, you will need to make a WAV file from a VGM and open it in a program that can display what the music waveform looks like.

Creating .WAVs from VGMs

Note: Converting will be very resource-intensive and may slow down your computer during the conversion. (It will only occupy a single CPU core though) The resulting WAV file(s) will be large, but you will only keep them for the short time of finding loop points.

Any music player that can play VGMs and create .wav files can do the trick. To keep the page small, we will just look at VGMPlay here. See "#Other Players?" below for info regarding others.

By changing VGMPlay settings

Open VGMPlay.ini in a plain-text editor like Notepad. Find (ctrl+f) and change the following settings like so.

[General]
SampleRate = 44100
JinglePause = 0
FadeRAWLogs = False
Volume = 1.0
LogSound = 1

You can now drop your logs on VGMPlay.exe and wait for output to finish.

Note: You can also place just these options in a new VGMPlay.ini file that you put inside the folder of VGMs you're working on. VGMPlay will automatically use it, and you can just move/delete the file when you don't need it.

By using a shortcut (on Windows)

  • Make a shortcut of VGMPlay.exe, and name it "VGMPlay (wave log)"
  • Open the shortcut properties
  • In the "destination" field, add -c General.SampleRate=44100 -c General.JinglePause=0 -c General.FadeRAWLogs=False -c General.Volume = 1.0 --dump-wav

You can now drag and drop VGMs and/or M3Us on that shortcut.

By using VGMPlay on the Command Line

vgmplay -c General.SampleRate=44100 -c General.JinglePause=0 -c General.FadeRAWLogs=False -c General.Volume=1.0 --dump-wav "your_vgm_here.vgm"

Other Players?

Check the readme or options to see if they describe how to convert files.

If you want/need instructions for any of ZXTune or in_vgm with Winamp or XMPlay, see this older version of this tutorial.

At last report years ago, using Foobar's foo_gep seemed to strip silence you need to trim properly. I'm not sure if this is still the case.

Advice, Dawg

For experienced loggers. If none of the following makes sense, just come back later.

You'll sometimes want to make WAVs of your trimmed VGMs, too: to compare them to the raw logs, and make sure your timing is correct. At those times, you might want to use vgm_trim with 0 for the Start Sample so you don't have to line up the waveforms by hand.

Note: (By the way, the waveform being slightly different during the loop is just normal. As long as there are no audible artifacts, everything should be fine.)


Sound Editors

There are a few of these:

Any other program like these, which lets you view exact samples (see below) in WAVs, is fine too. However, while GoldWave is used for the example images of waveforms, only Audacity + forks will be covered below, to reduce page bloat. If you need information for the other three programs, see this older version of this tutorial.


Viewing in Samples

When viewing a WAV file, you're trying to find the exact start, loop begin (if applicable), and loop/song end points. These numbers should be in samples, not seconds.

In the converting instructions above, the number 44100 appeared. VGM stores data at a resolution of 44100 samples per second (hence, 44.1 KHz); that's why it was important that the WAV files used this sample rate/frequency too. If your sound editor says the files have that number, you're good to go.

But the default time numbers shown in these programs are in seconds, minutes and so on. At the bottom left in Audacity, you'll see a drop-down list (newer versions), or boxes saying Selection Start, End/Length, and Audio Position (older versions). There are arrows by the numbers below/nearby. Click any of those (or right-click on the numbers themselves), and select "samples".

Note: If you don't see any of that stuff, Use View -> Toolbars and make sure Selection Toolbar is checked.

Now Audacity is giving you what you need: the position of the selection markers in samples. Once you've done this once, you shouldn't need to do it again.


Finding Trim Points in the WAVs

Trimming VGMs shows the three types of songs, and shows examples of the kind of points you're trying to find. If you've never searched for trim points before, you can practice on the VGMs provided there. (You should also read the whole tutorial for further insight and info, if you haven't already.)

You want to find two to three points:

  • The time where the song starts (Start Sample)
  • Where it finishes (End Sample)
  • Where it jumps to when it finishes, to loop (Loop Sample, which can be 0 to indicate "No Loop" in case of non-looping songs)

For looping songs without an intro, Start Sample and Loop Sample may be the same number.


Now that you know what you're looking for, play the WAV file on your sound editor and find where the song starts. Select the part of the sound around this spot and zoom to fit the view. Zooming in lets you get more precise values. Keep zooming until you get a nice, close look at the sound wave.

This is the start of the Ghouls 'n Ghosts song, as mentioned in Trimming VGMs, in a close zoom. You can take a good look at the sound wave at this scale, but it's not abusively close either.

As you probably noticed, the Start Sample (yellow) is set a few samples away from the first noticeable changes in the wave. This is important because we don't want to trim out the starting commands at the beginning of the music, so we always give a bit of a space. Here's a hint: any space or gap below 500 samples is not noticed by the human ear at all. The above space is only 50 samples, which is less than 2 milliseconds in length!

Note: If the leading silence of a VGM log is only made of Wait commands, it's safe to go right up to the end of the Wait and beginning of the music. You can't tell if that's the case with just WAVs, though. vgm2txt can not only show you this, but help you confirm all the trim points you find. If you combine these two methods, you're really playing with power!

It's also worth zooming in on the amplitude scale as mentioned in the next section:

This is the last sound wave we saw, with expanded amplitude. The tiny bump you noticed before is now a big obvious hump pointing down. Doing this is a good way to find silence gaps in songs, which make good and safer edit points. As mentioned, you can also make your sound editor "snap" to these zero-crossings for you.

Once you've placed the selection marker at the appropriate position, get the number for it (depending on how you selected and how your sound editor shows you this information) and write it down as the Start Sample. Discard the commas, if any are present. Do the same thing with the End and Loop Samples.

Listen carefully to the sound at these points and see if they're correct. If they are, it's time to use vgm_trim to do the actual trimming. Then you'll have to listen to the trimmed file to check if the file "agrees" that your trims are good.

You may need to repeat the finding process a few times to get good-sounding trim points, so don't be discouraged if your first tries sound funkotronic when actually trimmed. Even veterans can struggle with this. If you're having difficulty finding the right samples, or want more tools in your toolkit, try vgm2txt and vgmlpfnd.

Another method of finding loops which may make it easier can be found in the Manual looping tutorial.

Keep in mind that, as long as it sounds right and it doesn't have excessive information, the trimming is good.


Some things to make finding loop points easier

Many sound editors can mark loop points as you work, via menu options. In Audacity(/ies), I don't know any quick way to do so, except to:

  • use Edit -> Region Save/Restore to keep your selection/cursor
  • use label tracks on a selection or cursor and move the labels as needed

Zooming In/Out on Time and Amplitude

Zooming normally (that is, time-wise/horizontally) is pretty easy, most of the time complete with magnifying-glass icons. But the less-simple amplitude/vertical zoom is something you'll definitely want to know how to do.

Why's that? Some sounds actually start long before you can actually see them at the default amplitude scale (that's how tall the waveforms look). You can make bigger the sound wave on the vertical axis with the sound editor, and see where the VGM('s sound) actually starts. We'll see an example later on, when we learn trim point finding.

Right Click and Left Click on the amplitude scale to the left of the waveforms to zoom. You can also fit the horizontal selection to the window by pressing CTRL+E.

Finding "Zero Crossings"

Zero Crossings are points at the start and end of a loop that are silent (0.0db), which should make for good and safer loop/end points. You can make Audacity find these for you by merely pressing the Z key

Moving Your Loop Section Around Without Losing the Loop Length

Optional, but extremely handy and worth getting used to.

  1. There are two radio buttons after the start point that say End and Length. Push Length.
  2. Click into or otherwise access Selection Start, so that you can enter numbers there.
  3. Change the start point as you need by typing.
  4. When finished and ready to try the new endpoint in vgm_trim, change the radio button back to End.