Outils pour utilisateurs

Outils du site


emulation:sons:vgmplay

VGMPlay

Description

VGMPlay (https://github.com/vgmrips/vgmplay) est un lecteur de musique en ligne de commande pour les fichiers son de type vgm. Il est aussi capable de convertir les fichiers sources en PCM et WAV.

Compilation

sudo apt install git make gcc zlib1g-dev libao-dev
git clone https://github.com/vgmrips/vgmplay
cd vgmplay
make
sudo make install

Script de conversion

Dessous un petit script qui transforme les fichiers vgm en flac avec tag, en normalisant le volume, et en détectant si la source n'est pas en fausse stéréo (deux canaux identique).

Vous aurez besoin de VGMPlay, vgm_tag, et FFMPEG.

Compiler vgm_tag :

git clone https://github.com/vgmrips/vgmtools
cd vgmtools
make vgm_tag
sudo cp vgm_tag /usr/local/bin/
vgm2flac.sh
#! /bin/bash
# Author : Jocker / Romain BARBAROT
# Dependencies:	-VGMPplay (https://github.com/vgmrips/vgmplay) 
#				-vgm_tag (https://github.com/vgmrips/vgmtools)
#				-FFMPEG (https://ffmpeg.org/)
 
# Set nullglob to remove null globs
shopt -s nullglob
 
# Directory argument
if [ -d "$1" ]; then
    cd "$1" || exit
fi
 
# Extention auth
VGM="*.VGM *.vgm *.VGZ *.vgz"
 
# Test files
LSTVGM=$(ls -- *.VGM *.vgm *.VGZ *.vgz 2> /dev/null)
if test -z "$LSTVGM"; then
	echo
	echo "	Failed, no vgm files here"
	echo
	exit
fi
 
# Loop for set tag, test volume, test channels, apply normalization and make WAV->FLAC
for audio in $VGM
		do
		# Tag
		TRACK=$(($COUNTER+1))													# Track tag (counter)
		COUNTER=$TRACK															# Increment track
 
		vgm_tag "$audio" > temp													# Tag record
		GAME=$(sed -n 's/Game Name:/&\n/;s/.*\n//p' temp | awk '{$1=$1}1')		# Album part 1
		MACHINE=$(sed -n 's/System:/&\n/;s/.*\n//p' temp | awk '{$1=$1}1')		# Album part 2
		ALBUM="$GAME ($MACHINE)"												# Album
		ARTIST=$(sed -n 's/Composer:/&\n/;s/.*\n//p' temp | awk '{$1=$1}1')		# Artist
		SONG=$(sed -n 's/Track Title:/&\n/;s/.*\n//p' temp | awk '{$1=$1}1')	# Track name
		DATE=$(sed -n 's/Release:/&\n/;s/.*\n//p' temp | awk '{$1=$1}1')		# Date
 
		# Make Wav
		vgm2wav "$audio" "${audio%.*}".wav
 
		# Test Volume and set normalization variable
		ffmpeg -i "${audio%.*}".wav -af "volumedetect" -vn -sn -dn -f null /dev/null 2> temp2
		TESTDB=$(grep "max_volume" temp2 | awk '{print $5;}')
		if [[ $TESTDB = *"-"* ]]; then
			GREPVOLUME=$(grep "max_volume" temp2 | sed 's|: -|=|' | awk '{print $4;}' | sed 's|max_volume=||')dB
		else
			GREPVOLUME="0dB"
		fi
 
		# Channel test mono or stereo
		TESTLEFT=$(ffmpeg -i "${audio%.*}".wav -map_channel 0.0.0 -f md5 - 2>/dev/null)
		TESTRIGHT=$(ffmpeg -i "${audio%.*}".wav -map_channel 0.0.1 -f md5 - 2>/dev/null)
		if [ "$TESTLEFT" = "$TESTRIGHT" ]; then
			CHANNEL="-channel_layout mono"
		fi
 
		# Make Wav
		ffmpeg -i "${audio%.*}".wav -af "volume=$GREPVOLUME" $CHANNEL -acodec flac -compression_level 12 -ar 44100 -metadata track="$TRACK" -metadata title="$SONG" -metadata album="$ALBUM" -metadata artist="$ARTIST" -metadata date="$DATE" "${audio%.*}".flac
 
		#ffmpeg -i "${audio%.*}".flac -af "volumedetect" -vn -sn -dn -f null /dev/null 2> "${audio%.*}".info
done
 
# Clean
shopt -u nullglob
rm -- *.wav &>/dev/null
rm temp* &>/dev/null
 
exit

Références

emulation/sons/vgmplay.txt · Dernière modification: 2019/05/17 06:33 par jocker