Bash tool for convert various video game music files to FLAC.
curl https://raw.githubusercontent.com/Jocker666z/vgm2flac/main/vgm2flac.sh > /home/$USER/.local/bin/vgm2flac && chmod +rx /home/$USER/.local/bin/vgm2flac
bc ffmpeg ffprobe sox soxi xxd
adplay asapconv bc bchunk fluidsynth gsf2wav info68 mednafen munt nsfplay sc68 sidplayfp vgm2wav vgmstream_cli vgm_tag uade wildmidi xmp zxtune123
You will be able to run vgm2flac even if some dependencies are missing. The script will warn you if a dependency is not met depending on the file format to convert.
- adplay: https://github.com/adplug/adplay-unix
- asapconv: https://asap.sourceforge.net/
- gsf2wav: https://github.com/jprjr/gsf2wav
- ffmpeg: must be compiled with
--enable-libgme
- fluidsynth: https://www.fluidsynth.org/
- mednafen: https://mednafen.github.io/
- munt: https://github.com/munt/munt
- nsfplay: https://github.com/bbbradsmith/nsfplay
- sc68 & info68:
- original source: https://sourceforge.net/projects/sc68/
- prefered version: https://github.com/Jocker666z/sc68
- sidplayfp: https://github.com/libsidplayfp/sidplayfp
- portable mdx: https://github.com/yosshin4004/portable_mdx
- uade: https://gitlab.com/uade-music-player/uade
- vgm2wav: https://github.com/ValleyBell/libvgm
- vgmstream-cli: https://github.com/losnoco/vgmstream
- vgmtag: https://github.com/vgmrips/vgmtools
- wildmidi: https://github.com/Mindwerks/wildmidi
- xmp: https://xmp.sourceforge.net/
- zxtune: https://zxtune.bitbucket.io/
Help is available at the bottom of the page for the installation of dependencies that are generally not present on the official repositories of the largest GNU/Linux distributions.
flac metaflac mac mutagen-inspect opusenc rsgain wavpack wvtag
- metaflac: used for tag & ReplayGain
- mutagen-inspect: for display info (in
python3-mutagen
package) - rsgain: used for ReplayGain, it takes precedence over metaflac, and handles all other final file types
These dependencies are all optional. But are highly recommended, especially flac
, metaflac
, mutagen-inspect
& rsgain
.
Simply launch vgm2flac command in directory with vgm files supported.
- If possible, encoding is done in parallel.
- If available, the tags are always implemented in the final file.
- Default decoding/compressing loop:
- vgm decoding to WAV
- -optional- remove silences
- -optional- forced apply fade out
- false stereo detection (md5 channel + noise db compare)
- -optional- peak normalisation to -1db
- WAV compressing to FLAC at level
-8 -p -r 15 -l 32 --lax --no-padding --no-seektable
- -optional- compressing to Monkey's Audio at level
-c5000
- -optional- compressing to WAVPACK at level
-hhx3
- -optional- encoding to OPUS at 192kb
--bitrate 192 --vbr
- remove duplicate files (diff)
- tag output files
- apply a ReplayGain (if no peak normalisation)
--add_ape Compress also in Monkey's Audio.
--add_opus Compress also in Opus at 192k.
--add_wavpack Compress also in WAVPACK.
-d|--dependencies Display dependencies status.
-h|--help Display this help.
--force_fade_out Force default fade out.
--force_stereo Force stereo output.
-j|--job Set the number of parallel jobs.
--no_fade_out Force no fade out.
--no_remove_duplicate Force no remove duplicate files.
--normalization Force peak db normalization.
-o|--output <dirname> Force output directory name.
--only_wav Force output wav files only.
-s|--summary_more Display more infos at start & end.
--remove_silence Remove silence at start & end of track (85db).
--remove_silence_more Remove silence agressive mode (58db).
-v|--verbose Verbose mode
VGM files are processed in two ways:
- hard-coded extensions associated with a decoder
- testing of certain multi-machine decoders on other files.
hard-coded extensions:
- AdLib:
adl, amd, bam, cff, cmf, d00, ddt, dtm, got, hsc, hsq, imf, ksm, laa, mdi, rad, rol, sdb, sqx, wlf, xms
- Amstrad CPC:
ay, ym
- Atari ST, XL/XE: sap,
sc68, snd, sndh, ym
- Commodore C64/128:
sid, prg
- Fujitsu FM-7, FM Towns:
s98
- NEC PC-Engine/TurboGrafx-16:
hes
- Nintendo GB, GBA, DS, N64, NES, SNES:
2sf, gbs, gsf, mini2sf, minigsf, minincsf, minisnsf, miniusf, ncsf, snsf, nsf, nsfe, spc, usf
- PC MIDI & derivate:
hmi, mid, hmp, xmi
- Sharp X1, X68000, Turbo, Turbo Z:
mdx, s98
- Sega Dreamcast, Saturn:
dsf, minidsf, minissf, ssf
- Sony Playstation 1, 2:
psf, psf2, minipsf, minipsf2
- Various machines:
vgm, vgz
- Various machines mixed
CD: bin, bin/cue, img/cue, iso/cue
- ZX Spectrum:
asc, ay, psc, pt2, pt3, sqt, stc, stp
testing:
- streamed audio files (vgmstream)
- Microsoft Xbox, Xbox 360
- Nintendo 3DS, GameCube, Switch, Wii
- Sega Dreamcast
- Sony Playstation 1, 2, 3, 4, 5, PSP, Vita
- Panasonic 3DO
- PC & mobile
- Philips CD-i
- tracker files & others (uade, xmp, zxtune)
- Amiga
- PC
If you want to use a specific soundfont the parameter fluidsynth_soundfont=""
has to be filled in at the beginning of the script.
Recommended soundfonts:
- Arachno SoundFont - https://www.arachnosoft.com/main/soundfont.php
- Roland MT-32 - https://www.hedsound.com/2019/06/mt32-cm64l-sf2-for-everyone.html
- Roland SC-55 (EmperorGrieferus version) - https://drive.google.com/file/d/1G53wKnIBMONgOVx0gCOWrBlJaXsyaKml/view
- Sound Blaster 16 - https://github.com/Mindwerks/opl3-soundfont
- SGM-V2.01 (Shan's GM soundfont) - https://archive.org/details/SGM-V2.01
- Tyroland (Yamaha Tyros 4 + the JV-1010 Soundfont) - https://musical-artifacts.com/artifacts/1305
- WeedsGM3 (Rich ¥Weeds¥ Nagel's soundfont) - https://github.com/octylFractal/MidiEditor/raw/master/WeedsGM3.sf2
If you want to use munt Roland MT-32 emulator as decoder, you must filled parameter munt_rom_path=""
with the ROM path of MT-32.
For use correct track duration, you have 2 solutions:
- In vgm2flac script file, filled parameter
hvsc_directory=""
with the C64Music path (https://hvsc.c64.org/downloads). - In sidplayfp config file
/home/$USER/.config/sidplayfp/sidplayfp.ini
filled parameterSonglength Database =
, with Songlengths text file.
In most cases the music is converted without problems, but you may need to add the Kernal, BASIC, and Chargen ROM files to the configuration file of sidplayfp. These files are available here https://github.com/Jocker666z/vgm2flac-dep/raw/main/C64-ROM.tar.bz2
Default conversion made with gfs2wav, but if binary not installed backup convert made by ZXTune.
Here the conversion is highly experimental, it is done while reading the file, this is the only way I found to do it. So you will have to be patient.
- unrepeatable usf/miniusf decoding stuck = zxtune123 bug
- Atari ST: http://sndh.atari.org/
- Atari XL/XE: https://asma.atari.org/
- Commodore 64: https://hvsc.c64.org/
- Various machines: https://vgm.hcs64.com/
- VGM: https://vgmrips.net/
- https://wiki.archlinux.org/index.php/FluidSynth
- http://loveemu.hatenablog.com/entry/Conversion_Tools_for_Video_Game_Music
- http://www.vgmpf.com/
- https://vgmrips.net/wiki/Main_Page
- https://github.com/Sembiance/dexvert/blob/master/SUPPORTED.md
- GBS https://ocremix.org/info/GBS_Format_Specification
- GSF https://www.caitsith2.com/gsf/gsf%20spec.txt
- HES http://www.purose.net/befis/download/nezplug/hesspec.txt
- KSS https://ocremix.org/info/KSS_Format_Specification
- MDX https://github.com/vampirefrog/mdxtools/blob/master/docs/MDX.md
- NSF https://wiki.nesdev.org/w/index.php/NSF
- NSFe https://wiki.nesdev.org/w/index.php/NSFe
- SGC https://ocremix.org/info/SGC_Format_Specification
- SAP https://asap.sourceforge.net/sap-format.html
- SID https://ocremix.org/info/SID_Format_Specification
- SC68 http://sc68.atari.org/developers_fileformat.html
- SNSF https://snsf.caitsith2.net/snsf%20spec.txt
- SPC https://ocremix.org/info/SPC_Format_Specification
- PSF https://gist.githubusercontent.com/SaxxonPike/a0b47f8579aad703b842001b24d40c00/raw/a6fa28b44fb598b8874923dbffe932459f6a61b9/psf_format.txt
- XMI https://moddingwiki.shikadi.net/wiki/XMI_Format
Build dependencies: wget build-essential
wget https://sourceforge.net/projects/asap/files/asap/5.2.0/asap-5.2.0.tar.gz/download -O asap-5.2.0.tar.gz
tar -xf asap-5.2.0.tar.gz
cd asap-5.2.0
make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: git build-essential
git clone https://github.com/jprjr/gsf2wav && cd gsf2wav
git clone --recursive https://github.com/jprjr/lazygsf/
git clone https://github.com/jprjr/psflib
mkdir build && cd build
cmake .. && make -j"$(nproc)"
cp gsf2wav /home/$USER/.local/bin/
Build dependencies: git build-essential pkg-config libasound2-dev libcdio-dev libsdl1.2-dev libsndfile1-dev zlib1g-dev
git clone https://github.com/libretro-mirrors/mednafen-git && cd mednafen-git
./configure && make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: git build-essential cmake libpulse-dev libasound2-dev libjack-jackd2-dev qtbase5-dev
git clone https://github.com/munt/munt && cd munt
mkdir build && cd build && cmake ..
make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: git build-essential
git clone -b vgm2flac_stable https://github.com/Jocker666z/nsfplay/ && cd nsfplay/contrib
make -j"$(nproc)"
cp nsf2wav /home/$USER/.local/bin
Build dependencies: git build-essential autoconf libtool libtool-bin automake pkg-config libao-dev zlib1g-dev
cd
git clone https://github.com/Jocker666z/sc68 && cd sc68
tools/svn-bootstrap.sh && ./configure LDFLAGS="-static"
make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: git build-essential
git clone https://github.com/yosshin4004/portable_mdx
bash -c 'cd portable_mdx/examples/simple_mdx2wav && bash build.sh'
cp portable_mdx/examples/simple_mdx2wav/simple_mdx2wav /home/$USER/.local/bin/
Build dependencies: git build-essential
git clone https://github.com/vgmrips/vgmtools && cd vgmtools
mkdir build && cd build && cmake ..
make -j"$(nproc)"
cp vgm_tag /home/$USER/.local/bin
Build dependencies: git build-essential cmake zlib1g-dev libao-dev libdbus-1-dev
git clone https://github.com/ValleyBell/libvgm && cd libvgm
mkdir build && cd build && cmake ..
make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: gcc g++ make cmake build-essential git libmpg123-dev libvorbis-dev libspeex-dev libavformat-dev libavcodec-dev libavutil-dev libswresample-dev yasm libopus-dev pkg-config autoconf libtool-bin libao-dev libjansson-dev
git clone https://github.com/vgmstream/vgmstream && cd vgmstream
mkdir build && cd build
cmake .. -DBUILD_AUDACIOUS=OFF
make -j"$(nproc)"
su -c "make install" -m "root"
Build dependencies: git build-essential sparse
git clone https://gitlab.com/heikkiorsila/bencodetools && cd bencodetools
./configure && make -j"$(nproc)"
su -c "make install" -m "root"
cd ..
git clone https://gitlab.com/hors/libzakalwe && cd libzakalwe
./configure && make -j"$(nproc)"
su -c "make install" -m "root"
cd ..
git clone https://gitlab.com/uade-music-player/uade && cd uade
./configure && make -j"$(nproc)"
su -c "make install" -m "root"
Bin here: https://zxtune.bitbucket.io/
- .eup .fmb .pmb : EUPHONY Module https://github.com/gzaffin/eupmini
- .uni : MikMod Module https://github.com/Sembiance/mikmod2wav https://github.com/sezero/mikmod