ABC notation/MIDI

ABC notation has a function to generate MIDI file. You need a converter for this function. If you use NetBSD, you can easily install it.

# pkgin install abcmidi

If you use a Linux distribution, you'll follow your installation process of your distribution.

The first example

The file "sample_midi01.abc" below is the first example.

X:1
T:eine kleine Nachtmusik
C:W. A. Mozart
K:G
M:C
L:1/4
% Q:Allegro
Q:1/4=120
I:violin
%%MIDI program 41
gz1/2d1/2gz1/2d1/2|g1/2d1/2g1/2b1/2d'z|c'z1/2a1/2c'z1/2a1/2|c'1/2a1/2f1/2a1/2dz|
alice-fmvwe3u27l%

You will convert this ABC notation file to a MIDI file with the command below.

% abc2midi sample_midi01.abc
% mv sample_midi011.mid sample_midi01.mid

If you want to indicate the output filename, the correspondent command is below.

% abc2midi sample_midi01.abc -o sample_midi01.mid

You can listen to the generated MIDI file with any MIDI player. One choice is timidity.

terminal 1 % timidity -iA
terminal 2 % timidity sample_midi01.mid

This sample ABC notation includes the line below.

%%MIDI program 41

The line determines the kind of instrument used to play.

MIDI to sound file

You are able to convert the generated MIDI file to a sound file with timidity.

% timidity sample_midi01.mid -Ow -o output.wav
% timidity sample_midi01.mid -Ow -o - | ffmpeg7 -i - output.mp3

The first command generates WAV file and the second command generates MP3 file. If you use not NetBSD but Linux, you need to replace ffmpeg7 to ffmpeg.