vgm_ptch

From vgmrips

VGM patching utility. Allows editing the VGM header (chip clocks/chip settings), checking/fixing VGMs, and stripping chips and/or channels.

Note: vgm_ptch always edits the original file(s). It doesn't create new files, so you probably want to create your own backups first.

Usage

vgm_ptch [-command1] [-command2] file1.vgm file2.vgz

Command names are case insensitive.

General Commands

-Help Show vgm_ptch help
-ChipCmdList List all supported chips with SetHzxxx command
-StripList List all supported chips and channels for the Strip command

Patching Commands

Command format: -command:value
Command Description Notes
-SetVer Set Header-Version Set header version without further header modifications. Should not be used with VGM v1.00-1.10.

Example: 1.51

-UpdateVer Update Header-Version Change header version, and perform additional changes if necessary to keep the VGM functioning properly
-MinHeader Minimize Header Size VGM v1.50+; useful after stripping chips
-MinVer Minimize VGM Version VGM v1.50+; useful after stripping chips
-SetRate Sets the Playback rate VGM v1.01+
-SetHzxxx Sets the xxx's chip clock See -ChipCmdList for details
-SetLoopMod Set the Loop Modifier Value examples:
  • *2
  • /2.0
  • 0x20
-SetLoopBase Set the Loop Base Value can be any number between -128 and 127 (inclusive).
-SetVolMod Set the Volume Modifier Value examples: 1.0, 0x00

Commands to check the lengths (total, loop) and offsets (EOF, loop, GD3)

-Check
Asks for correction
-CheckR
Read-only mode (doesn't make changes but shows what would happen)
-CheckL
Autofix mode. Recalculates lengths
-CheckO
Like Autofix, but tries to relocate loop offset
-Strip
Strip the data of a chip and/or channel (see below). Does not yet work with all chips.
Note: Stripping without using other commands optimizes the delays.

Stripping Format

-Strip:Chip[-Number][:Channel,Channel,...];Chip[...]

e.g.:

-Strip:PSG:0,1,2,Noise,Stereo;YM2151
-Strip:YM2612-0;OKIM6295-1

Make sure the -Strip command does not have any spaces, like the examples above and below. Spaces will tell vgm_ptch the command is complete.

Stripping unused chips from a VGM

First use vgm_cnt on it, to see if there really are any unused chips.

  • Unused chips will usually have 0 for both Commands and Notes.
  • The SEGA VDP PSG is probably unused if it has no Notes.

If you do find an unused chip, you can strip it with the Strip option. Specify the chip (and channel, if necessary), such as like the following examples.

-Strip examples
Command Target chip
vgm_ptch -Strip:AY8910-0 insert_here_a.vgm
First AY chip
vgm_ptch -Strip:AY8910-1 ay-nother.vgm
Second AY chip
vgm_ptch -strip:ym2151 "04 Credit SFX.vgm"
YM2151

Afterwards, you can use the commands starting with -Min to try to shrink the VGM even further.