6

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?

3
  • 1
    What Python version are you using? – Undo Aug 22 '14 at 12:30
  • 1
    And what command line (or rather, which OS)? – Izzy Aug 22 '14 at 13:46
  • 1
    @Undo: I'm okay with all Python versions. – Christian Aug 22 '14 at 14:09
5

You can use TiMidity++:

  • free and open source
  • CLI
  • Linux and Windows (although it seems to be painful to make it work on Windows, but maybe things have improved since then)
  • can convert MIDI files into WAV files: timidity input.mid -Ow -o out.wav
3

You can use SoX - Sound eXchange:

  • free and open source
  • CLI
  • cross-platform (Windows, Linux, MacOS X, etc.)
  • can convert MIDI file to WAV: sox -t raw -r 44100 -e signed -b 16 -c 1 raw_audio audio.wav
1
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.