Play abc files via midi under Debian 

Here is the simplest way to play abc files under Debian (all commands are run from command line).

First, enable your system to play midi files. The following simple steps will guarantee that you can play midi, no matter what sound card you may have. If you have sound card that has hardware support to play midi, you can also try to install the proper sound card midi driver if you want.

  1. Make sure your sound system is working, e.g., you can play mp3 or wave files.
  2. Install the 'timidity' and 'freepats' packages

    $ aptitude install timidity freepats
    The following NEW packages will be installed:
      freepats libflac8 timidity
    0 packages upgraded, 3 newly installed, 0 to remove.
    Need to get 29.5MB/29.7MB of archives. After unpacking 36.1MB will be used.
  3. Optionally install the playmidi package if you don't have a mid file to test that will surely work.

    $ aptitude install playmidi
    gunzip < /usr/share/doc/playmidi/examples/jazz.mid.gz > jazz.mid
  4. Play the midi file using timidity

    timidity jazz.mid

If everything works fine, you should be able to hear the midi song. Else check the rest of this note collection for troubleshootings.

Now, we get to the playing abc files part.

  1. Install the 'abcm2ps' and 'abcmidi' packages. The abc2mps has became the main standard for creating PostScript files from ABC files; the abcmidi package consists of several programs: abc2midi, abc2abc, and midi2abc. Check http://abc.sourceforge.net/abcMIDI/ for details.

    $ aptitude install abcm2ps abcmidi
    The following NEW packages will be installed:
      abcm2ps abcmidi
    0 packages upgraded, 2 newly installed, 0 to remove.
    Need to get 242kB of archives. After unpacking 614kB will be used.
  2. Prepare a abc file. The sample file I used here is from http://www.linuxjournal.com/article/8629. Use your favorite editor to create a file Scale.abc:

    X:1
    T:A Scale In C
    C:DLP
    M:4/4
    L:1/4
    K:C
    C D E F | G A B c |1 c/2B/2A/2G/2 | F/2E/2D/2C/2 :|2 c4 ||
  3. Convert the abc file as midi file.

    $ abc2midi Scale.abc
    writing MIDI file Scale1.mid
  4. Now play it.

    $ timidity Scale1.mid
    Playing Scale1.mid
    MIDI file: Scale1.mid
    Format: 0  Tracks: 1  Divisions: 480
    Sequence: A Scale In C
    Playing time: ~15 seconds
    Notes cut: 0
    Notes lost totally: 0

That's it. Now go crazy and download every abc file available from the Internet, starting from the sites listed in this note collection. :-)

documented on: 2008-05-29, xpt