vgm_trim

From vgmrips

vgm_trim is a tool for trimming and looping VGM files.

Usage

You may drag and drop a file onto the program to be prompted for inputs, or use the command line as shown below.

vgm_trim YourFileGoesHere.vgm startSample loopSample endSample OptionalCustomOutputName.vgm

Example:

vgm_trim track1.vgm 15280 23499 194222

The inputs startSample, loopSample and endSample are expressed in 44100Hz samples.

Input parameters for vgm_trim
Input Description Default Special Values
Start Sample The 1st sample of the new VGM file 0
Loop Sample Sample to which the VGM goes when it loops back 0
0
Track does not loop
-1
Loop from Start Sample. If Start Sample is 0, you must use this.
-2
Keep old Loop Point. If there was no loop, there will be no loop.
End Sample Sample where the VGM ends or loops back 0
0
Actually not a special value, but can be used to cancel trimming
-1
Use Total Samples (i.e., End Sample is the end of the VGM data)

Any data in the VGM after End Sample is not included, unless End Sample is one of the special values above.

Suggestions

These require using the command line form.

  • To automatically create a record of your sample points, add >> trim_points.txt to the end of your vgm_trim commands. This should create a text file of that name if it doesn't exist, and add vgm_trim's output to the end of that file.
  • (Discouraged) If you put the argument `-state` after the program name, vgm_trim will put a save state of all used chips at the beginning of the VGM. You can use this if the instruments don't want to sound right even with silence at the beginning. However, it isn't recommended and is not yet supported for all chips.

Finding Input Samples

There are several methods.

  • Usually, you can use vgmlpfnd to get a reasonable loopSample and endSample, and get a good startSample with vgm2txt.
    • vgm_spts and vgm_sptd can often be used to trim starting silence for you, but this is considered an advanced usage.
  • (Suggested by MaliceX) If vgmlpfnd fails to find good samples, you can listen to the track to find the approximate sample times. Then, use vgm2txt to look in those areas for the sample values to use. (See Finding Trim Points with vgm2txt, ideally after it has been revised for readability.)
  • Sometimes it is useful to use a 44100Hz WAV recording of your VGM, and find the approximate sample points with an audio editing software such as Tenacity, Wavosaur, Sony Sound Forge, or others. You can then cross-check the sample values with vgm2txt to be sure. (See Finding Trim Points in WAV Files, ideally after it has been revised for readability.)


Advanced users: If you're familiar with assembly, the intuition of using vgm2txt to find the best sample point (through looking for the relevant command patterns) should be similar to finding a good opcode to replace with a JMP in a disassembly.