Skip to content

Bash tool for convert various video game music files to FLAC

License

Notifications You must be signed in to change notification settings

Jocker666z/vgm2flac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

vgm2flac

Bash tool for convert various video game music files to FLAC.

Install & update

curl https://raw.githubusercontent.com/Jocker666z/vgm2flac/main/vgm2flac.sh > /home/$USER/.local/bin/vgm2flac && chmod +rx /home/$USER/.local/bin/vgm2flac

Dependencies

Core

bc ffmpeg ffprobe sox soxi xxd

Decoder

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.

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.

Compress, encode, tag & ReplayGain

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.

Use & description

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)

Arguments options

  --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 supported

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

Midi files

fluidsynth

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:

munt

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.

Commodore 64 files

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 parameter Songlength 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

GSF files (GBA)

Default conversion made with gfs2wav, but if binary not installed backup convert made by ZXTune.

snsf files (SNES)

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.

Known error

  • unrepeatable usf/miniusf decoding stuck = zxtune123 bug

Notable sites, source of audio files

Holy reading

Files specification

Dependencies installation:

asap

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"

gsf2wav

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/

mednafen

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"

munt

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"

nsfplay

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

sc68 & info68

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"

Portable mdx

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/

vgm_tag

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

vgm2wav

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"

vgmstream-cli

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"

uade

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"

zxtune123

Bin here: https://zxtune.bitbucket.io/

TODO

About

Bash tool for convert various video game music files to FLAC

Topics

Resources

License

Stars

Watchers

Forks

Languages