To make a tabulature with abc2xml you only need to specify a tab clef. An example is the following ABC code (in a file bass.abc)
X:1 K:Cm tab octave=-1 strings=E1,A1,D2,G2 C,3 E,3 G,A,| G,3 F,3 G,D, |
In addition to the tab clef we also specified an instrument tuning with the stings=... attribute (more info). The instrument is in this case an electrical bass guitar. The stings=E1,A1,D2,G2 attribute defines the tuning of each string (and implicitly the number of strings). With this information abc2xml is able to calculate the string/fret position of each note. We convert the example (bass.abc) to MusicXML with the following command:
> abc2xml.exe -f bass.abc > bass.xml
Note the extra command line option -f, which forces abc2xml to do the allocation of notes to string/fret positions. If you leave it out, the XML file will contain no string/fret elements, which is better if you want a score editor like MuseScore to do the allocation. But when you want to translate the XML file right back to ABC, which we will do hereafter, we need the string/fret elements present in the XML file.
In MuseScore the file bass.xml we just made, looks like this: (SVG picture exported from MuseScore)
However, in stead of using MuseScore, we want to use abc2svg to display the score. To do that, many complex statements need to be calculated and inserted into the ABC score. With option -t, however, xml2abc will generate these statements for you, and also include the SVG code for the noteheads. So we just translate bass.xml back into ABC, using the -t option:
> xml2abc.exe -t bass.xml > bass_1.abc
and we display bass_1.abc with abc2svg, which results in the following SVG picture:
There are some minor differences with the output of MuseScore, regarding dots and stems. But essentially it looks quite the same.
To illustrate the complexity of the ABC code produced with the -t option, the content of the file bass_1.abc is shown below:
X:1 %%beginsvg <style type="text/css"> .bf {font-family:sans-serif; font-size:7px} </style> <defs> <rect id="clr" x="-3" y="-1" width="6" height="5" fill="white"/> <rect id="clr2" x="-3" y="-1" width="11" height="5" fill="white"/> <g id="kop0" class="bf"><use xlink:href="#clr"/><text x="-2" y="3">0</text></g> <g id="kop1" class="bf"><use xlink:href="#clr"/><text x="-2" y="3">1</text></g> <g id="kop3" class="bf"><use xlink:href="#clr"/><text x="-2" y="3">3</text></g> </defs> %%endsvg X:1 T:Bass L:1/8 M:4/4 K:Cmin %%map tab1 C,, print=G heads=kop3 %%map tab1 D,, print=B heads=kop0 %%map tab1 F,, print=B heads=kop3 %%map tab1 G,, print=d heads=kop0 %%map tab1 _A,, print=d heads=kop1 %%map tab1 _E,, print=B heads=kop1 V:1 tab stafflines=4 strings=E1,A1,D2,G2 %%voicemap tab1 K:none M:none %%clef none %%staffscale 1.6 %%flatbeams true %%stemdir down V:1 C,,3 _E,,3 G,,_A,, | G,,3 F,,3 G,,D,, | %2
At the very bottom you still see the single line of real ABC, which this is all about. You can compare this output with the original ABC of the example at the top. The tab clef syntax incorporates a higher musical level than the %%map and %%voicemap of abc2svg. The latter are, however, more flexible and can be used to implement a variety of musical concepts.
A real bass guitarist will avoid playing two open strings in succession because the first one has to be damped before the next is played (two bass tones sounding simultaneously is ugly). The automatic layout algorithm does not know about this, and in the example above the last two notes (G,D,) are open strings. To change this the G, can be assigned to the second string, as follows:
X:1 K:Cm tab octave=-1 strings=E1,A1,D2,G2 C,3 E,3 G,A,| G,3 F,3 !2!G,D, |
The ABC finger decoration !2! is used to indicate the second string (only in the context of a tab-staff). String numbers run from high to low strings. For a bass !4! denotes the lowest string. After translation by running:
> abc2xml.exe -f bass.abc > bass.xml > xml2abc.exe -t bass.xml > bass_1.abc
the resulting score (file bass_1.abc) is shown below:
The !2!G, is now played at the fifth postition of the second string, avoiding the two open strings in succession.
I have saved the file bass_1.abc to my Dropbox and shared the file, getting the following link back from Dropbox:
https://www.dropbox.com/s/jrja2i0bl82pi8y/bass_1.abc?dl=0.
Dropbox links, like this one, can be used in all my programs (abcweb, synpdf, follow, xmlplay), by using only the ID-part of the link prefixed with "d:". For the bass_1.abc this prefixed ID would be:
d:jrja2i0bl82pi8y/bass_1.abc
This prefixed ID is then appended to the base URL of one of my programs (using a question mark in between)
https://wim.vree.org/js3/xmlplay.html ? d:jrja2i0bl82pi8y/bass_1.abc
resulting in the following, working, link:
https://wim.vree.org/js3/xmlplay.html?d:jrja2i0bl82pi8y/bass_1.abc
Anyone with a Dropbox account can share and show scores in this way. No private web server needed.
Also a percussion score is easy to make, as shown in the next example (drum.abc)
X:1 K:C perc I:percmap ^g closed-hi-hat x ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g |
You need to specify a perc clef and for each ABC note an I:percmap statement. In the example the percmap says that note ^g sounds as a closed high hat and appears in the score as a little cross (x). The sound names you can use in a percmap are the ones defined in the MIDI-GM-1 standard, which you can see here and here.
The following command translates the percussion example to MusicXML:
> abc2xml.exe drum.abc > drum.xml
In MuseScore it looks like this:
To show the file with abc2svg, we translate the XML file back to ABC again with the -t option:
> xml2abc.exe -t drum.xml > drum_1.abc
This file drum_1.abc produces the following SVG picture with abc2svg:
To obtain an ABC file that is suited for both abc2svg and abc2midi we need to invoke xml2abc with the -t and -m1 option. The -m1 option generates %%MIDI statements for abc2midi. In particular for a percussion voice %%MIDI drummap lines will be generated for the sounds used. In our example:
> xml2abc.exe -t -m1 drum.xml > drum_1.abc
generates the following voice definition in drum_1.abc:
... K:C V:1 perc %%voicemap perc1 %%MIDI channel 10 %%MIDI program 0 %%MIDI drummap ^g 42 V:1 ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g | %2
In the following ABC file (bassDrum.abc) we have added a second voice to the drum score with a bass and snare drum. Also the bass guitar tabulature from the first example is added as a third voice. In the second percussion voice the acoustic snare is tapped on the rim (sound side-stick) and played normally (sound acoustic-snare). To distinguish between the two, we display the side-stick with a triangle note head and the acoustic-snare with a normal note-head. Both note heads are shown at the same step-height (c). The accidental of _c has no further meaning in a percussion score and is not rendered. It only serves to distinguish between the rim tap and normal beat.
X:1 T:Example L:1/8 M:4/4 I:score (1 2) 3 K:Cm % V:1 perc nm="Drum" I:percmap ^g closed-hi-hat x % V:2 perc I:percmap c acoustic-snare I:percmap _c side-stick triangle I:percmap E acoustic-bass-drum square % V:3 tab octave=-1 strings=E1,A1,D2,G2 nm="Bass" %%MIDI program 36 % [V:1] ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g | [V:2] EE c x EE c x | EE _c x EE _c x | [V:3] C,3 E,3 G,A, | G,3 F,3 !2!G,D,|
Both the tabulature and percussion voices will be translated to XML and back to ABC with the -t option, generating all the necessary %%map, %%voicemap and SVG definitions in one go. First we translate to XML:
> abc2xml.exe -f bassDrum.abc > bassDrum.xml
In MuseScore this is rendered as follows
MuseScore is not able to render the square note head that we used for the bass drum. With abc2svg that is no problem because xml2abc includes its own SVG definitions for note heads (presently xml2abc only supports x, diamond, triangle and square).
To get abc2svg to display the score, we translate back to ABC with the -t option:
> xml2abc.exe -t -m1 bassDrum.xml > bassDrum2.abc
This results in the following SVG picture: (click in the score to start playback)
A click in the score above starts playback. A click outside the score stops playback. While playing the cursor can be repositioned by a click on a note. The -m1 option of xml2abc that we used to make file bassDrum2.abc generates %%MIDI definitions, so that you hear the right instruments (with the right volume and panning, as we will see later).
We extend our example with two more measures and two more instruments: a guitar (tab) and a piano. In addition we add %%MIDI statements to position the instruments at different places in the stereo image and balance their volumes. The midi statements %%MIDI contol 7 volume sets the volume of a voice and %%MIDI contol 10 pan sets the panning position. The ABC code is shown below (file bassDrumPan.abc):
X:1 T:Example %%score (1 2) 3 4 5 L:1/8 M:4/4 I:linebreak $ K:Eb V:1 perc nm="Drum" I:percmap ^g closed-hi-hat x %%MIDI control 10 48 %%MIDI control 7 110 V:2 perc I:percmap c acoustic-snare I:percmap _c side-stick triangle I:percmap E acoustic-bass-drum square %%MIDI control 10 80 %%MIDI control 7 110 V:3 tab octave=-1 strings=E1,A1,D2,G2 nostems nm="bass" %%MIDI program 36 %%MIDI control 7 100 V:4 tab nostems nm="guitar" %%MIDI program 25 %%MIDI control 10 127 %%MIDI control 7 100 V:5 treble nm="piano" %%MIDI program 0 %%MIDI control 10 0 %%MIDI control 7 90 [V:1] ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g | ^g^g ^g^g ^g^g ^g^g | %4 [V:2] EE c x EE c x | EE _c x EE _c x | EE c x EE c x | EE _c x EE _c x | %4 [V:3] C,3 E,3 G,A,| G,3 F,3 !2!G,D,| F,3 A,3 B,A,| G,F,E, D,3 =B,,G,,| %4 [V:4] [CEG]2 !3!CD [CEG]2 E!2!F | [DG=B]2 !3!D!3!=E [DGB]2 FG | [A,CF]2 AB [EAc]2 cd | [EGc]2 dc [DG=B]2 !2!G=B, | %4 [V:5] CD [CEG]2 EF [CEG]2 | D=E [DG=B]2 FG [DGB]2 | AB [FAc]2 cd [Ace]2 | ed [EGc]2 =BG [DGB]2 | %4
The volumes of hi-hat, bass-drum/snare, bass, guitar and piano are respectively set to 64, 40, 120, 127 and 127. The volume number ranges from 0 (silent) to 127 (loudest). The sound of the bass/drum/snare was relatively loud, whereas the guitar was relatively soft. The given volume settings compensate for this.
The panning of hi-hat, bass-drum/snare, guitar and piano are respectively set to 80, 48, 127, 0. The panning numbers range from left (0), middle (64) to right (127). The bass panning was not set, which means it remains at the default which is 64 (in the middle).
We translate the example with abc2xml and xml2abc in succession:
> abc2xml.exe -f bassDrumPan.abc > bassDrumPan.xml > xml2abc.exe -t -m2 bassDrumPan.xml > bassDrum3.abc
The -m2 option option makes sure that the %%MIDI control statements appear in the output. The SVG picture generated from bassDrum3.abc with abc2svg is the following: (click in the score to start playback)
and playback can be started by clicking inside the score above (pay attention to the panning). All examples in this tutorial can be played by clicking on the score. Playback stops when clicking outside the score. Clicking on a different position in the score repositions playback to that point.
In the next example we will make a combined normal staff with tab staff for a 5-string banjo.
The following ABC code is taken from the web page of Jean-François Moine: a banjo tablature fragment of the "Blue Moon of Kentucky". It is (probably) derived from a free tab by Dick Mahoney. The ABC code of the fragment is (file banjo1.abc):
X:1 M:4/4 L:1/4 V:1 treble-8 V:2 tab strings=G4,D3,G3,B3,D4 octave=-1 nostems K:C % [V:1] z[Bg][cg][^cg] |: ^c/[dd]/ g/d/ d/g/ d/d/ | B/d/ B/d/ A/d/ G/d/ | [V:2] z[Bg][cg][^cg] |: ^c/[dd]/ g/d/ d/g/ d/d/ | B/d/ B/d/ A/d/ G/d/ | % [V:1] E/c/ G/d/ g/G/ d/g/ | G/e/ g/G/ e/G/ E/e/ | D/d/ g/G/ d/g/ B/d/ | [V:2] E/c/ G/d/ g/G/ d/g/ | G/e/ g/G/ e/G/ E/e/ | D/d/ g/G/ d/g/ B/d/ |
In the first measure, after the pickup, is a unison chord [dd]. As we will see the allocation algorithm is smart enough to allocate the two d's to the first two strings. We translate the example as follows:
> abc2xml.exe -f banjo1.abc | xml2abc.exe -t -i > banjo1_tab.abc
Xml2abc can read xml data from standard input with option -i. The output of abc2xml is now piped into xml2abc avoiding the intermediate xml file. The output file banjo1_tab.abc produces the following SVG picture with abc2svg:
Apparently the string allocation algorithm (option -f) almost did a perfect job. There are only two notes in error: two /d 's after the unison chord in the first measure. They are allocated to the first string, but should be played on the second string. This can easily be corrected by adding a string annotion: !2!d/
We also add %%MIDI commands, to silence the first voice (normal staff) and to get the right instrument for the second voice. If we do not silence the first voice, both voices play the same notes at the same time, as if two instruments were playing. The corrected ACB code becomes:
X:1 M:4/4 Q:1/4=200 L:1/4 V:1 treble-8 %%MIDI program 25 %%MIDI control 7 0 V:2 tab strings=G4,D3,G3,B3,D4 octave=-1 nostems %%MIDI program 25 K:C % [V:1] z[Bg][cg][^cg] |: ^c/[dd]/ g/d/ d/g/ d/d/ | B/d/ B/d/ A/d/ G/d/ | [V:2] z[Bg][cg][^cg] |: ^c/[dd]/ g/!2!d/ d/g/ !2!d/d/ | B/d/ B/d/ A/d/ G/d/ | % [V:1] E/c/ G/d/ g/G/ d/g/ | G/e/ g/G/ e/G/ E/e/ | D/d/ g/G/ d/g/ B/d/ | [V:2] E/c/ G/d/ g/G/ d/g/ | G/e/ g/G/ e/G/ E/e/ | D/d/ g/G/ d/g/ B/d/ |
Translating the corrected example again, yields the tab as it should be:
The added %%MIDI commands (option -m2) also make the result playable. Just click on the score to start playback.
Fortunately I happen to be a much better banjo player than the legendary Dick Mahoney, so now listen to this:
https://wim.vree.org/js3/xmlplay.html?d:hovvq1wkald6rhq/banjo_wim.abc
The Mountain Dulcimer is an instrument with three string pairs (courses) and diatonic fretting. A common string tuning, which we use in the example below, is strings=D4,A3,D3. Note that the strings are ordered from high pitch to low pitch, which is the reverse of what is usual for a guitar. The diatonic scale of the frets is in Mixolydian mode. Both diatonic fretting and reverse pitch ordering of strings are not supported by MusicXML, so you cannot hope to display the xml files produced by abc2xml by any current software, except xml2abc+abc2svg.
The example is taken from abide_with_me2.pdf and hand translated by me into ABC (file awm1.abc):
X:1 %%score (1 2 3) L:1/4 M:4/4 I:linebreak $ K:D V:1 tab octave=-1 strings=D4,A3,D3 diafret nostems V:2 tab octave=-1 strings=D4,A3,D3 diafret nostems V:3 tab octave=-1 strings=D4,A3,D3 diafret nostems % [V:1] f2 f e | d2 a2 | b a a g | f3 z | [V:2] D D !1!A G | z F F2 | G E E E | !1!A3 z | [V:3] A2 c c | B2 d c | d c c A | d d c B | % [V:1] f2 g a | b2 a2 | g e f !2!^g | a4 | [V:2] D D D F | G G F2 | E E D B | E4 | [V:3] A2 B d | d2 d d | B A A d | c2 g2 | % [V:1] f2 f e | d2 a2 | a g g f | e4 | [V:2] D !1!A !1!A G | F F F2 | G2 D2 | z G F E | [V:3] A2 c c | B2 d c | B2 B2 | B4 | % [V:1] e2 f g | f e d g | f2 e > d | d4 |] [V:2] z E D E | D E F E | D D2 G | F2 D2 |] [V:3] A2 A A | A A B B | A2 A2 | A4 |]
Each tab clef has the new attribute diafret which is used by xml2abc to map the notes to the right frets, respecting the Mixolydian scale. Some notes had to be annotated with string numbers to get them on the right string. The ABC code above is spaced in such a way that the annotations clearly stand out. The example is translated as follows:
> abc2xml.exe -f awm1.abc | xml2abc.exe -t -i > awm1_tab.abc
The xml file is not needed so the output of abc2xml is fed directly into xml2abc using a pipe (the -i option). The output file (awm1_tab.abc) produces the following SVG picture with abc2svg:
We add a normal staff to the example by duplicating the three voices while changing the tab clef to a treble-8 clef and removing the string annotations. To get playable output we also add %%MIDI statements, spreading the three voices across the sound image from left to right. This results in the following SVG picture (click on the score to start playback):
X:1 T:Abide with Me C:Arranged for Mountain Dulcimer C:©2008 by Alan R. Barnarsd %%score { (1 3 2) (4 5 6) } L:1/4 M:4/4 I:linebreak $ K:D V:1 treble-8 nm="Dulcimer" %%MIDI program 25 %%MIDI control 7 0 V:2 treble-8 %%MIDI program 25 %%MIDI control 7 0 V:3 treble-8 %%MIDI program 25 %%MIDI control 7 0 V:4 tab octave=-1 strings=D4,A3,D3 diafret nostems %%MIDI program 1 25 %%MIDI control 10 0 V:5 tab octave=-1 strings=D4,A3,D3 diafret nostems %%MIDI program 2 25 %%MIDI control 10 64 V:6 tab octave=-1 strings=D4,A3,D3 diafret nostems %%MIDI program 3 25 %%MIDI control 10 127 % % Normal staff % [V:1] f2 f e | d2 a2 | b a a g | f3 z | [V:2] D D A G | z F F2 | G E E E | A3 z | [V:3] A2 c c | B2 d c | d c c A | d d c B | % [V:1] f2 g a | b2 a2 | g e f ^g | a4 | [V:2] D D D F | G G F2 | E E D B | E4 | [V:3] A2 B d | d2 d d | B A A d | c2 g2 | % [V:1] f2 f e | d2 a2 | a g g f | e4 | [V:2] D A A G | F F F2 | G2 D2 | z G F E | [V:3] A2 c c | B2 d c | B2 B2 | B4 | % [V:1] e2 f g | f e d g | f2 e > d | d4 |] [V:2] z E D E | D E F E | D D2 G | F2 D2 |] [V:3] A2 A A | A A B B | A2 A2 | A4 |] % % Tablature (same ABC with occasional string annotation) % [V:4] f2 f e | d2 a2 | b a a g | f3 z | [V:5] D D !1!A G | z F F2 | G E E E | !1!A3 z | [V:6] A2 c c | B2 d c | d c c A | d d c B | % [V:4] f2 g a | b2 a2 | g e f !2!^g | a4 | [V:5] D D D F | G G F2 | E E D B | E4 | [V:6] A2 B d | d2 d d | B A A d | c2 g2 | % [V:4] f2 f e | d2 a2 | a g g f | e4 | [V:5] D !1!A !1!A G | F F F2 | G2 D2 | z G F E | [V:6] A2 c c | B2 d c | B2 B2 | B4 | % [V:4] e2 f g | f e d g | f2 e > d | d4 |] [V:5] z E D E | D E F E | D D2 G | F2 D2 |] [V:6] A2 A A | A A B B | A2 A2 | A4 |], click to keep it unfolded)
A dulcimer tablature for the classical tuning DAA needs more string annotations, because the program cannot not distinguish between the two A-strings. Here is an example, due to Matthew E. Walworth:
https://wim.vree.org/js3/xmlplay.html?test/tab_still_daa.abc
X:1 T:Still, Still, Still C:Traditional C:Arranged by Matthew E. Walworth Z:copyright 2017 Matthew E. Walworth M:4/4 L:1/4 Q:1/4=80 V:1 clef=treble-8 %%MIDI program 25 %%MIDI control 7 0 V:2 clef=treble-8 %%MIDI program 25 %%MIDI control 7 0 V:3 octave=-1 tab strings=A3,A3,D3 diafret nostems %%MIDI program 3 25 V:4 octave=-1 tab strings=A3,A3,D3 diafret nostems %%MIDI program 4 25 I:score [ (1 2) | (3 4) ] K:Dmaj % % notation % V:1 "_Tuning DAA" a d' f a | d3 d/f/ | e e/g/ c c/e/ | d3 f | e e/f/ g e | f f/ g/ a f | e e/f/ g e | f f/g/ a f | a d' f a | d3 d/f/ | e e/g/ c c/e/ | d4 |] V:2 D/f/- f/f/ F/c/- c/c/| F/B/ F/B/ d x | G/B/ x E/A/ x | F/A/ F/A/ d x | A/c/ x A/c/ x/c/ | A/d/ x A/d/ x/d/ | A/c/ x A/c/ x/c/ | A/d/ x A/d/ x/d/ | D/f/- f/f/ F/c/- c/c/| F/B/ F/B/ d x | G/B/ x E/A/ x | F/A/ F/A/ D2 |] % % tablature % V:3 a d' f a | d3 d/f/ | e e/g/ c c/e/ | d3 f | e e/f/ g e | f f/ g/ a f | e e/f/ g e | f f/g/ a f | a d' f a | d3 d/f/ | e e/g/ c c/e/ | d4 |] V:4 D/f f/ F/c c/| F/B/ F/B/ !3!d z | G/B/ z E/A/ z | F/A/ F/A/ !3!d z | !1!A/c/ z !1!A/c/ z/c/ | !1!A/d/ z !1!A/d/ z/d/ | !1!A/c/ z !1!A/c/ z/c/ | !1!A/d/ z !1!A/d/ z/d/ | D/f f/ F/c c/| F/B/ F/B/ !3!d z | G/B/ z E/A/ z | F/A/ F/A/ D2 |], click to keep it unfolded)
A last example concludes the tutorial. It is a fragment of a composition of mine with guitar tab, bass tab and drum: