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.
First, abc2midi has some serious limitations and perhaps a few known bugs. Abc2midi ignores all D.C. (Da Capo), D.S. (Da Segno), al Fine symbols. You will either need to explicitly repeat sections or use the P: command to control these repeats. There are many limitations in the handling of lyrics and the creation of Karaoke MIDI files. If the lyrics, are embedded in repeats (eg. |: and :|) they will not be repeated in the MIDI file. To create a proper MIDI file you will have to expand the repeats explicitly in the abc file (eliminating the repeat symbols). This is particularly important, if there are different lyrics in the repeats. In general the repeat symbols cause a minor annoyance since it is common to leave out the opening repeat (|:) in common music notation. Abc2midi needs to know where it returns during a repeat; it silently inserts the opening repeat when it is missing but it may put it in the wrong place if there is an anacrusis. When a music line contains overlays using (sometimes called splits), they are not handled correctly when they occur in a part (eg. P:A). I have not figured out how to do it properly. (The software to handle splits is very complicated since they are put into a separate tracks. The handling of repeats and splits is hard enough.)
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.
As an extension, abc2midi also recognizes "Maj" for Major "Min" for Minor,
"Phr" for Phrygian, "Lyd" for Lydian, "Aeo" for Aeolian and "Loc" for
Locrian. Thus CMaj, EPhr, FLyd, AAeo and BLoc will all generate a stave with
no sharps or flats. If you use one of these modes in the key signature, it is
recommended that you add a comment giving the number of sharps or flats for
the benefit of other people who may not be familiar with modes. e.g.
Another extension of the K: field is that it can include a clef specifier
an octave specifier and a transpose specifier e.g.
The octave specifier is a convenience to make entering music easier.
It allows the user to avoid repeatedly entering commas or apostrophes
when entering a sequence of low or high notes. Both yaps and abc2midi
will transpose the notes by the specified number of octaves during
the parsing stage.
e.g. the passage B,,, C,, D,, E,, F,, could be written more compactly as
I:octave=-2
B, C D E F
I:octave=0
Some instruments such as the Bb clarinet automatically transpose the
written music. For example in the case of the clarinet, the music is
written in the key of C but the instrument plays it in the key of Bb.
For multivoiced tunes, the %%MIDI transpose indication is not that useful
since it transposes all the voices by the specified amount. The
transpose=n subcommand in the K: field tells abc2midi to transpose
a particular voice by n semitones without affecting how it appears in
the printed score. For example for the tune,
Key Signature Extensions
The K: is made up of a base note A-G possibly followed by b for flat or
# for sharp. This specifies a major key. A minor key can be specified
by adding an m while Mixolydian and Dorian modes can be specified by adding
Mix and Dor respectively e.g.
K:Eb
K:EDor
K:EbDor
The following table relates the number of sharps or flats you see on the
stave to what is in the K: field :
4 sharps EMaj F#Dor G#Phr A#Lyd B#Mix C#Min
3 sharps AMaj BDor CPhr DLyd EMix F#Min
2 sharps DMaj EDor FPhr GLyd AMix BMin
1 sharp GMaj ADor BPhr CLyd DMix EMin
0 sharp CMaj DDor EPhr FLyd GMix AMin
1 flat FMaj GDor APhr BLyd CMix DMin
2 flats BbMaj CDor DPhr ELyd FMix GMin
3 flats EbMaj FDor GPhr ALyd BbMix CMin
4 flats AbMaj Bbdor CPhr DLyd EMix FMin
5 flat DbMaj Ebdor FPhr GLyd AbMix BbMin
K: DLoc % 3 flats
The key signature may be followed by modifiers. A modifier consists of ^^, ^
=, _ or __ followed by a-g or A-G. As an example, ^g means every a should be played
sharp unless otherwise marked in the music. This adds ^g to the existing
key signature. For example
K: G ^c^g
will produce a key signature similar to A major. Following the abc draft
2.0 standard, inserting the string exp in the key signature will cause
abc2midi to override the existing key signature. Thus
K: A exp _b
will remove the f,c and g sharps and put a b-flat instead. You may use
both upper and lower case letters as key modifiers since they are
distinguished by abcm2ps.
K:G clef=soprano octave=-1 transpose=-1
The clef is recognized by typesetting programs such as yaps and abc2mps
and in some situations it will cause abc2midi to transpose the notes
up or down by an octave. 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 which 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.
X:1
T:tranposing
M:1/8
L:2/4
K:C
V:1
K:C transpose=-1
CDEF|GABc|
V:2
K:C
CDEF|GABc
V:1
CDEF|GABc|
V:2
CDEF|GABc
Voice 1 will be played one semitone lower than indicated.
These transposition features are disabled for channel 10 which
is reserved for percussion instruments.
Channels and Programs
%%MIDI channel n
assigns MIDI channel n (in the range 1-16) to the current
voice or melody.
%%MIDI program [c] n
selects 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 channel
command. This is not the recommended practice for changing programs
since it ties up 4 channels unnecessarily.
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 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:|
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.
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:|
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, 11, dim9, sus, sus9, 7sus9, 5Lower 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.
Since November 2011, abc2midi now accepts octave=n where n is between -2 and 2 inclusive in the chordprog and bassprog MIDI command. This shifts the pitch of the bass and chordal accompaniment by the specified number of octaves from their usual positions. For example,
%%MIDI bassprog 45 octave=1will shift the acoustic guitar up one octave.
The manner in which the guitar chords are translated into bass and chords is controlled by the %%MIDI gchord string. The gchord strings have been set for common time signatures such as 2/4, 4/4, 3/4/, 6/8 and 9/8. For example, in the above example the gchord string was assumed to be fzcfzcz where f designates fundamental, c designates chord and z designates a rest. These letters may be followed by numbers which multiply the length of these entities by the factor. For example, an alternative gchord string could be f2cf2c. For other time signatures such as 7/8, it is necessary to indicate the gchord string using the following command.
%%MIDI gchord f2f2cz2
Please note that the default gchord string is issued any time a time signature change is specified in the body of the music. This means that if one of the bars has an extra beat and you encircled the bar with M: declarations, then the gchord string would be reset to the default string associated with that time signature. It is necessary to send another %%MIDI gchord declaration after the the time signature in order to set this back to the desired gchord string.
Also note that the standard note length of a single note f,c,z or d is not determined by the L: command. Instead it is adjusted so that the entire gchord string fits in a bar. (The same will apply to the drum string described later.) For example, if you have
%%MIDI gchord fffffthe bar will be divided evenly into five fundamental notes irrespective of the time signature (T:) and unit length indication. ( L:).
The gchord command has been extended to allow you to play the individual notes comprising the guitar chord. This allows you to play broken chords or arpeggios. The new codes g,h,i,j, G,H,I,J reference the individual notes starting from the lowest note of the chord (not necessarily the root in the case of inverses). For example, for the C major chord, g refers to C, h refers to E and i refers to G. For a gchord command such as
%%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.
If the guitar chord does not change in consecutive bars, it is not necessary to repeat the guitar chord in each bar. Once the guitar chord accompaniment has been started with the first guitar chord indication, there is only one way to turn it off.
%%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.
Since 2010 you can now have more than one gchord accompaniment track. Here is an example:
X:1
T: gchord multivoice extension
M: 4/4
L: 1/4
K: G
V: 1
%%MIDI gchord ghih
"G" z4| z4|\
%%MIDI gchordoff
z4|
V:2
%%MIDI chordprog 12
%%MIDI gchord GHIHG
z4|"D" z4|z4|
%%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 1 maintaining compatibility with existing abc files. Ensure that the drumstring is evenly divisible between the drumbar bars. The drumbars command must precede the drum command. 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|
Since 2010 you can also have separate drum accompaniment for separate voices. Here is an example:
X:1
T: drum multivoice extension
M: 4/4
L: 1/4
K: G
V:1
%%MIDI drum dddd 45 45 45 45 70 50 60 50
%%MIDI drumon
z4|z4|\
%%MIDI drumoff
z4|
V:2
%%MIDI drum ddddd 54 54 54 54 54 70 50 50 60 50
z4|\
%%MIDI drumon
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 |
Abc2midi automatically applies accents to the beats based on the time signature. The MIDI beat command indicates the amount of accent as well as the general loudness of the voice.
%%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.
The volume specifiers !ppp! to !fff! are equivalent to the
following :
Phil Taylor has introduced a more sophisticated stress algorithm in
his BarFly program
for the Mac. This model not only changes the loudness of the notes
but also alters the duration of the notes. The bar is split into a
number of equal segments where each segment is assigned a note loudness
(velocity) and an expansion factor. The partitioning of the bar into
segments and the segment coefficients depend upon the rhythm
designator (eg. jig) and the time signature.
Abc2midi provides two different models that apply this stress
program. The first model which modifies the articulation of the
notes rather than the duration of the beats and it was easiest to implement.
The second model, which closely resembles BarFly, actually distorts
the time scale in the bar or beat by expanding or contracting the
segments. Abc2midi uses built in tables (based on Phil Taylor's
models) which store the various configurations. All the
configurations preserve the duration of the musical bar.
To hear the affect of the different models, listen to the
following MIDI files produced from the double jig, 'Sailor's Wife' .
Abc2midi by default uses the Beat model
which also provides some support to the dynamic designators such
as +mf+ (for mezzoforte), +ppp+ (for pianissimo) etc.
To load the BarFly stress model instead, it is necessary to include
the runtime parameter -BF in the execution string. For example,
The abcMIDI distribution package comes with several sample
stress files in the pt/ folder. By default abc2midi will use
stress model 2 but you can select model 1 using the following
MIDI directive.
In order demonstrate how these stress models affect the note
durations, consider the following simple test file.
The stress descriptor file test.txt looks like:
If you are calling up the stress model manually using the %%MIDI ptstress
directive, it is unnecessary to include the rhythm designator R: in the
abc tune. Neverthesless, if you wish to use model 2, the -BF option
must be included in the runtime parameters of abc2midi.
The %%MIDI ptstress directive allows you to specify the stress parameters
directly without going through an intermediate file. For example,
The tempo is usually indicated with the Q: field command,
eg. Q:1/4=180 which is interpreted as 180 quarter beats per minute.
In compliance with the abc standard 2.0, you may also
indicate the tempo using directives such as "lento",
"allegro", "vivace" etc.
The following table based on
http://www.music.vt.edu/musicdictionary/appendix/tempo/tempo1.html
was used to translate the indications:
Reference: http://abc.sourceforge.net/standard/abc2-draft.html#Q:%20-%20tempo
Example:
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.)
abc2midi ignores space characters if they occur either (a) between the
end of a word/syllable and a hyphen or underscore or (b) between a hyphen or
underscore and the beginning of a word/syllable. However, some software
incorrectly treats a hyphen as a separate word if there is a space between
it and the previous syllable, so, for example, you should write go-ing and
not go - ing to ensure that your abc is portable between programs.
Here are some examples taken from
http://abc.sourceforge.net/standard/abc2-draft.html
The following example illustrates most of these :
Note that the continuation character is used in a rather strange manner.
One w: field and all continuations will match one line of music, whether
or not the line of music ends with a continuation character. You can
think of the \ in a music line dividing that line into sections and \
in a w: field further dividing these section into sub-sections.
It is possible for a music line to be followed by several w: fields.
This can be used together with the part notation to create verses.
The first w: field is used the first time that part is played, then
the second and so on. If the tune uses repeats, these must be placed
at the end of a line of music in order to make sure that the start of
a w: field matches up with the repeat.
The following is an example of lyrics appearing in separate voices.
Besides the MIDI transpose command, there is also the MIDI
rtranspose command described as follows.
Transposition by an entire octave is indicated in the K: or V:
field command. For example
The octave specifier is a convenience to make entering music easier.
It allows the user to avoid repeatedly entering commas or apostrophes
when entering a sequence of low or high notes. Both yaps and abc2midi
will transpose the notes by the specified number of octaves during
the parsing stage.
e.g. the passage B,,, C,, D,, E,, F,, could be written more compactly as
You can turn off all note trimming by setting x to 0,
e.g. 0/1. By default, note trimming is turned off at the beginning
of a tune or voice command. Here is an example:
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
Note that the MIDI command has no effect on grace notes
introduced using the M, R, T, !trill!, !mordent! indications.
In some cases, you may want abc2midi to ignore all grace notes
markings. To do this, add the
To apply portamento to either the bass or chord accompaniment,
add one or both of the commands:
In accordance with the General MIDI recommendations, the pitch range
of the pitchwheel is set to plus or minus two semitones. Therefore
abc2midi cannot go beyond this range.
Microtones are implemented using the MIDI pitchbend control command.
The command affects all notes in a specific MIDI channel. When several
notes are played at the same time (chords), it is necessary to place
the individual notes of the chord in separate MIDI channels. This
introduces another level of complexity. The additional channels
for playing chords must be pre-allocated using the following
MIDI command.
One workaround is to include the command +invisible+ which will
hide the |: when abcm2ps converts the tune to common music
notation. For example:
If the tune specifies a hornpipe rhythm, (eg. R:hornpipe) and the
meter is 4/4, then abc2midi will automatically convert sequences
of eighth notes to broken rhythm. For 2/4 time signature, the
conversion applies to sixteenth note sequences. (These conversions
do not apply when one of the stress models is selected.)
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
Here are sample MIDI files produced from the above source that you can listen to.
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 nobeataccents
To revert to emphasizing notes in the usual way (default), add
%%MIDI beataccents
!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 1
An 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 fppmpmp
which would be played as follows:
By default, the velocities associated with the strong, medium and weak beats
are 105, 95 and 85. To change them, issue the %%MIDI beat command
or insert the dynamic indicators like !mf! in the bar.
Stress Model
abc2midi myfile.abc -BF
You may follow -BF by either the numeral 1 or 2 to select the
desired stress model. In order, for the BarFly stress model to work,
the file must contain a rhythm designator, for example,
R: hornpipe
and an a appropriate time signature matching one of the built in
configurations. It does not matter whether there are upper or lower
case letters; however, if the rhythm designator is in two words, eg,
R: Double Hornpipe
there should only be one space between the two words. If abc2midi
does not recognize the rhythm descriptors, you will get a message
similar to this.
**warning** rhythm designator Lesnoto 7/8 is not one of
Hornpipe 4/4 Hornpipe C| Hornpipe 2/4 Hornpipe 9/4 Hornpipe 3/2
Hornpipe 12/8 Double hornpipe 6/2 Reel 4/4 Reel C| Reel 2/4
Slip Jig 9/8 Double Jig 6/8 Single Jig 6/8 Slide 6/8 Jig 6/8
Ragtime 12/8 Strathspey C Fling C Set Dance 4/4 Set Dance C|
Waltz 3/4 Slow March C| Slow March C March C| March C
March 6/8 March 2/4 Polka k1 3/4 Polka 4/4 saucy 3/4
Slip jig 3/4 Tango 2/4
and the usual beat model will be used. Nevertheless, you can
still call up your own stress model using a MIDI directive shown
below
%%MIDI ptstress myfolder/test.txt
where ptstress points to a file test.txt in the folder called
myfolder.
%%MIDI stressmodel 1
X: 1
T:test
M:4/4
L:1/4
R: myrhythm
K:G
%%MIDI ptstress abcmidi/pt/test.txt
|cBAG|c/B/A/B/AG|
In music notation, this file would appear as follows.
4
120 1.4
60 0.6
120 1.4
60 0.6
The first line indicates the number of segments in the bar. Each
following line specifies the velocity and the expansion factor.
Velocity is a MIDI term which is related to the loudness of the
note. (The more expensive MIDI keyboards had velocity detectors
below each key that would return how hard the key was hit.)
The expansion factor specifies how much the duration of the
note inside a particular segment is expanded (or contracted).
The total of all the expansion factors (here 4.0) must equal
the number of segments. Otherwise the duration
of the bar will not be preserved. The next illustration, shows
the piano roll representation of the MIDI file before applying
any stress model. The vertical lines separate the music into
quarter note intervals which also correspond to segments in this
case.
Stress model 1 cannot expand any notes, so all the expansion factors
are normalized so that the maximum is 1.0. The notes in a segment
are shortened by increasing the inter-note spacing, essentially
controlling the articulation of the notes. This is illustrated
below. If a note overlaps two segments, the normalized expansion factor
is averaged over the two segments weighted by the portion of
the note in each segment.
Stress model 2, expands or contracts the notes by the specified
expansion coefficients. In effect, this corresponds to expanding
or contracting the segments.
The algorithm maps the start and end time of the notes, into the
distorted space.
%%MIDI ptstress 3 100 1.4 80 1.0 60 0.6
indicates there are 3 segments, the first segment has loudness 100 and
expansion factor 1.4, the second segment has loudness 80 and expansion factor
1.0 and etc. The program first tries to parse the directive as numbers;
if it is not successful it assumes the string is a file name.
Tempo
Larghissimo 1/4=40 Moderato 1/4=104
Adagissimo 1/4=44 Allegretto 1/4=112
Lentissimo 1/4=48 Allegro 1/4=120
Largo 1/4=56 Vivace 1/4=168
Adagio 1/4=59 Vivo 1/4=180
Lento 1/4=62 Presto 1/4=192
Larghetto 1/4=66 Allegrissimo 1/4=208
Adagietto 1/4=76 Vivacissimo 1/4=220
Andante 1/4=88 Prestissimo 1/4=240
Andantino 1/4=96
Note: case is ignored (eg. ALLEGRO Allegro or allegro are treated
the same). The directive must be enclosed in double quotes.
X:1
T:tempo
M:2/4
L:1/4
K:G
Q: "Adagio"
CD|EF|
Q: "Adagio" 1/4=40
GA|Bc|
(In the second tempo command, the 1/4=40 overrides the default
1/4=59.)
Dynamics
%%MIDI beatmod n
increments 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.
%%MIDI deltaloudness n
where 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.
As usual, the note velocities were placed above the notes
manually. From my own experience, the dynamic levels are
quite dependent on the soundfont used in the MIDI player,
so that something sounding reasonable on one system may
sound somewhat artificial on another system.
The W: field (upper case W) can be used for lyrics to be typeset separately
if the abc is printed out. The w: field (lower case w) in the body of a tune
supplies a line of lyrics to be matched syllable by syllable to the last line
of notes. These are usually printed below the notes if the abc is typeset.
abc2midi uses these to generate karaoke MIDI files. Since 2010 a karaoke MIDI
file can contain more than one set of lyrics in separate voices.
Lyrics by default are embedded in the same MIDI track as the notes. If the runtime parameter
-STFW (separate tracks for words) is included when starting abc2midi, then
the lyrics will be placed in separate adjoining MIDI tracks. When the karaoke
MIDI file is played using an appropriate player program, the lyrics appear
on the screen with the current syllable highlighted. Within the lyrics,
the following symbols may be used :
A rest is not matched by any lyrics.
A tied note e.g. d2-d2 is treated as 2 notes (or however many parts it
is written as), despite the fact that it only plays as a single note.
w: syll-a-ble is aligned with three notes
w: syll-a--ble is aligned with four notes
w: syll-a -ble (equivalent to the previous line)
w: time__ is aligned with three notes
w: of~the~day is treated as one syllable (i.e. aligned with one note)
but appears as three separate words
gf|e2dc B2A2|B2G2 E2D2|.G2.G2 GABc|d4 B2
w: Sa-ys my au-l' wan to your aul' wan\
w: Will~ye come to the Wa-x-ies dar-gle?
X:1
T:Multivoiced lyrics
M:2/4
L:1/16
K:C
V:1
C4 C4 | E4 G4 | c8 |]
w: 1 2 3 4 5
V:2
C4 E4 | C4 B,4 | C8 |]
w: 11 12 13 14 15
Transposition
Transposition allows you to typeset the music in one key
and play it in another key. This is common with many musical
instruments. For example, sheet music for the Bb clarinet
written in the key C will be played one tone lower. Abc2midi
provides various ways of applying transposition to a single
voice or all the voices in the tune and these methods have
their peculiar idiosyncracies. To illustrate, see the following
example.
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.
%%MIDI rtranspose n
performs 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.
K:G clef=soprano octave=-1 transpose=-1
abcm2ps 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
Articulation
Articulation:
%%MIDI trim x/y
where 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.
Arpeggiation
With version 1.54 Dec 4 2004 of abc2midi, notes in chords
(e.g. [FAc]) are not played in the same instant but offset
and shortened by 10 MIDI time units. Thus the first note
in the chord (e.g. F) is played for the full indicated time,
the second note (e.g. A) starts 10 MIDI units later and is shortened
by the same amount and the third note starts another 10 MIDI
units later and is shortened by another 10 units. This introduces
an "expressivo" option and avoids the heavy attack. (This
does not apply to gchords or multivoiced chords.) The amount
of the delay and shortening may be configured by the MIDI command
%%MIDI chordattack n
where 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 n
where 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.
which sounds like
this.
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]|
Grace Notes
%%MIDI grace a/b
sets 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.
which sounds like this.
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|
%%MIDI gracedivider b
where 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.
This sounds a little better.
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|
-NGRA
(no grace notes) to the runtime
parameter list.
Portamento
Portamento is a pitch to pitch glide that can be produced
by MIDI synthesizers. The quality of the output depends
on the synthesizer, the selected musical instrument,
and the interval between notes. Here is an example:
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.
%%MIDI portamento bass n
%%MIDI portamento chord n
where n is a number between 0 and 63.
Pedal
The instructions +ped+ and +ped-end+ simulate the sustain pedal
on the piano.
In the following example,
the notes, G,A,B,C are sustained. Though the bassoon does not
have a sustain pedal, the scale is played on that instrument to
make the effect more obvious.
X:1
T:Ped in pianomusic
M:C
L:1/8
K:C treble
K: clef=bass
Q:1/4=60
%%MIDI program 70
+ped+G,A,B,C+ped-end+DE|
MIDI Control
%%MIDI control [bass/chord] n1 n2
This 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 50
will set the main volume of the channel to 50
%%MIDI control 10 0
will 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
.
Microtones
Microtones are indicated by following a ^ or _ with a fraction.
^/C is played as one quarter tone (i.e. half a semitone) above C.
_/C is played as one quarter tone (i.e. half a semitone) below C.
^^/4F is played as 1/4 of a semitone above F#. (The microtone always
follows any accidentals.) In general, a microtone offset is indicated
by a fraction using the same convention as note length (described
below). Abcmidi uses the same microtone syntax as abcm2ps.
(See features.txt in the abcm2ps distribution.)
Note that unlike accidentals, microtones do not propagate across a measure.
Microtones are implemented using the MIDI pitchwheel command. Since the
pitchwheel affects all notes played on a specific channel, a microtone
applied to any note in a chord specified by rectangular brackets
(e.g. [ACE]) will apply to all the notes in the chord. Microtone
accidentals override any sharpening or flattening induced by
key signatures. To illustrate
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 n
where n is the number of additional channels needed. More
details are provided below.
Tuning
Some of the older musical instruments such as the German accordian
are tuned to A = 445 Hz rather than 440 Hz. Abc2midi can create
a MIDI file tuned to any A withen a range of plus or minus a semitone.
To use this option, include the -TT run time option. For example,
abc2midi mytune.abc -TT 445.0
Repeats
The treatment of repeats has been a source of a lot of grief
to some users. The problem is that common music notation
permits omitting the left repeat symbol (|:) at the beginning
of the score; however, abc2midi is not consistent in assuming
this missing left repeat. Frequently abc2midi gives a warning
or does not repeat the desired section at all. Here is part
of a reel that has been edited for purposes of demonstration.
When we run abc2midi, the following output appears.
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:|
% ...
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 repeat
Abc2midi 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.
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: 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:|
% ...
Then abc2midi will not assume a left repeat; the following message
appears and the section is not repeated.
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:|
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.
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 :|
X:3
T:Ein Tuger Welscher Tanz
C:Hans Neusiedler
M:C|
L:1/8
K:C
%%staves [(1 2)]
V: 1 clef=treble-8 stem = up
V: 2 clef=treble-8 stem = down
[V:1] +invisible+ |: z2 c2 B4|c4 d4 |d2 c2 =B2 c2-| ccAB c4 :|
[V:2] +invisible+ |: x2 [CE]2 [G,D]4 | x4 [V:2 stem=up] FEFG [V:2 stem=down] &[CE]4 _B,4 |[_B,F]2 [CE]2 [G,D]2 [A,E]2| [G,D]4 [CG]4 :|
Abc2midi will produce a warning that it does not know what +invisible+
means but that is not a problem.
Miscellaneous
ratio
%%MIDI ratio n m
This 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 1
and 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 1
Can you hear the change in ratio for the following abc file?
To listen click here.
X: 1
T: Balance the Straw
R: jig
Z: 1997 by John Chambers
barlines
%%MIDI nobarlines
This 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 barlines
This turns off the effect of %%MIDI nobarlines
in the middle
of a tune. This is the default behaviour assumed at the start of every tune.
accidentals
%%propagate-accidentals not
as 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 pitch
or
%%propagate-accidentals octave
restores propagation. Presently only octave method is used.
For example:
A2 is flattened since the natural sign does not propagate.
M:2/4
L:1/8
K:Eb
%%propagate-accidentals not
A =A A2|
temperament
%%MIDI temperamentlinear octave_cents fifth_cents
This 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.0
will produce a slightly stretched scale with narrowed fifths.
%%MIDI temperamentlinear 1200 700
but to avoid unnecessary pitchbends you should restore
to the normal temperament using the command
%%MIDI termperamentnormal
Here is an example provided by Hudson Lacerda that
you can experiment with.
where EDO stands for
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
equal divisions of octave
.
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.
In some cases, you may want abc2midi to ignore all fermata
markings. To do this, add the
It is possible to set MIDI directives that will apply to
all the following tunes in an abc file. The directives
should appear prior to the first tune in the abc file.
MIDI commands that will be recognized outside the tune are
listed here.
-NFER
(no fermatas) to the runtime
parameter list.
MIDI Commands Applying Globally
%%MIDI C
%%MIDI nobarlines
%%MIDI barlines
%%MIDI fermatafixed
%%MIDI fermataproportional
%%MIDI ratio
%%MIDI chordname
%%MIDI deltaloudness
All 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.26 January 05 2009
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
-NFER ignore all fermata markings
-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.26 January 05 2010The 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.