Coder Social home page Coder Social logo

jocker666z / vgm2flac Goto Github PK

View Code? Open in Web Editor NEW
8.0 2.0 0.0 876 KB

Bash tool for convert various video game music files to FLAC

License: GNU General Public License v2.0

Shell 100.00%
vgm flac audio-processing ffmpeg game-audio chiptune bash-script

vgm2flac's Introduction

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.
  • FLAC default quality is: 16 bits with compression level --lax -8pl32
  • Default decoding/compressing loop:
    • vgm decoding to WAV
    • optional: remove audio silence
    • apply fade out (if necessary or forced)
    • false stereo detection (md5 channel + noise db compare)
    • -optional- peak normalisation to -1db
    • WAV compressing to FLAC
    • -optional- compressing to Monkey's Audio at level -c5000
    • -optional- encoding to OPUS at 192kb --bitrate 192 --vbr
    • -optional- compressing to WAVPACK at level -hhx3
    • remove duplicate files (diff)
    • tag FLAC
    • 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

Files tested

  • 3DO : aif, aifc, str
  • Amiga: 8svx, aam, abk, ahx, bd, bp, core, cust, dw, fc13, fc14, gmc, mcr, mdat, mod, np3, rjp, sa, sb, scumm, sfx, xm
  • Amstrad CPC: ay, ym
  • Atari ST: sc68, snd, sndh, ym
  • Atari XL/XE: sap
  • Philips CD-i: xa
  • Commodore C64/128: sid, prg
  • Fujitsu FM-7, FM Towns: s98
  • Microsoft Xbox: aix, mus, sndsn, sfd, xwav
  • Microsoft Xbox 360: bik, wem, xwb
  • Mobile: acb/awb, fsb, txtp
  • NEC PC-Engine/TurboGrafx-16: hes
  • Nintendo 3DS: bcstm, wem, bcwav, fsb, mus, txtp
  • Nintendo DS: 2sf, adx, mini2sf, minincsf, ncsf, sad
  • Nintendo GB & GBC: gbs
  • Nintendo GBA: gsf, minigsf
  • Nintendo GameCube: adx, cfn, dsp, hps, adp, thp, mus
  • Nintendo N64: usf, miniusf
  • Nintendo NES: nsf, nsfe
  • Nintendo SNES: spc, minisnsf, snsf
  • Nintendo Switch: acb/awb, adx, bgm, bfstm, bfwav, bwav, hca, kno, ktss, lopus, wem
  • Nintendo Wii: ads, adx, brstm, lwav, mus
  • Sharp X68000: mdx
  • Sharp X1, Turbo, Turbo Z: s98
  • Sega Game Gear: vgm, vgz
  • Sega Mark III/Master System: vgm, vgz
  • Sega Mega Drive/Genesis: vgm, vgz
  • Sega Saturn: minissf, ssf
  • Sega Dreamcast: adx, dsf, spsd, str
  • Sony Playstation: psf, minipsf, pona, xa, vag
  • Sony Playstation 2: ads, adpcm, adx, genh, psf2, int, mib, minipsf2, ss2, sps, svag, vag, vpk, sng, vgs
  • Sony Playstation 3: aa3, adx, at3, cps, genh, hca, laac, idmsf, msf, msadpcm, mtaf, sgd, ss2, vag, xvag, txtp, wem
  • Sony Playstation 4: at9, sab, wem
  • Sony Playstation Vita: at9, sab
  • Sony PSP: at3, txtp
  • Panasonic 3DO: aifc, pona, str
  • Philips CD-i: grn
  • PC: apc, bik, bnk, fsb, his, hvl, imc, logg, mab, mid, mod, sab, sdb, snds, smk, txtp, v2m, wem, xwb
  • PC AdLib: adl, amd, bam, cff, cmf, d00, ddt, dtm, got, hsc, hsq, imf, ksm, laa, mdi, rad, rol, sdb, sqx, wlf, xms
  • PC HMI/XMI: hmi, hmp, xmi
  • Various machines: vgm, vgz
  • Various machines CD-DA: bin, bin/cue, img/cue, iso/cue
  • ZX Spectrum: asc, ay, psc, pt2, pt3, sqt, stc, stp

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

vgm2flac's People

Contributors

jocker666z avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vgm2flac's Issues

Broken Files?

Hey there. Yesterday I went through a bunch of music rips from vgm.hcs64.com, and while this script worked for the majority of them, there were a few that didn't seem to work. It's entirely possible that I messed up installing one of the dependencies, but I couldn't find any indication of what, so I figured I'd write an issue about it. I'm not going to die if I don't get those flacs or anything, but maybe documenting it will turn out to be helpful to someone.

For reference, I did this all on Linux Mint. I didn't bother installing uade, since the warning message implied it would only be a problem with Amiga files. I believe I had everything else installed. This was running off of a Live USB, so pretty much the freshest possible environment -- no lingering old versions of any dependencies.

Rips that refused to encode at all:
Katamari Damacy [PS2, .vgmstream]
We Love Katamari [PS2, .MIB/.ss2]
Persona 4 The Golden [PC, .txtp]

Rips that partially failed:
Earthbound [SNES, .spc; around 50% success]
MGSV [PS3, .wem; around 75% success, although one file got corrupted halfway through. Specifically d30a053a1cd3c45.wem, which is Take On Me]

In both of the partial failure cases, the console output had some files that said they encoded to wav successfully, but unfortunately I couldn't find the wav outputs for those files, only the ones that correctly converted to flac. In the case of MGSV specifically, all of the files that failed had supposedly converted to wav successfully, so not being able to find them was pretty sad.

I had other rips involving .spc files work fine (eg Street Fighter II Turbo). I got vgmstream from their repo, which has releases for vgmstream-cli that are claimed to work natively on Linux. Not sure which dependencies handle the other file formats. It might be useful to enumerate which are which in the README, since there are so many optional dependencies.

At any rate, thanks for the useful tool. Quite happy with the results for everything else I ran through it, and it was pretty easy to get going :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.