Abc2midi is a program that converts an abc music notation file to a MIDI file. The program was developed by James Allwright in the early 1990s and has been supported by Seymour Shlien since 2003. The program contains many features, such as expansion of guitar chords, drum accompaniment, and support for microtones, that do not exist in other packages. This guide focuses on those features that are particular to abc2midi. It assumes a general understanding of the abc notation syntax. Some knowledge of the MIDI standard is also an asset.
Abc2midi is coded in C language; the latest version of the source code is found in the abcMIDI-20*.zip package which can be downloaded from http://ifdo.ca/~seymour/runabc/top.html or http://sourceforge.net/projects/abc/. Executables for some systems can be found in The ABC Plus project.
The source code was designed to compile on many different platforms and operating systems. As a result, there is no graphical user interface built in; however, other programs such as runabc provide the graphical user interface to abcMIDI and other packages.
It is necessary to run abc2midi from a command window in order to supply run time parameters. (This applies to all programs in the abcMIDI package.) If you double click on one of the executables, the screen might blink but nothing else will happen.
Abc2midi creates either a type 0 or type 1 MIDI file. If the abc tune is simple (no voices or accompaniment), abc2midi creates a type 0 file consisting of only one track. For other tunes, abc2midi creates a type 1 file or a multitrack MIDI file. The first track conventionally contains ancillary information such as the name of the tune and other comments. The other tracks contain the different voices and accompaniment.
The MIDI standard provides 16 channels, each of which
can be controlled independently. Commonly, the channels
are mapped into separate musical instruments, allowing
16 instruments to be played at the same time. The different
instruments are referred to as programs
and there
is a special MIDI command which maps a channel to a specific
program. There are 128 possible programs available and they
are referred to by a number from 0 to 127.
Abc2midi automatically assigns a new track and channel to each
voice in the abc tune. (You can change the channel assignment,
with the %%MIDI channel
command.) If the voice contains
splits, i.e. distinct music lines in a measure, the voice will
be mapped into multiple tracks. The bass/chord accompaniment is
put into one track but the bass and chordal accompaniment
have different MIDI channels. The drum and drone accompaniments
are also put into separate tracks and channels.
Since abc2midi creates an audio representation of the abc file, there are a number of commands that are particular to this program that may be embedded in the abc file. These commands are all prefixed with %%MIDI starting from the first column of the line. There are about 40 such commands. For example,
%%MIDI program 64assigns the soprano saxophone to the melody line or the particular voice it is attached to.
To avoid the problem of breaking up a music line in order to place a %%MIDI command, for example,
A2 B2|\ %%MIDI drumon C2 D2|you can place the MIDI instruction inside an info field using the following syntax.
A2 B2|[I:MIDI= drumon] C2 D2|The '=' following the MIDI is very important. The info field syntax allows you to place several MIDI commands in one inline block, for example
[I: MIDI = program 73 MIDI=chordprog 29](Spaces are optional.)
Some other commands embedded in the abc body are enclosed by exclamation marks, e.g. !mf! and affect abc2midi. There are a few parameters included in the K: and V: field commands which are particular to abc2midi. For example,
K: C transpose=-2addresses the problem with the Bb clarinet where the music is printed in C, but actually played in Bb. Other parameters are presented directly in the run time parameters of abc2midi, but can be overriden by the contents of the abc file.
%%MIDI channel nassigns MIDI channel n (in the range 1-16) to the current voice or melody.
%%MIDI program [c] nselects program n (in the range 0-127) to channel c. If c is not given, the program is assigned to the current channel being used. Most modern tone generators follow the General MIDI standard, which defines the instrument type for each program number. These instruments are listed at the end of this section. Note that for multivoiced files, the program command is placed in the track associated with the voice previously declared. If the %%MIDI indications affect channels in other tracks, it is recommended that they be placed before the first track or first declared voice. The following example is used to illustrate the use of the
%%MIDI channelcommand. This is not the recommended practice for changing programs since it ties up 4 channels unnecessarily.
X: 10
T:Avon Jig
% Nottingham Music Database
S:Pauline Wilson, via Phil Rowe
M:6/8
Q:1/4=180
K:Em
%%MIDI program 5 10
%%MIDI program 6 20
%%MIDI program 7 30
%%MIDI program 8 40
%%MIDI channel 5
B|"Em"e2e B2B|GAB E3|"D7"FED AGF|FED AGF|
%%MIDI channel 6
"Em"e2e B2B|"Em"GAB E3|"D7"FED A2A|"Em"GEE E2::
%%MIDI channel 7
D|"G"G2G B2B|"D7"ABA D3|"G"G2G B2B|"Am"d2d "D7"cBA|"G"G2G B2B|"D7"ABA D3|\
%%MIDI channel 8
"Em"EFG "A7"FED|"Em"E3 -E2:|
Instead you should use the same channel to change the program as
shown here.
X: 10
T:Avon Jig
% Nottingham Music Database
S:Pauline Wilson, via Phil Rowe
M:6/8
Q:1/4=180
K:Em
%%MIDI program 10
B|"Em"e2e B2B|GAB E3|"D7"FED AGF|FED AGF|
%%MIDI program 20
"Em"e2e B2B|"Em"GAB E3|"D7"FED A2A|"Em"GEE E2::
%%MIDI program 30
D|"G"G2G B2B|"D7"ABA D3|"G"G2G B2B|"Am"d2d "D7"cBA|"G"G2G B2B|"D7"ABA D3|\
%%MIDI program 40
"Em"EFG "A7"FED|"Em"E3 -E2:|
Here is how it sounds like.
Note that that channel numbers must be from 1 to 16; however, program
numbers must be from 0 to 127.
) 0. Acoustic Grand Piano | 1. Bright Acoustic Piano | 2. Electric Grand Piano |
3. Honky-tonk Piano | 4. Electric Piano 1 | 5. Electric Piano 2 |
6. Harpsichord | 7. Clavi | 8. Celesta |
9. Glockenspiel | 10. Music Box | 11. Vibraphone |
12. Marimba | 13. Xylophone | 14. Tubular Bells |
15. Dulcimer | 16. Drawbar Organ | 17. Percussive Organ |
18. Rock Organ | 19. Church Organ | 20. Reed Organ |
21. Accordion | 22. Harmonica | 23. Tango Accordion |
24. Acoustic Guitar (nylon) | 25. Acoustic Guitar (steel) | 26. Electric Guitar (jazz) |
27. Electric Guitar (clean) | 28. Electric Guitar (muted) | 29. Overdriven Guitar |
30. Distortion Guitar | 31. Guitar harmonics | 32. Acoustic Bass |
33. Electric Bass (finger) | 34. Electric Bass (pick) | 35. Fretless Bass |
36. Slap Bass 1 | 37. Slap Bass 2 | 38. Synth Bass 1 |
39. Synth Bass 2 | 40. Violin | 41. Viola |
42. Cello | 43. Contrabass | 44. Tremolo Strings |
45. Pizzicato Strings | 46. Orchestral Harp | 47. Timpani |
48. String Ensemble 1 | 49. String Ensemble 2 | 50. SynthStrings 1 |
51. SynthStrings 2 | 52. Choir Aahs | 53. Voice Oohs |
54. Synth Voice | 55. Orchestra Hit | 56. Trumpet |
57. Trombone | 58. Tuba | 59. Muted Trumpet |
60. French Horn | 61. Brass Section | 62. SynthBrass 1 |
63. SynthBrass 2 | 64. Soprano Sax | 65. Alto Sax |
66. Tenor Sax | 67. Baritone Sax | 68. Oboe |
69. English Horn | 70. Bassoon | 71. Clarinet |
72. Piccolo | 73. Flute | 74. Recorder |
75. Pan Flute | 76. Blown Bottle | 77. Shakuhachi |
78. Whistle | 79. Ocarina | 80. Lead 1 (square) |
81. Lead 2 (sawtooth) | 82. Lead 3 (calliope) | 83. Lead 4 (chiff) |
84. Lead 5 (charang) | 85. Lead 6 (voice) | 86. Lead 7 (fifths) |
87. Lead 8 (bass + lead) | 88. Pad 1 (new age) | 89. Pad 2 (warm) |
90. Pad 3 (polysynth) | 91. Pad 4 (choir) | 92. Pad 5 (bowed) |
93. Pad 6 (metallic) | 94. Pad 7 (halo) | 95. Pad 8 (sweep) |
96. FX 1 (rain) | 97. FX 2 (soundtrack | 98. FX 3 (crystal) |
99. FX 4 (atmosphere) | 100. FX 5 (brightness) | 101. FX 6 (goblins) |
102. FX 7 (echoes) | 103. FX 8 (sci-fi) | 104. Sitar |
105. Banjo | 106. Shamisen | 107. Koto |
108. Kalimba | 109. Bag pipe | 110. Fiddle |
111. Shanai | 112. Tinkle Bell | 113. Agogo |
114. Steel Drums | 115. Woodblock | 116. Taiko Drum |
117. Melodic Tom | 118. Synth Drum | 119. Reverse Cymbal |
120. Guitar Fret Noise | 121. Breath Noise | 122. Seashore |
123. Bird Tweet | 124. Telephone Ring | 125. Helicopter |
126. Applause | 127. Gunshot |
X: 3
T:Dennis Murphy's
% Nottingham Music Database
S:via PR
M:4/4
L:1/4
K:D
d/2e/2|:"D"f/2g/2f/2e/2 d3/2B/2|AD FA|"Em"GE e3/2d/2|"A7"cB c/2B/2A|
"D"f/2g/2f/2e/2 d3/2B/2|"D"AD FA|"Em"GE "A7"e3/2f/2|"D"ed d2::
"D"Af f/2e/2f|"G"Bg g/2f/2g|"D"Af f/2e/2d|"A7"e/2f/2e/2d/2 BA|
"D"Af f/2e/2f|"G"Bg g3/2a/2|"A7"ba gc|"D"ed d2:|
Guitar chords must use upper case A-G followed by optional # or b, then
the name of a chord type e.g. "m", "aug", "7". abc2midi currently
recognizes the following chord names :
m, 7, m7, maj7, M7, 6, m6, aug, +, aug7, dim, dim7, 9, m9, maj9, M9,Lower case a-g followed by optional # or b will generate a single note (the fundamental) only.
The chord notation also allows chords such as "G/B" or "G/b". The note following the / is interpreted in one of two ways:
If the note following / does not exist as part of the given chord, it is added to the chord below the root note of the chord (G in the above example).
If the note following / does exist in the chord, then the notes of the chord are rearranged so that it becomes the lowest pitch note of the chord. This is known as an inversion of the chord. It does not matter whether the note following the / is upper or lower case. They are both treated the same. The following examples are equivalent.
X:1
T: chord types
M: 2/4
L: 1/4
K: C
%%MIDI gchord fc
"C/E" z2| "CM7/G" z2| "C/F" z2|"C/f" z2|
X: 2
T: chords expanded
M: 2/4
L: 1/4
K:C
"^C/E"E,, [CG,E,]| \
"^CM7/G"G,, [ECB,G,]| \
"^C/F"F,,, [G,E,C,]| \
"^C/f"F,,, [G,E,C,]|
You may find some abc tunes that abuse this notation and use quotes for things that are not guitar chords. Usually these are tunes that have been typeset but never played by a computer. If you do not want to just delete things in quotes, you can insert one of the characters _, ^, @, < or > after the first quote e.g. "_Chorus" "_Very Loud". This causes abc2midi to ignore the following text. However, typesetting programs should recognize the first character as telling them where to print the following text.
Abc2midi expands the guitar chords into a specific pattern of notes
and places them into a separate track in the midi file. For common
time signatures such as 2/4,3/4 and 4/4, there are specific patterns
already defined; for unusual time signatures, the user must define
the patterns. For example:
expands to
The guitar chord consists of two components, the bass note and the
chord. Each component is assigned a separate MIDI channel, so that
the user is able to play them on separate instruments. For example,
listen to the following arrangement of
Dennis Murphy's Reel
The abc file containing these special instructions abc2midi is
shown here.
X: 3 T:Dennis Murphy's % Nottingham Music Database S:via PR M:4/4 L:1/4 K:D %%MIDI program 64 %%MIDI chordprog 24 %%MIDI bassprog 45 %%MIDI beat 87 77 67 4 %%MIDI chordvol 88 %%MIDI bassvol 82 d/2e/2|:"D"f/2g/2f/2e/2 d3/2B/2|AD FA|"Em"GE e3/2d/2|"A7"cB c/2B/2A| "D"f/2g/2f/2e/2 d3/2B/2|"D"AD FA|"Em"GE "A7"e3/2f/2|"D"ed d2:: "D"Af f/2e/2f|"G"Bg g/2f/2g|"D"Af f/2e/2d|"A7"e/2f/2e/2d/2 BA| "D"Af f/2e/2f|"G"Bg g3/2a/2|"A7"ba gc|"D"ed d2:|
Here is an explanation of all the %%MIDI instructions.
%%MIDI program 64tells abc2midi to assign the soprano saxophone to the melody line (or the current voice). The General Midi Standard assigns 128 instrument sounds to the program numbers. Assuming that the program numbers start from zero, the soprano saxophone has the number 64.
%%MIDI chordprog 24likewise assigns the acoustic guitar (nylon), to the chords and
%%MIDI bassprog 45assigns the pizzicato strings to the bass. The loudness (called velocities in MIDI nomenclature) of the bass and chord accompaniment are specified separately using the bassvol and chordvol parameters. They range between 0 and 127, where 127 is the loudest. The beat command is used to control the loudness of the melody or other voices. This is described in a separate section.
%%MIDI gchord f2f2cz2
%%MIDI gchord fffffthe bar will be divided evenly into five fundamental notes irrespective of the time signature (T:) and unit length indication. ( L:).
%%MIDI gchord ghihAbc2midi will arpeggiate the C major guitar chord to CEGE. The upper case letters G,H,I, and J refer to the same notes, except they are transposed down one octave. Note that for the first inversion of the C major chord (indicated by "C/E"), E would be the lowest note, so g would reference the note E. To hear an example using the command
%%MIDI gchord ghigclick on Dennis Murphy's Reel arpeggiatted. The first few bars of the arpeggiated tune look like this.
%%MIDI gchordoffTurns off guitar chords.
%%MIDI gchordonTurns on guitar chords (they are turned on by default at the start of a tune after the first guitar chord). If you do not hear the guitar chord accompaniment after the first guitar chord indication, it is probably because there is no default gchord string for the particular time signature. You will need to include a gchord string.
%%MIDI chordname name n1 n2 n3 n4 n5 n6Defines how to play a guitar chord called "name". n1 is usually 0 and n2, n3 to n6 give the pitches of the other notes in semitones relative to the root note. There may be fewer than 6 notes in the chord, but not more. If "name" is already defined, this command redefines it. Unlike most other commands, chordname definitions stay in effect from where they are defined to the end of the abc file. The following illustrates how m, 7, m7 and maj7 could be set up if they were not already defined.
%%MIDI chordname m 0 3 7 %%MIDI chordname 7 0 4 7 10 %%MIDI chordname m7 0 3 7 10 %%MIDI chordname maj7 0 4 7 11
%%MIDI droneonThis starts a continuous drone used in bagpipe music. The drone consists of two notes (by default A, and A,,) played on a bassoon at a MIDI loudness (velocity) 80. You can configure the drone sound using the %%MIDI drone command described below.
%%MIDI droneoffThis turns off the drone.
%%MIDI drone n1 n2 n3 n4 n5Configures the drone chord. n1 = MIDI program, n2 = MIDI pitch 1, n2 = MIDI pitch 2, n4 = MIDI velocity 1, and n5 = MIDI velocity 2. By default they have already been set to 70 45 33 80 80.
For example:
click on Banks and Braes.
X: 1 T:Banks and Braes M:6/8 L:1/8 S:Slow March K:HP %%MIDI program 109 %%MIDI gracedivider 4 %%MIDI drone 70 45 33 61 54 %%MIDI droneon |: {Gdc}d2{g}d{g}ede|\ {g}faf{gef}e2{g}d/2e/2|\ {g}f3/2e/2d{g}dB{G}A|\ {g}A3/2B/2d{gef}e2{g}A| {Gdc}d2{g}d{g}ede|\ {g}faf{gef}e2{g}d/2e/2|\ {g}f3/2e/2d{g}dB{G}A|\ {g}A3/2B/2d{gdc}d2| {g}A:|
%%MIDI drum string [drum pitch numbers] [drum velocities]This sets up a drum pattern. The string determines when there is a drum beat and the drum pitch values determine what each drum strike sounds like. Drum velocities indicate which range from 0 to 127 indicate the loudness of each drum hit. e.g. %%MIDI drum d2zdd 35 38 38 100 50 50 The string may contain 'd' for a drum strike or 'z' for a rest. By default a voice starts with no drum pattern. The drum string is treated in a similar manner as the gchord string and is expanded to fill the whole bar (with one exception to be discussed later).
%%MIDI drumonis needed to enable the drumming. The drum pattern is repeated during each bar until a
%%MIDI drumoffis encountered. The %%MIDI drum command may be used within a tune to change the drum pattern. This command places the drum sounds on channel 10 and assumes that your tone generator complies with the General Midi standard - if it does not, then you may hear tones instead of drum sounds. (Note the old method of using the instruction !drum! and !nodrum! is being deprecated.) For example: click on Macedonska Sedenka sample.
X:1
T:Macedonska Sedenka abridged sample
O:Macedonia
C:Trad.
R:kopanica
Z:http://swiss.csail.mit.edu/~jaffer/Music
Q:1/4=220
M:11/8
L:1/8
K:C
%%MIDI gracedivider 2
%%MIDI channel 1
%%MIDI program 1 71
%%MIDI chordprog 71
%%MIDI chordvol 40
%%MIDI bassprog 58
%%MIDI gchord f2c2c3f2c2
%%MIDI drumon
%%MIDI drum d2d2d2dd2d2 43 43 41 37 43 43
|:"G"dz ^fg gfa ~g2 =fe | ef df ~e2 d ^cd dG |
^cd ef dfd ~e2 ed |1 "D"^cd Bd ~=c2 B "G"BG dG :|2 "D"^cd Bd ~=c2 B "G"B2 z2 ||
The %%MIDI drum line can sound quite monotonous if it is repeated
each bar. To circumvent this problem, a new MIDI command
%%MIDI drumbars nwhere n is a small number will spread out the drum string over n consecutive bars. By default drumbars is set to 1m maintaining compatibility with existing abc files. Ensure that the drumstring is evenly divisible between the drumbar bars. Also the time signature should not change between bars in a drumbar unit. The following example illustrates the use of drumbar command.
X:1
T: splitting a drum string into two bars
M: 2/4
L: 1/8
K: G
%%MIDI drum zdzdzdzd 39 59 50 60
%%MIDI drumon
z4| z4| z4| z4|
%%MIDI drumbars 2
%%MIDI drum zdzdzdzd 39 59 50 60
z4| z4| z4| z4|
The following table shows the MIDI pitch to percussion assignment.
35. Acoustic Bass Drum | 36. Bass Drum 1 | 37. Side Stick |
38. Acoustic Snare | 39. Hand Clap | 40. Electric Snare |
41. Low Floor Tom | 42. Closed Hi Hat | 43. High Floor Tom |
44. Pedal Hi-Hat | 45. Low Tom | 46. Open Hi-Hat |
47. Low-Mid Tom | 48. Hi Mid Tom | 49. Crash Cymbal 1 |
50. High Tom | 51. Ride Cymbal 1 | 52. Chinese Cymbal |
53. Ride Bell | 54. Tambourine | 55. Splash Cymbal |
56. Cowbell | 57. Crash Cymbal 2 | 58. Vibraslap |
59. Ride Cymbal 2 | 60. Hi Bongo | 61. Low Bongo |
62. Mute Hi Conga | 63. Open Hi Conga | 64. Low Conga |
65. High Timbale | 66. Low Timbale | 67. High Agogo |
68. Low Agogo | 69. Cabasa | 70. Maracas |
71. Short Whistle | 72. Long Whistle | 73. Short Guiro |
74. Long Guiro | 75. Claves | 76. Hi Wood Block |
77. Low Wood Block | 78. Mute Cuica | 79. Open Cuica |
80. Mute Triangle | 81. Open Triangle |
X: 1 T: drum voice M: 4/4 L: 1/8 Q:1/4=120 K:C % 0 sharps V:1 %%MIDI channel 10 %%MIDI program 0 C,,C,, D,,C,,z2 C,,2| \ C,,C,, D,,C,, C,,D,, C,,2| \ C,,C,, D,,C,,z2 C,,2| \ C,,C,, D,,C,, C,,D,, C,,2| \Note C,, maps into MIDI pitch 36 which is interpreted as
Bass Drum 1and note D,, maps into MIDI pitch 38 which is interpreted as
Acoustic Snare. When the notes are displayed using abcm2ps, the following score is seen.
MIDI drummapcommand allows the user to remap the MIDI pitches in the drum voice to more convenient ABC notes. For example:
X: 1 T: drum voice - remapped M: 4/4 L: 1/8 Q:1/4=120 K: C V:1 clef=perc %%MIDI channel 10 %%MIDI program 0 %%MIDI drummap G 36 %%MIDI drummap D 38 GG DGz2 G2| \ GG DG GD G2| \ GG DGz2 G2| \ GG DG GD G2| \
%%MIDI drummap G 36maps MIDI pitch 36 to G instead of C,,. Likewise, D is mapped to MIDI pitch 38. The score can now appear as follows.
The following table indicates the default note to percussion assignment.
B,,, Acoustic Bass Drum | C,, Bass Drum 1 | ^C,, Side Stick |
D,, Acoustic Snare | ^D,, Hand Clap | E,, Electric Snare |
F,, Low Floor Tom | ^F,, Closed Hi Hat | G,, High Floor Tom |
^G,, Pedal Hi-Hat | A,, Low Tom | ^A,, Open Hi-Hat |
B,, Low-Mid Tom | C, Hi Mid Tom | ^C, Crash Cymbal 1 |
D, High Tom | ^D, Ride Cymbal 1 | E, Chinese Cymbal |
F, Ride Bell | ^F, Tambourine | G, Splash Cymbal |
^G, Cowbell | A, Crash Cymbal 2 | ^A, Vibraslap |
B, Ride Cymbal 2 | C Hi Bongo | ^C Low Bongo |
D Mute Hi Conga | ^D Open Hi Conga | E Low Conga |
F High Timbale | ^F Low Timbale | G High Agogo |
^G Low Agogo | A Cabasa | ^A Maracas |
B Short Whistle | c Long Whistle | ^c Short Guiro |
d Long Guiro | ^d Claves | e Hi Wood Block |
f Low Wood Block | ^f Mute Cuica | g Open Cuica |
^g Mute Triangle | a Open Triangle |
%%MIDI beat a b c nFour parameters are needed to specify the loudness level of the notes in the melody line. The first note in a bar has velocity a . Other "strong" notes have velocity b and all the rest have velocity c. a, b and c must be in the rang 0-127. The parameter n determines which notes are "strong". The beat number of each note is determined on the basis of the time signature and the accumulated note length. If the beat number is a multiple of n, then the note is "strong".
The loudness of the notes indicated above the following notes would
be appropriate for a, b, c and n set to 95, 85, 75 and 2 respectively.
This would sound like this.
Without the accents it would sound like
this.
Some instruments such as the church
organ have no emphasized notes. It may be appropriate to have
all notes played at an even level by including the following
command.
%%MIDI nobeataccentsTo revert to emphasizing notes in the usual way (default), add
%%MIDI beataccents
The volume specifiers !ppp! to !fff! are equivalent to the following :
!ppp! = %%MIDI beat 30 20 10 1 !pp! = %%MIDI beat 45 35 20 1 !p! = %%MIDI beat 60 50 35 1 !mp! = %%MIDI beat 75 65 50 1 !mf! = %%MIDI beat 90 80 65 1 !f! = %%MIDI beat 105 95 80 1 !ff! = %%MIDI beat 120 110 95 1 !fff! = %%MIDI beat 127 125 110 1An alternative way of specifying where the strong and weak stresses fall within a bar uses a beatstring.
%%MIDI beatstring'f' means velocity a (normally strong), 'm' means velocity b (medium velocity) and 'p' means velocity c (soft velocity). For example, if the time signature is 7/8 with stresses on the first, fourth and sixth notes in the bar, we could use the following:
%%MIDI beatstring fppmpmpwhich would be played as follows:
%%MIDI beatmod nincrements by n (or decrements if n is negative) the velocities a, b and c described above. It is also used in implementing crescendo and diminuendo.
The !crescendo(! and !crescendo)! delineate the start and end of a crescendo. Alternatively, you can use !<(! and !>)!. Abc2midi does not implement a gradual loudness increase, but instead increases the loudness at the start and end of the crescendo by a fixed amount. (See %%MIDI beatmod and %%MIDI deltaloudness for more information.)
%%MIDI deltaloudness nwhere n is a small positive number. By default the crescendo and dimuendo instructions modify the beat variables a, b, and c by 15 velocity units. This instruction allows you to change this default. Here is an example:
X:1 T: crescendo M: 4/4 L: 1/4 K: C %%MIDI deltaloudness 30 !mp!CDEF|!crescendo(!GABc!crescendo)!|cBAG|FEDC|which sounds like this.
X:1 T: transpose M: 4/4 L: 1/4 K: C V: 1 cdef|gabc'| V: 2 transpose=2 %%MIDI program 70 CDEF|GABc| V:3 C,D,E,F|G,A,B,C|all the notes in voice 2 will be transposed up one tone. The notes in the other voices are unaffected. On the other hand, in the next example
X:1 T: transpose M: 4/4 L: 1/4 K: C V: 1 cdef|gabc'| V: 2 %%MIDI program 70 %%MIDI transpose 2 CDEF|GABc| V:3 C,D,E,F|G,A,B,C|The notes in both voices 2 and 3 are transposed up one tone. To make life more complicated, transposition can also be indicated in the K: field command -- for example K:C transpose=2. (The behaviour is similar to the %%MIDI transpose command.) It is recommended that users experiment on simple abc files to become familiar with the way transpose command works. Though this behaviour is not logical, it is too late to change it since there are already existing abc databases assuming this implementation.
Besides the MIDI transpose command, there is also the MIDI rtranspose command described as follows.
%%MIDI rtranspose nperforms relative transpose by the specified number of semitones. i.e. %%MIDI transpose a followed by %%MIDI rtranspose b results in a transposition of a+b. %%MIDI transpose b will result in a transposition of b semitones, regardless of any previous transposition.
Transposition by an entire octave is indicated in the K: or V: field command. For example
K:G clef=soprano octave=-1 transpose=-1abcm2ps recognizes the clef indication and displays the notes correctly; however, in order for abc2midi to convert the music correctly it is also necessary to add octave=-1 and transpose=-1. Recognized clefs are treble, bass, baritone, tenor, alto, mezzo and soprano. There are also variants of these clefs; treble-8, tenor-8, treble+8 covering ranges that are an octave below and an octave above the normal treble clef. Other variants are not recognized at this time. No transposition is assumed for the bass clef since many abc files enter the notes with all the commas.
I:octave=-2 B, C D E F I:octave=0
%%MIDI trim x/ywhere x and y are two numbers. This command controls the articulation of notes and chords by placing silent gaps between the notes. The length of these gaps is determined by x/y and the unit length specified by the L: command. These gaps are produced by shortening the notes by the same amount. If the note is already shorter than the specified gap, then the gap is set to half the length of the note. The fraction x/y indicates a note duration in the same manner as specified in the abc file. The actual duration is based on the unit length specified by the L: field command. It is recommended that x/y be a fraction close to zero. The denominator, y does not need to be a power of 2. Trimming is disabled inside slurs as indicated by parentheses.
X: 1 T:Dennis Murphy's -- articulated % Nottingham Music Database S:via PR M:4/4 L:1/4 K:D Q:1/4=180 %%MIDI program 71 d/2e/2| %%MIDI trim 0/4 f/2g/2f/2e/2 d3/2B/2|AD FA|GE e3/2d/2|cB c/2B/2A| %%MIDI trim 1/4 f/2g/2f/2e/2 d3/2B/2|AD FA|GE e3/2f/2|ed d2|which sounds like this.
%%MIDI chordattack nwhere n is a small number. If n is zero, then abc2midi should behave as in earlier versions. The delay n is in MIDI time units where there are 480 units in a quarter note beat. The program may not run correctly if n is too large and there are short chords.
%%MIDI randomchordattack nwhere n is a small number. This is similar to above, except the delay of each note in the chord varies randomly between 0 and n-1. Therefore each chord is played differently. Here is an example.
X:1
T: arpeggiate
M: 2/4
L: 1/4
Q: 1/4 =60
K: C
%%MIDI chordattack 0
[CEGB] [GBDF]|\
%%MIDI chordattack 20
[CEGB] [GBDF]|
which sounds like
this.
%%MIDI grace a/bsets the fraction of the next note that grace notes will take up. a must be between 1 and b-1. The grace notes may not sound natural in this approach, since the length of the individual grace notes varies with the complexity of the grace and the length of the following note. Here is a sample abc file.
X:1
T: grace fraction
M: 2/4
L: 1/8
K: C
%%MIDI grace 1/4
{E}D2 {GFE}D2| {DCDC}C4|
%%MIDI grace 1/2
{E}D2 {GFE}D2| {DCDC}C4|
%%MIDI grace 3/4
{E}D2 {GFE}D2| {DCDC}C4|
which sounds like this.
A different approach (which is now the default) assumes that the grace notes always have fixed duration specified by a fraction of the unit length. To use the other approach you would specify
%%MIDI gracedivider bwhere b specifies how many parts to divide the unit length specified by the L: field command. For example, if b = 4 and L: = 1/8, then every grace note would be 1/(8*4) or a 32nd note. Time would be stolen from the note to which the grace note is applied. If that note is not long enough to handle the grace sequence, then the grace notes would be assigned 0 duration. Here is an example.
X:1
T: grace divider
M: 2/4
L: 1/8
K: C
%%MIDI gracedivider 4
{E}D2 {GFE}D2| {DCDC}C4|
%%MIDI gracedivider 2
{E}D2 {GFE}D2| {DCDC}C4|
This sounds a little better.
Note that the MIDI command has no effect on grace notes introduced using the M, R, T, !trill!, !mordent! indications.
X:1 T: portamento M: 4/4 L: 1/4 K: C %%MIDI program 2 CDEF|GABc| %%MIDI portamento 60 CDEF|GABc| CEGB|dfac'|which sounds like this.
To apply portamento to either the bass or chord accompaniment, add one or both of the commands:
%%MIDI portamento bass n %%MIDI portamento chord nwhere n is a number between 0 and 63.
%%MIDI control [bass/chord] n1 n2This generates a MIDI control event. If the word "control" is followed by "bass" or "chord", the event will be applied to the bass or chord channel, otherwise it will be applied to the current channel. n1 and n2 are numbers in the range 0-127. Generally, n1 selects a control parameter and n2 is the value to which it is set. A couple of examples :
%%MIDI control 7 50will set the main volume of the channel to 50
%%MIDI control 10 0will set the pan parameter (left/right balance) to 0. There are nummerous MIDI Controller numbers which are listed here. Some of these controls are implemented by the %%MIDI commands, for example
%%MIDI portamento.
K: G ^/F F ^^/2F F|does the following. Even though the key of G major causes F to be sharp, the first note is F natural raised by half a semitone. This affects the next note by making it F natural instead of F#. The third note is F# raised by half a semitone. The F# propagates to the last note, making it also F#.
%%MIDI makechordchannels nwhere n is the number of additional channels needed. More details are provided below.
X: 5
T:Bobbin Mill Reel
% Nottingham Music Database
S:Mick Peat
M:4/4
L:1/4
K:D
A/2|"D"d/2c/2d/2e/2 fA|"G"Be "A"cA|"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"Em"Be "A"aA|
"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"G"Be "A"cA|"G"B/2c/2d/2B/2 "A"c/2d/2e/2c/2|\
"D"d2 dA:|
% ...
When we run abc2midi, the following output appears.
abc2midi Bobbin_Mill_Reel.abc Warning in line 11 : Assuming repeat writing MIDI file Bobbin_Mill_Reel5.mid Warning in line 8 : Bar 0 has 1/2 units instead of 4 in repeatAbc2midi assumes a left repeat at the beginning of the tune. When it processes the first bar
A/2|during the repeat, it issues a warning that it has only 1/2 beat instead of 4 beats. When you play the MIDI file Bobbin_Mill_Reel5.mid there is a stutter at the beginning of the repeat. The left repeat should have been placed after the anacrusis, as illustrated below.
X: 5
T:Bobbin Mill Reel
% Nottingham Music Database
S:Mick Peat
M:4/4
L:1/4
K:D
A/2|:"D"d/2c/2d/2e/2 fA|"G"Be "A"cA|"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"Em"Be "A"aA|
"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"G"Be "A"cA|"G"B/2c/2d/2B/2 "A"c/2d/2e/2c/2|\
"D"d2 dA:|
% ...
Now abc2midi runs correctly without warning.
Abc2midi assumes a repeat only in special situations. For example,
if the body was included in a part, as shown below
X: 7
T:Bobbin Mill Reel
% Nottingham Music Database
S:Mick Peat
M:4/4
L:1/4
P:A
K:D
P:A
A/2|"D"d/2c/2d/2e/2 fA|"G"Be "A"cA|"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"Em"Be "A"aA|
"D"d/2c/2d/2e/2 f/2e/2d/2c/2|"G"Be "A"cA|"G"B/2c/2d/2B/2 "A"c/2d/2e/2c/2|\
"D"d2 dA:|
Then abc2midi will not assume a left repeat; the following message
appears and the section is not repeated.
abc2midi Bobbin_Mill_Reel.abc
writing MIDI file Bobbin_Mill_Reel6.mid
Error in line 12 : Found unexpected :|
Error in line 12 : Found unexpected :|
Error in line 12 : Found unexpected :|
The problem in the code is difficult to fix, so it is safest
to always include a left repeat even though it is
considered redundant according to music conventions.
%%MIDI ratio n mThis sets the ratio of note lengths in broken rhythm (e.g. a>b). The default behaviour is for note a to sound for twice as long as note b. This can be achieved with
%%MIDI ratio 2 1and hornpipes are commonly played with approximately this ratio. However, for other musical styles a different ratio may be appropriate. If you are using abc2midi to export music to another program for printing, then you may wish to use a ratio of 3:1, which is how hornpipes are usually notated. This can be achieved with
%%MIDI ratio 3 1Can you hear the change in ratio for the following abc file?
X: 1
T: Balance the Straw
R: jig
Z: 1997 by John Chambers http://eddie.mit.edu/~jc/music/abc/
M: 6/8
L: 1/8
K: G
D \
| "G"G2B B>AB | "C"c2A A>ce | "D7"d>ed cAc | "G"G2B B2D \
%%MIDI ratio 3 1
| "G"G2B B>AB | "C"c2A A>ce | "D7"d>ed cEF | "G"G6 |
% rest truncated
To listen click here.
%%MIDI nobarlinesThis is a somewhat obscure option to support early music without barlines. Normally, an accidental applied to one note e.g. ^c will apply to every note at the same point in the scale until the end of the bar (so C,, C, C c c' would all be sharpened). This option turns off this behaviour, so that an accidental applies only to the next note. It should be used in the header of any tune requiring this behaviour.
%%MIDI barlinesThis turns off the effect of
%%MIDI nobarlinesin the middle of a tune. This is the default behaviour assumed at the start of every tune.
%%propagate-accidentals notas described in http://abc.sourceforge.net/standard/abc2-draft.html directive 11.3 This command suppresses propagation of accidentals across a bar. The commands
%%propagate-accidentals pitchor
%%propagate-accidentals octaverestores propagation. Presently only octave method is used. For example:
M:2/4
L:1/8
K:Eb
%%propagate-accidentals not
A =A A2|
A2 is flattened since the natural sign does not propagate.
%%MIDI temperamentlinear octave_cents fifth_centsThis command allows you to change the temperament of the scale. Octave_cents specifies the size of an octave in cents of a semitone or 1/1200 of an octave. Fifth_cents specifies in the size of a fifth (normally 700 cents). For example:
%%MIDI temperament 1200.5 698.0will produce a slightly stretched scale with narrowed fifths.
More details on linear tempered scales can be found on the site http://www.xs4all.nl/~huygensf/scala/ The pitch of each note is modified using a MIDI pitchbend command to comply with the scale. In order to handle chords, each note of the chord must be played on a different MIDI channel.
The normal musical scale has a temperament of
%%MIDI temperamentlinear 1200 700but to avoid unnecessary pitchbends you should restore to the normal temperament using the command
%%MIDI termperamentnormalHere is an example provided by Hudson Lacerda that you can experiment with.
X:1
T:Fuga (Sonata III BWV 1005)
T:Excerpt
C:J. S. Bach
M:C|
L:1/4
%
% %MIDI temperamentlinear 120 70
% %MIDI temperamentlinear 240 140
% %MIDI temperamentlinear 600 350
% %MIDI temperamentlinear 701.955 386.31
% %MIDI temperamentlinear 1800 1050
%
% Fifth sizes for some temperaments:
% %MIDI temperamentlinear 1200.0 705.882353 % 17-EDO
% %MIDI temperamentlinear 1200.0 694.736842 % 19-EDO
% %MIDI temperamentlinear 1200.0 709.090909 % 22-EDO
% %MIDI temperamentlinear 1200.0 696.774194 % 31-EDO
% %MIDI temperamentlinear 1200.0 702.439024 % 41-EDO
% %MIDI temperamentlinear 1200.0 697.674419 % 43-EDO
% %MIDI temperamentlinear 1200.0 701.886792 % 53-EDO
% %MIDI temperamentlinear 1200.0 698.0 % fifth=698 cents
% %MIDI temperamentlinear 1200.0 696.57843 % 1/4-comma meantone
% %MIDI temperamentlinear 1200.0 701.955001 % Pythagorean
%%MIDI temperamentnormal % 12-EDO
K:C
%
V:1 treble
%%MIDI program 110 % Fiddle
g2 | e f/g/ ag | f2 _ba | g a/g/ fg | a2 x2 |
V:2 merge
%%MIDI program 110 % Fiddle
B2 | c2 ^c2 & E2 E2 | d2 d2 & x2 G2 | _e2 z =e & G2 x G | fedc |
V:3 merge
%%MIDI program 110 % Fiddle
ED | C2 A,2 | D2 G,2 | C2 z C | F2 ^F2 |
%
V:1
x2 g2 | _a2 =a2 | _b2 z =b | c'_bag | ^fe/d/ g2 |
V:2
B c/d/ ed | c2 fe | de/d/cd | e2c2 & G2 x2 | c2 _BA/G/ |
V:3
G2 C2 | F2 D2 | G2 z2 | C2 _E2 | D2 z2 |
%
V:1
g a/_b/ag | f2f2 | e2e2 | ^f2x2 | x2 g2 | g2fe/d/ |
V:2
^c2 z ^c & x2 x E | d=c_BA | =B2 A2 & ^G^F/E/ E2 |\
AB/c/BA | G=FB2 | A2A2 & E2x2 |
V:3
E2 x A, | D2D2 | D2 CB,/A,/ | ^D2 zD | ExE=D | ^CB,/A,/ D2 |
%
V:1
^g2 z=g | gf/e/f2 | fe/d/ ef/e/ | de/f/ gf | e2
V:2
B2 z _B | A2 A=B/=c/ & E2x2 | d2c2 & G2G2 | x2B2 & x2 D2 | G x
V:3
DE/F/ED | ^C2D2 | B,2=C2 | FE G,2 | C2
where EDO stands for equal divisions of octave.
Here are sample MIDI files produced from the above source that you can listen to.
normal temperament | 17 divisions/octave | 19 divisions/octave |
22 divisions/octave | 31 divisions/octave | 41 divisions/octave |
120-70 | 120-140 | 600-350 |
%%MIDI makechordchannels nIf you are not modifying the temperament or inserting microtones you can ignore this command. Normally voice chords containing microtones e.g. [_/CE_/G] will not be handled correctly because all the notes in the chord are played on the same MIDI channel. If you include the above command where n here is 2, then two separate channels will be allocated for playing the other two notes in this chord. These separate channels will be used whether the pitches of the notes are bent or not. Once you allocate those channels with this command, they are no longer available and since there are only 16 MIDI channels you can easily run out. Furthermore, you need to allocate chordchannels for any other voices which may have in voice chords. The channel allocation process will automatically propogate the program assignment (musical instrument) to the other chordchannels, so be sure you set the program before using this command. If you need to change the program assignments, you can find out the channel numbers that were assigned by running abc2midi in verbose mode using the -v command.
%%MIDI pitchbend [bass/chord]This generates a pitchbend event on the current channel, or on the bass or chord channel as specified. The value given by the following two bytes indicates the pitch change.
%%MIDI snt k pitchSince many MIDI devices do not support this function, use of this command is not recommended. The command changes the tuning of a single note using the
universal system exclusive messages. k is the MIDI pitch being retuned (a number between 0 to 127) and pitch is a floating point number representing the pitch's new value in MIDI pitch units. Here is an example.
X:1
T: Single Note Tuning
M: 4/4
L: 1/4
K: C
%%MIDI program 60
C
%%MIDI snt 60 60.3
C
%%MIDI snt 60 60.6
C
%%MIDI snt 60 60.8
C
To test whether your midi synthesizer has this feature click
here. If the pitch of C drifts upwards, then
snt is working on your system.
%%MIDI fermatafixedDirects abc2midi to expand a fermata by one unit length. Thus HC3 becomes C4.
%%MIDI fermataproportionalThis is the default. A fermata doubles the length of a note so HC3 becomes C6.
%%MIDI C %%MIDI nobarlines %%MIDI barlines %%MIDI fermatafixed %%MIDI fermataproportional %%MIDI ratio %%MIDI chordname %%MIDI deltaloudnessAll other MIDI commands outside the tune are ignored and will produce the warning "cannot handle this MIDI directive here". The following is a sample test file.
%MIDI C 48
%%MIDI nobarlines
%%MIDI ratio 5 1
%%MIDI chordname ugly 1 2 3 4
X: 1
T: test global settings
M: 2/4
L: 1/8
K: C
"G"CDEF|"Gugly" D>EF>C|^ABDA|AAC2|
[seymour@localhost abc]$ abc2midi
abc2midi version 2.12 August 13 2008
Usage : abc2midi [reference number] [-c] [-v] [-o filename]
[-t] [-n ] [-RS] [-NFNP]
[reference number] selects a tune
-c selects checking only
-v selects verbose option
-ver prints version number and exits
-o selects output filename
-t selects filenames derived from tune titles
-n set limit for length of filename stem
-RS use 3:1 instead of 2:1 for broken rhythms
-quiet suppress some common warnings
-Q default tempo (quarter notes/minute)
-NFNP don't process !p! or !f!-like fields
-OCC old chord convention (e.g. +CE+)
The default action is to write a MIDI file for each abc tune
with the filename N.mid, where is the filestem
of the abc file and N is the tune reference number. If the -o
option is used, only one file is written. This is the tune
specified by the reference number or, if no reference number
is given, the first tune in the file.
[seymour@localhost abc]$
The easiest way of running abc2midi is just to follow it
with the abc file name. For example:
[seymour@localhost abc]$ abc2midi dennis.abc writing MIDI file dennis3.midYou will find a MIDI file dennis3.mid in your directory which you can play with any MIDI synthesizer (e.g. TiMidity) on your system. The number 3 included in the filename is the X: reference number in the abc file. If your abc file consisted of a collection of abc tunes, then abc2midi will create separate MIDI files for each tune (e.g. dennis1.mid, dennis2.mid, and etc.).
Rather than naming the MIDI file after the abc file name, abc2midi
can use the title of the tune to determine the file name. This is
done using the -t option. The length of the file name is limited
to 8 letters plus the .mid
extension to be compatible
with older operating systems. Any spaces, punctuation
marks and special characters are eliminated. Words are
separated by capitalization of the initial character.
If you want the option of having a longer file name, also
include the -n option. For example,
abc2midi collection.abc -t -n 12will create a collection of midi files whose file names are derived from the tunes' titles and are limited to 12 letters plus
.midextension.
To process only one particular tune in a abc file containing a collection of tunes, specify the X: reference number immediately after the filename. For example:
[seymour@localhost abc]$ abc2midi allreelsnum.abc 25 -t -n 20 writing MIDI file BeaverCreek.midwhere
Beaver Creekis the title of the tune with X: reference number 25.
To create a MIDI file for a specific file name, use the -o option. For example:
abc2midi dennis.abc -o test.midwill produce a MIDI file called test.mid instead of dennis3.mid.
Many abc files and tunes do not specify any tempo. By default, abc2midi chooses a tempo of 120 quarter notes per minute, which is frequently painfully slow. To override this default, include the -Q option followed by a number specifying the number of quarter notes per minute. For example:
abc2midi dennis.abc -Q 180will set the tempo to 180 beats per minute (assuming that the tempo is not indicated internally in the tune.) This avoids having to edit the abc file in order to change the tempo for all tunes.
Similarly, the default ratio for broken rhythms
(e.g. A < B or B > A) can be set to 3:1 using the
run time option -RS. This saves you the trouble of
editing the abc file.
The abc2-draft standard http://abc.sourceforge.net/standard/abc2-draft.html has deprecated the !...! notation in favour of the +...+ notation. In order to comply with the change, abc2midi, abc2abc and yaps were modified to accept either convention. Thus you can use +trill+, +fermata+ +pp+ etc. as well as the deprecated notation (!trill! etc.). There is one conflict: in the early days of abc, notation chords were notated as +CEG+ instead of [CEG]. There is probably very little music using this convention still available on the Internet. If you need to handle the old chord notation, you must now add the option -OCC to abc2midi. Here is a sample file using the deprecated and new convention. Hopefully, there are not too many files using the old convention.
X:1 T: decorations M: 2/4 L: 1/8 K: G +<(+ [CE]4 +<)+ |[CE] +trill+ DEF| !<(! [CE]4 !<)! |[CE] !trill! DEF|
In some cases, one may want abc2midi to ignore the dynamic
directives !ff!, !fp!, etc. in the abc
file and have the tune played at a steady loudness. To do
this, add the -NFNP
(no forte no piano) to the runtime
parameter list.
To determine which version of abc2midi you are running, use
the -ver
parameter. For example:
[seymour@localhost abc]$ abc2midi -ver 2.12 August 13 2008The verbose option
-vis useful if something is not working right.
[seymour@localhost abc]$ abc2midi dennis.abc -v Reference X: 3 scanning tune handling grace notes fixing repeats writing MIDI file dennis3.mid track 0, voice 0 assigning channel 0 to voice End of File reached
Users are always looking for more features, and new bugs are discovered as users become more adventurous. The abcmidi/doc/CHANGES file provides a history of my modifications to the abcmidi package. Certain features, such as tied notes, were particularly difficult to get working correctly. (For example, tied notes can occur in chords and triplets.)
Once a new bug is discovered, the first step is to identify and isolate it as much as possible. This involves creating a new abc file which is as simple as possible and demonstrates the bug. Examples of such files can be found in the CHANGES file referenced above. If the problem lies with the output MIDI file, then it is useful to examine the textual representation of the MIDI file using the -mftext output of midi2abc.
The MIDI file is created from the abc file in two passes. The next step is to determine which pass is faulty. An internal representation is created in the global arrays, feature[], pitch[],num[] and denom[]. To check the internal representation, run the program using a debugger, placing a break point on the function writetrack(). When the program stops at this break point, call the function dumpfeat(0,notes) which will display the contents of those global arrays. If the bug occurs in the internal representation, then the problem occurs in the first pass. The code in store.c or parseabc.c is suspect. Otherwise the code in genmidi.c should be checked out.
It is difficult to figure out some of the functions, so I usually run the debugger in step mode at the place where the faulty output is produced. It is also useful to scan the comments in the doc/CHANGES file which may shed some light on why the code was written this way. Usually after careful analysis, the source of the bug is identified. In most cases, the fix is just a small change.
It is a good idea to be very conservative in making any code changes so that it has little or no impact on the operation of the program. Radical changes usually lead to a whole proliferation of new bugs. If you are introducing a new feature, the added code should ideally be localized to a few new functions and it should be easy to revert to the older version in case unexpected bugs are introduced. This often means creating a new copy of some function, e.g. new_start_drone() which will eventually replace start_drone(). Once you are absolutely confident that the new code is reliable, you can eliminate the duplication.