I'm searching a tool that can be used in Python or via the command line (preferably Windows but Linux would also be okay) that returns a .wav or .mp3 file for a MIDI file.
What is the best choice for this task?
Software Recommendations Stack Exchange is a question and answer site for people seeking specific software recommendations. It only takes a minute to sign up.
Sign up to join this communityI'm searching a tool that can be used in Python or via the command line (preferably Windows but Linux would also be okay) that returns a .wav or .mp3 file for a MIDI file.
What is the best choice for this task?
You can use TiMidity++:
timidity input.mid -Ow -o out.wav
You can use SoX - Sound eXchange:
sox -t raw -r 44100 -e signed -b 16 -c 1 raw_audio audio.wav
timidity + FFmpeg for MP3 output
And for MP3 conversion you can put it together with timidity + ffmpeg:
sudo apt install timidity ffmpeg
timidity MIDI_sample.mid -Ow -o - | ffmpeg -y -f wav -i - MIDI_sample.mp3
FluidSynth + FFmpeg
fluidsynth -a alsa -T raw -F - /usr/share/sounds/sf2/FluidR3_GM.sf2 MIDI_sample.mid |
ffmpeg -f s32le -i - MIDI_sample.mp3
Tested on Ubuntu 20.04, FluidSynth 2.1.1-2, timidity 2.14.0, and this MIDI file: https://en.wikipedia.org/wiki/File:MIDI_sample.mid
Related: https://stackoverflow.com/questions/16295459/convert-midi-to-mp3
You can use SoundKonverter, which relies on FluidSynth and Timidity++ MIDI engines (you can manually switch between them) for converting MIDI to any audio format (Wav, MP3, AAC, Opus, etc.)
https://github.com/dfaust/soundkonverter/wiki/Installing-soundKonverter