Synthesize MIDI using FluidSynth
Suppose that your soundfont file is example.sf2
and your MIDI file is example.midi
:
fluidsynth -ni example.sf2 example.midi -F output.wav -r 48000 -g 1.0
-ni
runs FluidSynth in non-interactive mode.
example.sf2
is your soundfont file.
example.midi
is your MIDI file.
-F output.wav
specifies the output file.
-r 48000
sets the sample rate (you can adjust this if needed).
-g 1.0
sets the gain. The default is 0.2
, which causes the audio to be too quiet. 1.0
is a rather balanced value, but can result in clicks in extreme cases.
[Optional] Convert WAV to MP3 using ffmpeg
ffmpeg -i output.wav -codec:a libmp3lame -b:a 320k output.mp3
-b:a 320k
sets the audio bitrate to 320 kbps.
References
ChatGPT