19

I'd like to do something like

$ play filename.mid

and hear the midi file played without opening up a graphical program. Is there a package for Ubuntu that can do this?

Rafał Cieślak
  • 20,204
  • 7
  • 56
  • 86
coffee-grinder
  • 3,875
  • 8
  • 25
  • 22

6 Answers6

24

There are many different packages/commands you can try:

  1. wildmidi (as used by gstreamer)
  2. timidity (found this very CPU intensive)
  3. playmidi (never tried personally)
8128
  • 28,630
  • 27
  • 111
  • 145
9

You'll likely want the playmidi package (sudo apt-get install playmidi) which will allow you to play midi files from the command line.

playmidi filename.mid

Marco Ceppi
  • 47,783
  • 30
  • 172
  • 197
6

I know this thread is old, but I was looking for answers for a Raspberry Pi but didn't find any. After more work I came up with the following, it may work in Ubuntu too. The output is through a cheap USB to midi interface.

On Raspbian Jessie Lite with no extra installs:

pi@pizerow:~$ aconnect -l  
client 0: 'System' [type=kernel]  
0 'Timer           '  
1 'Announce        '  
client 14: 'Midi Through' [type=kernel]  
0 'Midi Through Port-0'  
client 20: 'CH345' [type=kernel]  
0 'CH345 MIDI 1    '  
pi@pizerow:~$ aplaymidi --port=20:0 myfile.mid  
karel
  • 110,292
  • 102
  • 269
  • 299
Lee Sanders
  • 61
  • 1
  • 2
  • Helped me get where I needed to be! It's basic and doesn't offer many features, but it will indeed play the MIDI file once. fwiw, `aplaymidi -l` will also list the available MIDI ports. The relevant github is here if you want to improve the project: https://github.com/alsa-project/alsa-utils/commits/master/seq/aplaymidi – Wray Bowling Mar 10 '23 at 19:06
4

fluidsynth from http://www.fluidsynth.org/.

Use it like this:
fluidsynth /some/dir/with/sundfonts/some_soundfont.sf2 some.mid

You can find soundfonts here: https://musescore.org/de/handbuch/soundfont

And quite a nice collection of MIDI files to try this out here: http://garyrog.50megs.com/midi1.html

I especially like the soundfont "Timbres of Heaven" from http://midkar.com/soundfonts/.

Christian
  • 141
  • 4
  • Does `fluidsynth` work with `sfz`? It only seems to work for me with `sf2`. – mherzl Jul 12 '18 at 01:46
  • I'm a little late but Fluidsynth is written specifically to support the Soundfont format, which is sf2 and sf3. sfz is an entirely separate format. – DaVince Nov 04 '20 at 12:11
1

If you have fluidsynth installed, you can also play Midi files with VLC by installing the vlc-plugin-fluidsynth package.

mydoghasworms
  • 1,019
  • 4
  • 11
  • 26
  • 1
    The question asked 'without opening up a graphical program'. You don't say what the VLC command would be. `cvlc ` should work. – Cedric Knight Apr 17 '21 at 17:36
0

Another alternative besides Fluidsynth nowadays is Timidity. Install the packages timidity, timidity-interfaces-extra and freepats (the latter is about 30MB, but smaller than the sf2 files in fluid-soundfont-gm). Then the following should work:

timidity -Os midi.mid
Cedric Knight
  • 151
  • 1
  • 4