Skip to content

Some useful scripts for making VGM packs

Technical discussion about the VGM format, and all the software you need to handle VGM files.

Moderator: Staff

  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Some useful scripts for making VGM packs

Post by ValleyBell »

During the past years I've written a few batch scripts that I use when doing my pack checking/repackaging work.

There are two ways the scripts work, which are denoted in square brackets:
  • [folder] - copy the file into the folder and double-click it
  • [drop] - drop a file on the .bat script
Note: You can execute all of that stuff directly in cmd.exe, if you type only one % instead of %%.

The tools used in the scripts are: The first line of all of my batch scripts is usually this one:

Code: Select all

set PATH=C:\Users\User\VGMTools
This way I can just copy the script into any folder and it still finds the tools.

VGM editing/packaging
[folder] check all VGMs (and remove a trailing 0-character from VGMTool tags), then optimize the VGM header:

Code: Select all

for %%f in (*.vg?) do vgm_ptch -CheckT -MinHeader -MinVer "%%f"
[folder] prepare VGM for v1.70 extra header hex-editing:

Code: Select all

for %%f in (*.vg?) do vgm_ptch -ResizeHead:0xE0 -Check "%%f"
[folder] apply volume gain factor of 2.0 / 200% / +6 db:

Code: Select all

for %%f in (*.vg?) do vgm_ptch -SetVolMod:2.0 -Check "%%f"
[folder] optimize all VGMs with vgm_cmp:

Code: Select all

mkdir cmp
for %%f in (*.vg?) do vgm_cmp "%%f" "cmp\%%f"
[folder] optimize all VGMs with vgm_sro, then vgm_cmp:

Code: Select all

mkdir sro
copy *.vg? sro\*.vg?
for %%f in (*.vg?) do vgm_sro "%%f" "sro\%%f"
cd sro
mkdir cmp
copy *.vg? cmp\*.vg?
for %%f in (*.vg?) do vgm_cmp "%%f" "cmp\%%f"
[folder] decompress all VGZs into VGM:

Code: Select all

ren *.vgz *.vgm.gz
ren *.vgm *.vgm.gz
gzip -d *.vgm.gz
for %%f in (*.vgm.gz) do ren "%%f" "%%~nf"
[folder] compress all VGMs into VGZ:

Code: Select all

ren *.vgz *.vgm
gzip -n9 *.vgm
for %%f in (*.vgm.gz) do ren "%%f" "%%~nf"
ren *.vgm *.vgz
Note: Be careful to not accidentally gzip everything multiple times!

Screenshot handling
[folder] optimize all screenshots with PNGOUT (tries 24-bit colour, then 8-bit, then greyscale):

Code: Select all

for %%f in (*.png) do pngout "%%f" /c2 /f0
for %%f in (*.png) do pngout "%%f" /c3 /d0 /f0
for %%f in (*.png) do pngout "%%f" /c0 /d0 /f0
[drop] crop openMSX screenshots to MSX1 resolution 256x192:

Code: Select all

move %1 %1.bak
magick %1.bak -crop 256x192+32+24 %1
[drop] crop openMSX screenshots to MSX2 resolution 256x212:

Code: Select all

move %1 %1.bak
magick %1.bak -crop 256x212+32+14 %1
[drop] scale screenshots by 1x2, i.e. fix aspect ratio for PC-88/98 resolution 640x200:

Code: Select all

move %1 %1.bak
magick %1.bak -sample "100x200%%" %1
[drop] remove scanlines from screenshots, black is on lines 1/3/5/...:

Code: Select all

move %1 %1.bak
magick %1.bak -define sample:offset=25 -sample "100x50%%" -sample "100x200%%" %1
[drop] remove scanlines from screenshots, black is on lines 0/2/4/...:

Code: Select all

move %1 %1.bak
magick %1.bak -define sample:offset=75 -sample "100x50%%" -sample "100x200%%" %1
  • User avatar
  • Gnome Offline
  • Posts: 107
  • Joined: 2017-01-12, 13:39:56

Post by Gnome »

Huge thanks for the vgm_cmp and vgm_sro scripts. Here's another one you can use in Powershell:

Code: Select all

Dir | Rename-Item -NewName { $_.name -replace "_optimized","" }
What it does is removes the "_optimized" suffix after you run your vgms through either of the aforementioned tools. It should be useful when you have a lot of songs you don't wanna rename manually.
These days I mostly maintain old/faulty packs.
  • Tom Offline
  • Ragequit Member
    Ragequit Member
  • Posts: 496
  • Joined: 2011-11-30, 17:26:44
  • Location: Italy
  • Contact:

Post by Tom »

Well, I did make a tool which removes the _suffixes from all the .vg? files in a directory: http://vgmrips.net/forum/viewtopic.php?p=947#p947

(someone with mod powers and FTP access should probably double check the link in my old post and/or edit it, though, since it still points to mdscene)

edit: it has been fixed.
Last edited by Tom on 2020-04-19, 19:17:33, edited 1 time in total.
Also known as nineko.
  • User avatar
  • Gnome Offline
  • Posts: 107
  • Joined: 2017-01-12, 13:39:56

Post by Gnome »

https://vgmrips.net/programs/tools/vgm_name.rar <- this here is a working link.
These days I mostly maintain old/faulty packs.
  • Tom Offline
  • Ragequit Member
    Ragequit Member
  • Posts: 496
  • Joined: 2011-11-30, 17:26:44
  • Location: Italy
  • Contact:

Post by Tom »

Thanks for checking that, I wasn't sure if all the files got moved to the new server back then, hence why I mentioned FTP, but if things are this simple I'll just edit my old post myself :)

edit: ha, someone already did that, I'm looking at you, ValleyBell :ihih:
Also known as nineko.
  • ctr Offline
  • Posts: 492
  • Joined: 2013-07-17, 23:32:39

Post by ctr »

Here are (some of the) scripts I used for "Street Fighter EX2 Plus". Probably the most useful one is "packgen.bat"

sfex2p.bat - logging script. Creates a "debug script", runs MAME automatically and copies the files (with temporary tags) to a new folder. Since it is done by a script, the VGMs will have minimal silence in the beginning and start at the exact time, making trimming easier. Remember to set "vgmwrite" to 1 in mame.ini or modify the script to set this parameter directly.

Of course this doesn't work immediately for each game, there is some manual effort needed to actually write a script that will work for each game. (Usually games on the same hardware using the same sound driver will work with the same script, though)

playlist.bat - Makes a playlist of all vgms. I run this once all tracks have been logged and then run VGMPlay with the "LogSound" setting to create wav files. You can modify this to make playlist for trimmed and optimized vgms later, for example when using vgm_vol

trim.bat - trimming script. I trim files manually using vgm_trim, then copy the parameters to this file, which I keep in case I have to log tracks again (along with original VGMs and creation scripts)

optimize.bat - Optimizes all tracks

unicode.html - Website to convert unicode text to character codes for vgm_tag (and packgen.bat). Also available online here

packgen.bat - my VGM tagging and packaging script. I edit this for every game and just run it, it tags vgms using vgm_tag (files should be named something like 123_trimmed_optimized_optimized.vgm), copies them to a directory with the game's name with a proper name (for instance "01 Title.vgm"). Outputs the song listing (using vgm_stat) to standard output which can then be copied and used when writing the description txt. (Also disregard some of the comments in that file, it's just old junk)
Attachments
packtools.zip
(4.64 KiB) Downloaded 623 times
  • Dekyo-NO Offline
  • Posts: 100
  • Joined: 2017-11-02, 3:58:27

Post by Dekyo-NO »

For those who use 7-Zip (and doesn't have the gzip utility) to compress VGMs, I use this little script I created:

Code: Select all

@echo off
rem VGM -> VGZ
for %%a in (*.vgm) do 7z a -tgzip "%%~na".vgz "%%a" -mx9
Save it as "compress.bat" and place it in your working directory. This script assumes that you have the installed version of 7-Zip. You can customize it to run 7za instead of 7z.
  • User avatar
  • ValleyBell Offline
  • Posts: 4768
  • Joined: 2011-12-01, 20:20:07
  • Location: Germany

Post by ValleyBell »

I made a Python script that checks whether or not an image is scaled 200% and if so it scales it back to 100%: Pic2xTo1x.py
You will need to install these pip packages first: pillow, numpy

Usage:

Code: Select all

python Pic2xTo1x.py "input_2x.bmp" "output_1x.bmp"
Note: If the image can not be scaled down properly, then it will show a warning AND will colour all non-matching pixels magenta (RGB code FF00FF).
It currently supports only images with an 8-bit palette. (can be BMP/PNG/...) I will add support for 24-bit RGB images later.


trivia: The tool is based on a Visual Basic 6 program I've been using for years.
The VB6 program was very tedious to use (it required inserting paths into the source code and it was slow), so I'm pretty happy to have a Python script now that I can just use with the command line.
Post Reply