Git Repos / dotfiles / bin / mpt_single.sh
Last update to this file was on 2024-01-02 at 05:12.
Show mpt_single.sh
#!/bin/sh
#
# Copyright (c) 2019-2022, Cameron Vanderzanden. Available under the
# terms of the 2-clause BSD license. Please see the file "LICENSE" in
# the root dir of this repository for more information.
#
#- mpt_single.sh 2019/11/17 cev, last updated 2021/12/07.
## Usage: mpt_single.sh [-hV] [-g gain] [-s rate] <file>
##
## Use openmpt123 to render <file> to flac.
##
## -g Set output gain to <gain> dB (passed to openmpt123)
## -h Show help
## -s Set samplerate to <rate> (passed to openmpt123)
## -V Print version info
#
# TODO: This could be fleshed out quite a bit.
[ -x $HOME/.local/bin/cev_print.sh ] && . $HOME/.local/bin/cev_print.sh
self="${0##*'/'}"
gain="-1.0"
samplerate="44100"
die_nofile() {
print_nofile
exit 1
}
die_filenotfound() {
print_filenotfound "$*"
exit 1
}
do_file() {
openmpt123 --dither 1 --gain "$gain" \
--no-float --samplerate "$samplerate" \
--no-details --no-progress --no-meters \
--render "$*"
modtype="$(printf "%s" "$*" | awk -F. '{ print $NF }')"
bname="$(basename "$*" ".$modtype")"
flac --totally-silent -o "$bname.flac" "$*.wav"
rm "$*.wav"
}
while getopts "g:hs:V?" option; do
case $option in
g) gain="$OPTARG" ;;
h) print_help && exit ;;
s) samplerate="$OPTARG" ;;
V) print_version && exit ;;
"?") print_help && exit ;;
esac
shift $((OPTIND - 1))
done
[ $# -lt 1 ] && die_nofile
[ ! -e "$*" ] && die_filenotfound "$*"
do_file "$*"
exit 0
Return to the top of this page or return to the overview of this repo.
Log mpt_single.sh
Date | Commit Message | Author | + | - |
---|---|---|---|---|
2024-01-02 | Change from FreeBSD to Linux, other minor changes | cev | +1 | -1 |
2022-01-29 | Adding first batch of audio file handling scripts. | cev | +63 |
Return to the top of this page or return to the overview of this repo.