标题: abcmidi user guide [打印本页] 作者: rofy530 时间: 2015-2-8 11:05 标题: abcmidi user guide
What's new
December 12 2012. New feature bent notes. April 10 2012. New feature customized stress models.
Guide to Advanced Features of Abc2midi
Introduction
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 DC (Da Capo), DS (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 [url]http://ifdo.ca/~seymour/runabc/top.html[/url] or [url]http://sourceforge.net/projects/abc/[/url] . 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, ie 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 64
assigns 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, eg !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=-2
addresses 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.
Key Signature Extensions
The K: is made up of a base note AG 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 eg
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
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. eg
K: DLoc % 3 flats
The key signature may be followed by modifiers. A modifier consists of ^^, ^ =, _ or __ followed by ag or AG. 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.
The modifiers in the key signature now allow you to put microtones. For example: K:C _1/2B will flatten the key of B by half of a semitone. Note that in the current implementation, microtones do not propagate and accidentals will not affect following B notes in the measure. Certain combinations may not work as expected. For example K:F _1/2B may be treated the same way as K: C _1/2B. See the microtone section for more details.
Another extension of the K: field is that it can include a clef specifier an octave specifier and a transpose specifier eg
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.
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.
eg the passage B,,, C,, D,, E,, F,, could be written more compactly as
I:octave=-2
B, CDEF
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,
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.
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.
General MIDI Programs
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
Guitar Chords
Guitar chord accompaniment adds more life to any tune. For example compare Dennis Murphys Reel with no accompaniment with Dennis Murphys Reel with accompaniment . Guitar chords are indicated using double quotes; for example, "D" in the body of the sample.
X:3 T:丹尼斯·墨菲%諾丁漢音樂數據庫S:通過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”版D2 ::“D”AF F / 2E / 2F |“G”博伽克/ 2F / 2G |“D”AF F / 2E / 2D | “A7”E / 2F / 2E / 2D / 2 BA |“D”AF F / 2E / 2F |“G”博伽梵歌G3 / 2A / 2 |“A7”巴GC |“D”版D2:|
X:3 T:丹尼斯·墨菲%諾丁漢音樂數據庫S:通過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”版D2 ::“D”AF F / 2E / 2F |“G”博伽克/ 2F / 2G |“D”AF F / 2E / 2D |“A7” E / 2F / 2E / 2D / 2 BA |“D”AF F / 2E / 2F |“G”博伽梵歌G3 / 2A / 2 |“A7”巴GC |“D”版D2:|
Guitar chords must use upper case AG followed by optional # or b, then the name of a chord type eg "m", "aug", "7". abc2midi currently recognizes the following chord names :
Lower case ag 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.
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 eg "_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:
gchord1
expands to
gchord2
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.
Here is an explanation of all the %%MIDI instructions.
%%MIDI program 64
tells 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 24
likewise assigns the acoustic guitar (nylon), to the chords and
%%MIDI bassprog 45
assigns 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=1
will 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.
%%MIDI gchord [string]
Sets up how guitar chords are generated. The string is a sequence of letters, each followed by an optional length:
z
rest
c
chord
f
fundamental (root note of chord)
b
fundamental plus chord
G/H/I/J
individual notes starting from the lowest note of the chord
g/h/i/j
an octave above these
For example for the C major chord "C", g refers to C, h refers to E and i refers to G. But for "C/E" (the first inversion of the C major chord), g refers to E, h refers to G and i refers to C.
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 fzczfzcz 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 for example,
%%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 fffff
the 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 ghih
Abc2midi 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 ghig
click on Dennis Murphy's Reel arpeggiatted . The first few bars of the arpeggiated tune look like this.
gchord3
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 gchordoff
Turns off guitar chords.
%%MIDI gchordon
Turns 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:
Defines 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
Drone accompaniment
%%MIDI droneon
This 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 droneoff
This turns off the drone.
%%MIDI drone n1 n2 n3 n4 n5
Configures 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:|
Explanation: the drone command selects the Bassoon, key of A, and A,, for the drone and the loudness levels 61 and 54 respectively. The melody is played on the bagpipes; the gracedivider command will be explained later.
Drum Accompaniment
The General MIDI Standard provides 47 percussion instruments. The percussion instruments are accessed from MIDI channel 10 (assuming you are counting from 1). Each percussion instrument is associated with a specific MIDI pitch starting from 35 and ending at 81 inclusive. (The table is given below.) The drum accompaniment provides a method of repeating a certain pattern every bar. The pattern is specified as follows.
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. eg %%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 drumon
is needed to enable the drumming. The drum pattern is repeated during each bar until a
%%MIDI drumoff
is 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 .
The %%MIDI drum line can sound quite monotonous if it is repeated each bar. To circumvent this problem, a new MIDI command
%%MIDI drumbars n
where 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.
The following table shows the MIDI pitch to percussion assignment.
MIDI pitch assignment to drum channel
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
Percussion Voice
When the drum pattern changes from bar to bar or contains more than one drum hit played at a time (chord), it is preferable to put the percussion in a separate voice. Setting the MIDI channel to 10 indicates that the notes address individual percussion instruments rather than specifying pitches. Here is an example showing how this is done.
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 1” and 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.
drumsamp
It is awkward to have all the strings of commas; also, the Bass clef should be replaced with a percussion clef. The “MIDI drummap” command 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 36” maps MIDI pitch 36 to G instead of C,,. Likewise, D is mapped to MIDI pitch 38. The score can now appear as follows.
drumsampmap
The following table indicates the default note to percussion assignment.
Abc note assignment to MIDI drum channel
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
Beats
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 abcn
Four 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.
beat1
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
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 1
An alternative way of specifying where the strong and weak stresses fall within a bar uses a beatstring.
%%MIDI beatstring <string of f, m and p>
'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:
beatstring
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
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' .
‧ plain
‧ stress model 1
‧ 應力模型2
Abc2midi默認使用節拍模型也提供了一些支撐,以動態指示符諸如+ MF +(對於mezzoforte)+ PPP +(對於弱音)等要加載酒鬼應力模型相反,它是必要的,包括在運行時參數- BF在執行字符串。 For example,
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
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.
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.
%%MIDI stressmodel 1
In order demonstrate how these stress models affect the note durations, consider the following simple test file.
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. 壓力樣本
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,
%%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.
There are 32 default stress models built in the code of abc2midi so that it is unnecessary to distribute an external file with the abc2midi executable. You can customize these default models by causing abc2midi to read a specific file using the -CSM <filename.txt> option (see runtime options below). The given file must comply with the following format exactly as illustrated below.
There are two models in the above example. The first model, March 6/8 already exists in abc2midi. The characteristic of this model is modified with the information in this file. The second model, Lesnoto 7/8 is new. abc2midi appends this model to the given set. Up to 16 new models may be introduced.
Sample files for customizing the stress models are provided with the abcMIDI sources in the pt/ subdirectory. The file customstress.txt is similar to the above. The file default_stress.txt is a copy of the built in models. If you modify this file and load it into abc2midi using the -CSM option, you can adapt the characteristics of the stress models to a particular tempo or instrument.
Tempo
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 [url]http://www.music.vt.edu/musicdictionary/appendix/tempo/tempo1.html[/url] was used to translate the indications:
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.
(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.
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 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:
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 :
<space> break between words
- break between syllables within a word
| advance to next bar
_ indicates last syllable is to be held for another note
* indicates a one note rest for the singer.
~ appears as a space but connects syllables each side into one.
\- appears as - in the output
\ continuation character. Next w: field is part of the same line.
A rest is not matched by any lyrics. A tied note eg 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.
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 [url]http://abc.sourceforge.net/standard/abc2-draft.html[/url]
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 (ie aligned with one note)
but appears as three separate words
The following example illustrates most of these :
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?
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 aw: 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 aw: field matches up with the repeat.
The following is an example of lyrics appearing in separate voices.
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: CV: 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: CV: 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 n
performs relative transpose by the specified number of semitones. ie %%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=-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.
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. eg the passage B,,, C,, D,, E,, F,, could be written more compactly as
I:octave=-2
B, CDEF
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.
You can turn off all note trimming by setting x to 0, eg 0/1. By default, note trimming is turned off at the beginning of a tune or voice command. Here is an example:
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|
這聽起來像這樣。
Arpeggiation
With version 1.54 Dec 4 2004 of abc2midi, notes in chords (eg [FAc]) are not played in the same instant but offset and shortened by 10 MIDI time units. Thus the first note in the chord (eg F) is played for the full indicated time, the second note (eg 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.
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.
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|
這聽起來像這樣。
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 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.
A bent note is a musical note which is varied in pitch. Typically a note may be bent on a continuous pitch instrument such as a trombone or string instrument. It is also heard on a penny whistle.
The !bend! instruction modulates the pitch of the following note by applying a sequence of MIDI pitchwheel commands while the note is still playing. Abc2midi splits the note into 8 segments and the pitch is incremented in small units (fraction of a semitone) for each segment. The MIDI pitchwheel affects all notes that are playing in the same channel, so it does not work well with chords unless the individual notes in the accord are assigned individual channels (ie in separate voices). For most General Midi devices, the pitchwheel provides a range of about plus or minus 2 semitones. The pitchwheel value of 8192 corresponds to a zero pitch change while 0 and 16383 are the minimum (negative pitch shift) and maximum values.
You can adjust the characteristics of the bend using the MIDI command bendvelocity
%%MIDI bendvelocity n1 n2
where n1 and n2 are two integers specifying the incremental change in pitch and the rate of change of the incremental pitch (in other words the bend velocity and bend acceleration). The units of n1 and n2 correspond to the units of the MIDI pitchwheel. By default, if you do not specify them, they assume the values of 100 and 300. Thus for each consecutive segment, the bend increment (bend velocity) increases by 300 so its values are 100, 400, 700, 1000 and etc. Therefore the pitchwheel values are 8192+100, 8192+400, 8192+700, and etc. for each consecutive segment.
Here is a sample abc file.
X:1
T: bending
M: 2/4
L: 1/8
K: G
%%MIDI program 26 Electric Guitar
%%MIDI bendvelocity 100 300
D4 |!bend!D4|\
%%MIDI bendvelocity 100 -300
!bend!D4|\
%%MIDI bendvelocity -1000 500
!bend!D4|
相應的MIDI文件聽起來像這樣。
The !bend! command now works with microtoned notes.
There is also a more general command
%%MIDI bendstring n1 n2 n3 ...
for specifying the pitch trajectory for bent notes. The integers n1, n2, etc. specify the pitchwheel increments for each of the n time periods where n is the number of integers provided and does not exceed 16. For example
%%MIDI bendstring 100 100 -100 -100
will divide the note length into four segments. The pitchwheel values will be 8192+100, 8192+200, 8192+100, and 8192 for the four segments (assuming that the note was not effected by a microtone).
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'|
這聽起來像這樣。
To apply portamento to either the bass or chord accompaniment, add one or both of the commands:
%%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.
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 :
Microtones are indicated by following a ^ or _ with a fraction. ^/C is played as one quarter tone (ie half a semitone) above C. _/C is played as one quarter tone (ie half a semitone) below C. ^^/4F is played as 1/4 of a semitone above F#; however I do not recommend using this form since it may not be supported or available in a future version of abc2midi. The microtone fraction may be a value between -2 and +2. So ^3/2F would alter F to F# plus a half a semitone. Another way to get to a half a semitone above F# is to go down a half semitone from Gb. One should consider a microtone specification to be just another type of accidental. As of January 20 2014, microtones now propagate across a bar just like accidentals. Thus for the example:
_1/4B cd B|
The second B is also played as _1/4B.
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 abcm2ps only handles a limited set of microtones. If you include a 1/4 microtone in your tune, abcm2ps will produce a PostScript file which ghostscript cannot display and your will get a blank page. The Out.ps contains a call to a function which is undefined. If you wish to display a 1/4 microtone, you will need to define the function to draw the glyph. Abcm2ps provides several ways of passing the definition.
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 (eg [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
^/FF =FF|
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 also played as ^/F. The third and fourth notes are played as a F natural.
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.
%%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.
X:5 T:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 K:DA / 2 |“D”D / 2C / 2D / 2E / 2次足總杯|“G”要“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“A”CA |“G”B / 2C / 2D / 2B / 2“A”C / 2D / 2E / 2C / 2 | \“D”D2 DA:| %...
X:5 T:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 K:DA / 2 |“D”D / 2C / 2D / 2E / 2次足總杯| “G”是“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“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 repeat
X:5 T:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 K:DA / 2 |:“D”D / 2C / 2D / 2E / 2次足總杯|“G”是“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“A”CA |“G”B / 2C / 2D / 2B / 2“A”C / 2D / 2E / 2C / 2 | \“D”D2 DA: |%...
X:5 T:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 K:DA / 2 |:“D”D / 2C / 2D / 2E / 2為fA |“G”是“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“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:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 P:AK:DP:AA / 2 |“D”D / 2C / 2D / 2E / 2次足總杯| “G”是“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“A”CA |“G”B / 2C / 2D / 2B / 2“A”C / 2D / 2E / 2C / 2 | \“D” D2 DA:|
X:7 T:梭磨卷%諾丁漢音樂數據庫S:米克泥煤M:4/4 L:1/4 P:AK:DP:AA / 2 |“D”D / 2C / 2D / 2E / 2次足總杯|“G”是“A”CA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“EM”是“A”AA |“D”D / 2C / 2D / 2E / 2 F / 2E / 2D / 2C / 2 |“G”是“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.
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.
One workaround is to include the command +invisible+ which will hide the |: when abcm2ps converts the tune to common music notation. For example:
Abc2midi will produce a warning that it does not know what +invisible+ means but that is not a problem.
You can also suppress the [1 in the score by putting %%repbra 0 after the definitions of V:2 and V:3.
Miscellaneous
ratio
%%MIDI ratio nm
This sets the ratio of note lengths in broken rhythm (eg 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?
X:1 T:平衡的秸稈R:夾具Z:由約翰·錢伯斯1997 <[email]jc@eddie.mit.edu[/email]> [url]http://eddie.mit.edu/~jc/music/abc/[/url] M:6/8 L: 1/8 K:GD \ |“G”G2B B> AB |“C”C2A A> CE |“D7”D>版CAC |“G”G2B B2D \ %% MIDI比3 1 |“G”G2B B > AB |“C”C2A A> CE |“D7”D>版CEF |“G”G6 |%其餘截斷
X:1 T:平衡的秸稈R:夾具Z:1997年由約翰·錢伯斯<[email]jc@eddie.mit[/email]埃杜> [url]http://eddie.mit.edu/~jc/music/abc/[/url] M:6/8 L:1/8 K:GD \ |“G”G2B B> AB |“C”C2A A> CE |“D7”D>版CAC |“G”G2B B2D \ %% MIDI比3 1 |“G”G2B B> AB |“C”C2A A> CE |“D7”D>版CEF |“G”G6 |%其餘截斷
要收聽點擊這裡。
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.)
barlines
%%MIDI nobarlines
This is a somewhat obscure option to support early music without barlines. Normally, an accidental applied to one note eg ^c will apply to every note at the same point in the scale until the end of the bar (so C,, C, C cc' 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.
as described in [url]http://abc.sourceforge.net/standard/abc2-draft.html[/url] 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:
M:2/4 L:1/8 K:%%的Eb傳播-記號不是A = A A2 |
M:2/4 L:1/8 K:%%的Eb傳播-記號不是A = A A2 |
A2 is flattened since the natural sign does not propagate.
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.
More details on linear tempered scales can be found on the site [url]http://www.xs4all.nl/~huygensf/scala/[/url] 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 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.
X:1 T:風雅(III奏鳴曲BWV 1005)T:摘錄C:JS巴赫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%%第五尺寸對於一些氣質:%% 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%,第五= 698仙%% MIDI temperamentlinear 1200.0 696.57843%四分之一逗號中間音調%% MIDI temperamentlinear 1200.0 701.955001%畢達哥拉斯%% MIDI temperamentnormal%12 EDO K:C%V:1高音%% MIDI程序110%小提琴G2 | EF / G / AG | F2 _ba | GA / G / FG | A2 X2 | V:2的合併%% MIDI程序110%小提琴B2 | C2 ^ C2與E2 E2 | D2 D2和X2 G2 | _e2 Z = E&G2 X G | FEDC | V :3合併%% MIDI程序110%小提琴ED | C2 A,2 | D2 G,2 | C2 z對於C | F2 ^ F2 |%V:1×2 G2 | _a2 = A2 | _b2 Z = B | c'_bag | ^ FE / D / G2 | V:2 B C / D / ED | C2 FE |德/日/ CD | e2c2&G2 X2 | C2 _BA / G / | V:3 G2 C2 | F2 D2 | G2 Z2 | C2 _E2 | D2 Z2 |%V:1 GA / _b / AG | f2f2 | E2E2 | ^ f2x2 | X2 G2 | g2fe / D / | V:2 ^ C2?^ 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?_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
X:1 T:風雅(III奏鳴曲BWV 1005)T:摘錄C:JS巴赫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%%第五尺寸對於一些氣質:%% 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%,第五= 698美分%% MIDI temperamentlinear 1200.0 696.57843%四分之一逗號中間音調%% MIDI temperamentlinear 1200.0 701.955001%畢達哥拉斯%% MIDI temperamentnormal%12 EDO K:C%V:1高音%% MIDI程序110%小提琴G2 | EF / G / AG | F2 _ba | GA /克/ FG | A2 X2 | V:2的合併%% MIDI程序110%小提琴B2 | C2 ^ C2與E2 E2 | D2 D2和X2 G2 | _e2 Z = E&G2 X G | FEDC | V:3 %%合併MIDI程序110%小提琴ED | C2 A,2 | D2 G,2 | C2 z對於C | F2 ^ F2 |%V:1×2 G2 | _a2 = A2 | _b2 Z = B | c'_bag | ^ FE / D / G2 | V:2 B C / D / ED | C2 FE |德/日/ CD | e2c2&G2 X2 | C2 _BA / G / | V:3 G2 C2 | F2 D2 | G2 Z2 | C2 _E2 | D2 Z2 | %V:1 GA / _b / AG | f2f2 | E2E2 | ^ f2x2 | X2 G2 | g2fe / D / | V:2 ^ C2?^ 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?_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
其中,EDO代表“倍頻的等分”。
Here are sample MIDI files produced from the above source that you can listen to.
正常的氣質
17部門/倍頻程
19部門/倍頻程
22部門/倍頻程
31部門/倍頻程
41部門/倍頻程
120-70
120-140
600-350
Tuning System
Turkish music uses more complex music scales which may contain many microtones. Inserting the command
%%MIDI tuningsystem comma53
Instructs abc2midi to use the Holdrian comma scale instead of the regular equal tempered scale. The Holdrian comma scale splits an octave into 53 equal microtones or commas. The comma is 1200/53 = 22.641 cents or 0.22641 of a MIDI pitch unit. Thus it splits a semitone into approximately 4 commas. Middle C corresponds to 60/0.22641 exactly to 265 Holdrian comma, however the other notes in the 12-note equal tempered scale do not align exactly with the comma scale. The following figure shows the comma value and the abc representation for a small range of comma tones.
逗號規模
The corresponding abc file without the annotations looks as follows.
%%format comma53.fmt
X:1
T: comma53 scale
M: 10/4
L: 1/4
K: C
%%MIDI tuningsystem comma53
C ^1/4C ^2/4C ^3/4C ^C ^9/8C _3/4D _2/4D _1/4D D|
Here are some important comments here. Abc2midi converts the microtones into the correct pitches using the MIDI pitch bend function. You need a fairly recent version of abc2midi (at least 3.21 January 16 2014), in order that the microtones are transformed correctly to the Holdrian comma 53 scale. Secondly, in order that abcm2ps can convert this file into a valid PostScript file, you require the statement
%%format comma53.fmt
at the top of your abc file, and the file comma53.fmt should be in the same folder as the abcm2ps executable. The comma53.fmt file defines the symbols to be used for representing the microtones and looks as follows.
Furthermore, though ^1/2, ^2/4, ^3/6 and etc. are all equivalent microtone fractions to abc2midi, they are treated differently by abcm2ps. If you substitute ^1/2 or ^/2 instead of ^2/4, abcm2ps will display the wrong symbol.
I have yet to create a format file for SVG output, so SVG and XHTML output do not work if you have these microtones.
If you are not modifying the temperament or inserting microtones you can ignore this command. Normally voice chords containing microtones eg [_/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.
Pitchbend
%%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.
Single Note Tuning
%%MIDI snt k pitch
由於許多MIDI設備不支持此功能,使用此命令不推薦。該命令更改使用一個音符調諧“通用系統專用信息”。k是MIDI音高被重新調整(一個介於0至127)和間距為代表的MIDI分隔單位的音調的新值的浮點數。 Here is an example.
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.
%%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.
Abc2midi has a few run time parameters that may be included after the input file name. If you start abc2midi with no parameters, you will see something similar to this.
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.mid
You will find a MIDI file dennis3.mid in your directory which you can play with any MIDI synthesizer (eg 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 (eg dennis1.mid, dennis2.mid, and etc.).
-c選項
abc2midi不產生任何MIDI文件,但只是報告它處理abc文件時發現的任何錯誤。
-v號碼
其中-v後跟一個小數目。這在詳細模式下運行abc2midi。在終端上abc2midi輸出很多信息取決於以下數(通常小於5)的大小。在事件abc2midi崩潰,並分段錯誤,這個輸出是確定發生問題的位置非常有用。如果沒有號碼如下-v,詳細級別是最小的。 For example,
Rather than automatically creating a MIDI file based on the input abc file name and X: reference number, abc2midi produces a MIDI file with the given filename. For example:
abc2midi dennis.abc -o test.mid
will produce a MIDI file called test.mid instead of dennis3.mid.
-t
The name of the output MIDI file is based on the first few letters in the title of the tune. By default the number of letters is 8 but you can change it using the -n option. Any spaces, punctuation marks and special characters are eliminated. Words are separated by capitalization of the initial character. For example, if your input abc file contains a collection of tunes, abc2midi will produce a collection of MIDI files with names related to the tunes title.
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.
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:
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 180
will 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.
To modify the abcmidi package, you need to be an accomplished C programmer, familiar with a debugger program and the MIDI file format. It takes many hours to identify the source of a bug and to determine the fix (which is frequently just a couple of lines of code), so you need to be patient. The abcmidi package was developed in the early days of C compilers and computers. Because computers at that time had limited memory and speed, this program was designed to use limited resources as efficiently as possible at the expense of easy maintenance. The abcmidi package is still being compiled and run on some ancient machines. The package was initially simple: there was one developer and there was little need for good documentation or clear programming style. Gradually, as more features were patched in and more bugs were identified and fixed, the code becane barely manageable. There is some description of how the programs are designed in the folder abcmidi/doc/programming/.
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, eg 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.