Skip to content

Instantly share code, notes, and snippets.

@kroger
Last active December 18, 2023 17:03
Show Gist options
  • Save kroger/6211862 to your computer and use it in GitHub Desktop.
Save kroger/6211862 to your computer and use it in GitHub Desktop.
Convert MIDI files to MP3 using fluidsynth. See
#!/usr/bin/env bash
SOUNDFONT=/Users/kroger/Dropbox/Sfonts/BOPLMEVF16.sf2
TMPDIR=/tmp
if [[ ! -f $SOUNDFONT ]]
then
echo "Couldn't find the soundfont: $SOUNDFONT"
exit 1
fi
if [ "$#" -eq 0 ]
then
echo "usage: midi2mp3 file1.mid [file2.mid, file3.mid, ...]"
exit 0
else
for filename in "$@"
do
echo "${filename}"
WAVFILE="$TMPDIR/${filename%.*}"
fluidsynth -F "${WAVFILE}" $SOUNDFONT "${filename}" && \
lame "${WAVFILE}" && \
rm "${WAVFILE}"
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment