Finding Trim Points in WAV Files
To know where to trim if vgmlpfnd and vgm2txt aren't enough, you will need to output a WAV file and view it in a program that can display the waveform. Let's start with your options for the latter:
- Audacity
- or an Audacity fork like Tenacity or Audacium. (Info below correct as of 2.0.6... yeah.)
- GoldWave (shareware)
- (Correct as of ~v5)
- ocenaudio
- (Correct info here as of... 2.0.16. Oy. Used much more RAM than Audacity.)
- Wavosaur
- Portable and lightweight; only requires <6mb disk space and uses even less RAM than Audacity.
Any music editing program that lets you view exact samples (see below) in WAVs is fine too. (This tutorial will use GoldWave for its example images of waveforms.) Whatever your choice, if you're not accustomed to the program, open any sound file it can work with in it and try to do the common tasks below until you're comfortable with the interface. Then I'll show you how to create the WAVs you need and find trim points for vgm_trim.
Contents
Everyday Tasks
Many music editing programs have native support for marking down loop points as you work. In Audacity(/ies), I'm not aware of any quick method of doing so beyond Edit -> Region Save/Restore. That doesn't necessarily mean one doesn't exist.
Viewing in Samples
When viewing a WAV file, you'll be trying to find the precise times for the start, loop begin (if applicable), and loop/song end points. This time value should be in samples, not seconds. VGM stores data at a resolution of 44100 samples per second (hence, 44.1Hz), which is why it's important to write the WAV files at this sample rate as I'll describe later: you'll get the numbers you need right away.
But the default time values you'll get with a sound editor are in seconds, minutes and so on, which isn't very helpful. To change to sample mode in:
Audacities
At the bottom, you'll see Selection Start, End/Length, and Audio Position. There are arrows by the numbers below. Click any of those (or menu-click on the numbers themselves), and select "samples".
(If you don't see any of that stuff, Use View -> Toolbars and make sure Selection Toolbar is checked. Newer versions use a slightly different interface, but the principle is the same.)
GoldWave
There is a status bar at the bottom of the screen giving you a number in the format "__ to __ (__ unit)". Right click on it and select the option that says "__ to __ (__ smp)" (it should be the second to last option). The bar will now give you numbers like "selection-start to selection-end (selection-size smp)".
ocenaudio
Use View -> Display Time Format -> Samples.
Getting the exact sample numbers for vgm_trim isn't intuitive. You have two options:
- Hold Alt and move the cursor to make the exact sample number beneath it appear at the bottom. Move the cursor over the trim point you want to find. This is imprecise and best combined with vgm2txt.
- Click to place the cursor before a marker or region (see below). Use Controls -> Move Cursor -> Next Marker; the exact sample will display in the black window at the top. A region counts as a single marker; to see the end sample you must use Edit -> Select Audio from Regions, and the end sample will display. This is precise but a bit of a pain.
Wavosaur
Use Options -> Sample Display -> Samples. The currently-selected range will always be visible next to the track's sample rate (which should of course read 44100 Hz). If there's no selection, the numbers will be the same.
Now the program 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.
Zooming In/Out on Time and Amplitude
Zooming normally (that is, time-wise/horizontally) is a pretty intuitive activity, complete with magnifying-glass icons most of the time. But the less-intuitive 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 enlargen the sound wave on the amplitude 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.
Audacity
Right Click and Left Click on the amplitude scale to the left of the waveforms. You can also fit the horizontal selection to the window by pressing CTRL+E.
GoldWave
Press CTRL+UP and CTRL+DOWN. Fit the selection by pressing SHIFT+S.
ocenaudio
There's a magnifying glass in the upper-right corner, next to the waveform. This is used for horizontal and vertical zooming, but doing so is not intuitive either way.
Without a selection, the glass has a + inside: Click/hold it, and it will zoom in toward the music cursor. With a selection, it has nothing inside: Clicking/holding it will zoom so that the selection fills the window. Hold Ctrl when you click to make the + appear and scroll normally.
Either way, hold Shift to make - appear and zoom out.
To zoom in on amplitude, you must hold the Alt key. Hold Shift at the same time to zoom out.
You can also use View -> Zoom for all these things, and to fit to the selection.
At this point, you no doubt want to know how to scroll left and right while zoomed in. If you hover the cursor over the samples at the bottom, it will change to indicate you can drag. Click and drag left/right to scroll.
Wavosaur
Next to the normal Zoom buttons, you'll find amplitude zoom buttons. Apply as needed.
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 the program find these for you.
- Audacities
- Simply press the Z key.
- GoldWave
- Use Edit -> Marker -> Snap to zero crossing.
- ocenaudio
- Use Adjust Selection -> Snap to Zero Cross. This can be found in the Edit menu, or by menu-clicking on your selection.
- Wavosaur
- Use Options -> Snap to zero crossing. This is a toggled option rather than one you activate by pressing, so you'll have to make new selections to use it.
Moving Your Loop Section Around Without Losing the Loop Length
Optional, but extremely handy and worth getting used to.
Audacities (~2.0.6)
- There are two radio buttons after the start point that say End and Length. Push Length.
- Click into or otherwise access Selection Start, so that you can enter numbers there.
- Change the start point as you need by typing.
- When finished and ready to try the new endpoint in vgm_trim, change the radio button back to End.
GoldWave
???
ocenaudio
- Use Edit -> Create Region to create a region from your selection.
- Move the cursor over one of the red region endpoints (at the top) until the cursor becomes a hand with all five fingers extended.
- Click and drag; the entire region should move. Place it where you want.
- If necessary, you can adjust the endpoints now by clicking on them when the hand has only the pointer/index/first finger extended.
- Use Edit -> Select Audio from Regions to regain a selection, so that you can play it and re-check the loop.
There is a feature to convert a region into a loop, but it doesn't appear to be helpful for our needs.
Wavosaur
You'll have to turn a selection of the possible loop into an, uh, Loop (Tools -> Loop -> Create Loop Points). Then open Properties (in the same menu) and change each loop sample by the amount of/to the pair of samples you need.
Okay, are you comfortable with your chosen sound editor? Then it's time to make some WAVs.
Creating .wavs from VGMs
Any music program that can play VGMs and create .wav files can do the trick. Described below are methods using VGMPlay, and Winamp/XMPlay + the VGM input plugin, in_vgm. Using in_vgm has the advantage you can stop the output for each VGM whenever you think you have enough of it converted; if it's possible in VGMPlay without mangling the file (or having to skip forward with Right Arrow), I don't know how.
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.
Using VGMPlay
In VGMPlay.ini, change the following settings as so. (You can also specify them with VGMs on the command line: see the program's wiki page linked above for the method.)
SampleRate = 44100 FadeTime = 0 FadeTimePL = 0 JinglePause = 0 FadePause = 0 FadeRAWLogs = False Volume = 1.0 LogSound = 1 [YM2612] Core = NUKE
You can now drop your logs on VGMPlay.exe and wait for output to finish.
Using Winamp, the VGM input plugin and the Disk Writer output plugin
Here's what you do:
- Run Winamp
- Press CTRL+P to open the preference screen, and then go to the "output" section
- Select the "Nullsoft Disk Writer plug-in" from the output list (if you don't have it, download the full version of Winamp, which has it bundled)
- Click on the configure button below the list and set the output directory (you might want to check "Output to directory containing source files"). Also, make sure you select the proper output format: PCM, 16 Bit, Stereo, 44.100 kHz. Just make sure the option "kill null samples" is disabled, because the file won't give you correct times if any samples are removed.
- Now go to the input section and configure the VGM input plugin. Set the option "pause after non-looped tracks" to zero.
- If shuffle, repeat, the equalizer or any DSP plugin are activated, turn them off. They won't do you any good here.
- Now just drop the file(s) into Winamp and play them. You won't hear a thing because the audio is being written to your hard drive. This process will be very resource-intensive and will probably slow down your computer for a while (depending of the size of the VGMs), and the resulting WAV file(s) will be very large, but you will soon get rid of them.
- Once Winamp is done writing the files, press CTRL+P again and turn the output plugin back to what was it before you changed it to the disk writer. This way you can listen to files again.
Using XMPlay and in_vgm
- Go into Options and Stuff (press F9, menu-click on XMPlay, or click the wrench icon), and go to Output.
- You don't have to change the sample rate as long as in_vgm is set to use 44100 Hz. Change the Device to "WAV Writer". Under "File writing", click the Source checkbox to make XMPlay dump WAVs into the same folder as the source VGMs (or use a specific Folder as you prefer).
- You may want to check Auto filename so the program doesn't ask every time, but this is optional.
- Now go to the Input section and configure the VGM input plugin. Set the option "pause after non-looped tracks" to zero. (To properly output trimmed files for comparison to raw logs, set Play Loops to 2.)
- If you don't want non-looping tracks to be written as if they're looped, go to Miscellaneous and uncheck "Auto-loop any track ending with sound".
- Open the VGMs in XMPlay: They'll automatically be written to WAVs.
- When all WAVs have been written, go back into the Options and change the Output Device back to what it was before you changed it to WAV Writer.
Good! So now you have the WAV file. Try opening it with your sound editor, and take a listen. This is what the VGM currently sounds like.
Finding Trim Points in the WAVs
You'll now have to look for the exact time where the song starts (Start Sample) and finishes (End Sample), and where it jumps to when it loops (Loop Sample, which can be 0 to indicate "No Loop"). There are three possible cases of these values showing up.
Type 1 - No Loop (Loop Sample = 0)
These are songs that play just once and then stop in silence: that is, there is no Loop Sample. Jingle, Game Over and Intro songs are usually of this type. Here's an example from Aladdin, "Ne Naw Tune":
As you can see, the song is complete on its own. There's a leading silence at the beginning of the VGM (black area), and we'll cut this off by placing the Start Sample (yellow line) closer to where the sound actually begins. On the other hand, the music finishes without extra silence (see note below), and hence the End Sample (red line) is at the very end.
Naturally, sometimes you'll have to cut extra silence or sound after the song finishes as well. (In rare cases where the log sounds like it's cut off at the end, you can add silence instead by giving vgm_trim an End Sample that's longer than the actual end of the VGM.)
Type 2 - Entire Song is Loops (Loop Sample = Start Sample)
The second type of music you'll find is when the entire song loops. That means it doesn't have any intro, and then the song just starts over once it finishes playing. Here's an example, also from Aladdin, "Storyline":
As you can see (and hear), the song drops to a silence and begins all over again. The Start Sample (yellow) is just at the start of the song (removing a leading silence at the beginning), and the End Sample (red) is at the exact place where the song starts again. Trimming like this will remove the redundant data after the red marker and the unwanted silence at the beginning.
Then, if you want to be extra-sure, you can make a looped WAV of your trimmed file and compare to the untrimmed log to make sure the silence isn't too long or too short.
Type 3 - Songs with Intro and Loops (Loop Sample ≠ Start Sample or 0)
The third type happens when the song has an intro part which plays only once. In this case, the Loop Sample is different from the Start Sample. Here's an example from Ghouls 'n Ghosts, the first boss (Shielder) battle song:
This time we have three different trim points. The Start Sample (yellow) cuts a tiny bit of leading silence at the beginning. What follows is a small intro (colored in light yellow), which then introduces the part of the song that repeats (in lime green). This is the Loop Sample, marked here with a cyan line. The End Sample (red) is placed at the exact point the song loops later on, trimming the repeated part that comes afterwards (the second+ loop logged).
Finding the correct edit points
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 in a close zoom. You can have 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!
It's also worth zooming in on the amplitude scale as I mentioned earlier:
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.
Anyway, 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.
You may need to repeat the finding process a few times to get good-sounding trim points, so don't be too discouraged if your first tries sound funkotronic when actually trimmed. If you're having difficulty finding the right samples, or want more tools in your toolkit, try vgm2txt and vgmlpfnd.





