Last active
March 8, 2022 23:57
-
-
Save virtualtam/cfb2f674cd3710f92a182710106c7948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Backup, compress and normalize audio files from a BOSS RC-30 Loop Station | |
# | |
# Sequence: | |
# - dump audio content from the RC-30 | |
# - encode and normalize audio | |
# | |
# Dependencies: | |
# - your favourite external storage mounting tool, | |
# - file managers: Dolphin, Nautilus, PCManFM, etc. | |
# - CLI: gvfs, pmount, udiskie, etc. | |
# - rsync | |
# - ffmpeg for audio encoding and normalization | |
# | |
# Author: VirtualTam <[email protected]> | |
VOLUME=01 | |
MOUNTPOINT=/run/media/${USER}/BOSS_RC-30 | |
WAV_DIR=wav | |
WAV_SUBDIR=${WAV_DIR}/${VOLUME} | |
FORMAT=ogg | |
function dump() { | |
# Dumps the looper's tracks | |
# ${1}: RC-30 mountpoint | |
# ${2}: directory to copy WAV files to | |
if [[ ! -d ${1} ]]; then | |
echo "Dump: ${1} is not mounted" | |
return | |
fi | |
rsync \ | |
-a \ | |
-v \ | |
--perms \ | |
--chmod=D2775,F664 \ | |
--prune-empty-dirs \ | |
${1}/ROLAND/WAVE/ ${2}/ | |
} | |
function max_volume() { | |
# Computes a track's peak volume | |
# ${1}: input file | |
ffmpeg -i ${1} -af "volumedetect" -f null /dev/null 2>&1 \ | |
| grep max_volume \ | |
| cut -d ' ' -f 5 | |
} | |
function compress_normalize() { | |
# Compress and normalize the tracks | |
# ${1}: input directory | |
# ${2}: volume (archive no.) | |
# ${3}: output format, e.g. "ogg" | |
mkdir -p ${3}/${2} | |
for wav in $(find ${1} -name "*.WAV" | sort); do | |
normalized="${3}/${2}/$(basename ${wav} .WAV).${3}" | |
if [[ -f ${normalized} ]]; then | |
echo "Compress: ${normalized} is already present" | |
continue | |
fi | |
ffmpeg -i ${wav} -af "volume=$(max_volume $wav | tr -d -)dB" ${normalized} | |
done | |
} | |
dump ${MOUNTPOINT} ${WAV_SUBDIR} | |
compress_normalize ${WAV_SUBDIR} ${VOLUME} ${FORMAT} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment