Abc midi tutorial

This page is based on


Abc notation is a simple but powerful ASCII musical notation format, by Chris Walshaw. A tune notated in abc can be played directly from the notation, or many software packages exist which can convert abc notation into MIDI, produce sheet music, play the file through the computer speaker, etc.

Wiki Syntax

This wiki allows to render Abc notation to images and midi files. In order to do so, you need to insert an <abc> command in the wiki page, followed by a unique midi file name X:. The code is parsed by Abc midi until the end tag</abc>, and (if no errors occured) displayed as a png image linked to the midi file.

T:Paddy O'Rafferty
dff cee|def gfe|dff cee|dfe dBA|dff cee|def gfe|faf gfe|1 dfe dBA:|2 dfe dcB||
~A3 B3|gfe fdB|AFA B2c|dfe dcB|~A3 ~B3|efe efg|faf gfe|1 dfe dcB:|2 dfe dBA||
fAA eAA|def gfe|fAA eAA|dfe dBA|fAA eAA|def gfe|faf gfe|dfe dBA:|
  • X:42 : this is a unique id for this midi snipplet. if you choose a non unique id, it may be overwritten by other wiki pages
  • T: (optional): Title of the Tune
  • C: (optional): Composer
  • M: (optional): Metrum (eg. M:3/4)
  • K: : Key (eg. K:F → F-major / F-Dur : one b)

the rest is Abc notation described in the following part of this tutorial.

Abc Syntax

Let's get right into it…


Middle C is notated as C.

Starting at middle C, the notes in that octave are shown as CDEFGAB.

The next octave above is shown in lowercase. Octaves further above are appended with a '. The middle C can be lowered an octave by appending an ,.

The middle four octaves are written as C,D,E,F,G,A,B,CDEFGABcdefgabc'd'e'f'g'a'b', but note that the range can be extended further by adding more commas or apostrophes. A picture paints a thousand words:


Note length / Timing

Abc allows you to set the ‘default note length’ for each tune. This is set (as a fraction) in the tune header in the L: field.

Default note length ‘English’ terminology ‘American’ terminology
1/2 Minim Half note
1/4 Crotchet Quarter note
1/8 Quaver Eighth note
1/16 Semi-quaverSixteenth note

To modify a note length from the default, simply append an integer multiplier to it: with L:1/8 (eight or quaver default) cd2e4 | f/2 g/4 f/4 renders as

cd2e4 | f/2 g/4 f/4


Rests are indicated by the (lower case) letter z. The length of rest is set exactly the same way as the length of note is, eg z4.

Sharps, flats

To sharpen a note precede it with the circumflex or caret ^ ^c

To flatten a note precede it with an underscore _ _B

Double sharps are shown as ^^ and double flats as __

To naturalise (?) a note precede it with an equals sign = eg. =c


The key signature is specified by the K: field eg K:G.

Major keys are assumed, but can be specified by maj eg K:Gmaj.

Minor keys are shown by m or min, eg K:Gm or K:Gmin.

In the key signature field sharps are noted by the hash character # and flats by the letter b, eg

B flat K:Bb
C sharp K:C#

Modal keys (the Lydian, Ionian, Mixolydian, Dorian, Aeolian, Phrygian and Locrian modes) can all be specified by adding the first 3 letters of the mode eg K: G mix or K:Gmix

Time signatures

the M: field and the rhythm R: field.

Time signatures, or meters, like default note lengths, are shown as fractions in the M: field, eg: M:6/8 or M:4/4 or M:3/4, and so forth. Common time is shown as C, and cut time as C| (the letter C followed by the pipe symbol).

Abc also includes a rhythm field, R:, which is used for cataloguing and sorting collections of abc tunes: this is entirely free text (although there are obvious ‘standard’ entries eg R:reel, R:jig, R:schottische).

An M: field can be placed in the middle of a tune to denote a change of meter.

Mid-tune changes of key, time etc.

The L: note length field, the M: meter field, the K: key signature field and the Q: tempo field can all be inserted in the middle of a tune to indicate a key change. Strictly speaking this should be on a new line eg to play a G major scale ‘up’ and a G minor scale ‘down’ again,

K:G GABcdefg K:Gm gfedcBAG

but most software packages will allow the use of [ ] square brackets eg

K:G GABcdefg [K:Gm] gfedcBAG.

If you want to change two fields at once, either put them on two new lines like this -

K:G GABcdefg | M:6/8 K:Gm gfe dcB | AGB FED |

or put them both in the square brackets in the middle of the line like so :

K:G GABcdefg | [M:6/8 K:Gm] gfe dcB | AGB FED |

GABcdefg | [M:6/8 K:Gm] gfe dcB | AGB FED |

Barlines and spaces

Barlines are denoted by the pipe symbol |. Our G major scale in jig time immediately becomes more readable :

M:6/8 L:1/8 R:Jig K:G GABcde|fgfedc|BAG


A double bar is shown by ||, and by using the square bracket symbol as |] (thin-thick) and [| (thick-thin). Repeats are dealt with soon.

To make the notation even more readable spaces can be inserted to separate groups of notes :

M:6/8 L:1/8 R:Jig K:Gm GAB cde|fgf edc|BAG

Spaces are also used within the melody, and by the various software packages which convert abc into standard notation, to group notes. The spacing of abc notation will tend to mirror the grouping which would be used in standard notation. Spaces may also be inserted at the start and / or end of bars to make the abc more readable. As an example, I find something like

G | GAG GAG | c2G EFG | A2F DEF | GEC C2E |

easier on the eye than



Repeats bring the colon : into action. The start of a repeated section is shown by |: and the end of a repeated section by :|

Where the end of one repeated section, and the beginning of the next, coincide, :||: is technically correct, but this is usually shown without the pipe symbols eg ::.

Numbered and alternate repeats are indicated by [1 and [2 (etc.). Where the start of a section coincides with a barline the [ symbol may be omitted, eg DE FF |[1 GA Bc :|[2 GA BG || can also be written as DE FF |1 GA Bc :|2 GA BG ||

However if a repeat section does not coincide with a barline, always use the [ symbol instead of inserting an extra | .

Note that there can be no blank space between the barline and the number - eg [1 and |1 are acceptable, whereas [ 1 and | 1 are not.

title (T:) and index (X:)

Nearly every tune has a title, and one should always be included for identification purposes in tune lists, even if the exact title is not known. The title is indicated by the T: field eg T:Ballydesmond polka.

A tune may have more than one title - in this case just add a second, third, etc. T: field (each on a new line) and enter the alternative title(s) in there.

There is one more field to introduce at this stage : the X: index field.

The X: field is primarily for computers' benefit, as they (computers) have much more trouble than human beings in telling where one tune stops and the next starts. Many software packages therefore rely on the X: field to signify the start of a tune, even if there's only one tune in a file, and a blank line, followed by an X: field, delimits one tune from the next. It is therefore good practise to include an X: field at the head of your Abc tune(s).

The X: field is put on the first line of the notation of a tune, and takes the form X:<number>

It is good practise (but not absolutely essential) for the X: field to be incremental, eg the first tune in a file is X:1, the second tune in the file is X:2, etc.

tempo (Q:)

The tempo of a tune is shown in the Q: field, giving either the human or software musician a speed indication, eg Q:120 indicates the tempo as 120 notes of the default note length per minute.

Q:1/8 = 120 can also be used, to specify in this example that the tune goes at the rate of 120 1/8 notes per minute, regardless of the default note length.

A T: field can be placed in the middle of a tune to denote a change of tempo - see the Mid-tune changes selection above.

Elements in the tune body


The general symbol for an ornament is the tilde ~.

The symbol is placed before the note to be ornamented, eg ~G2.

Note that the tilde is a general mark to indicated the presence of an ornament, and does not specify a particular ornamentation - it is usually interpreted as a roll or a turn. For the more precise notation of ornamentation such as Great Highland Bagpipe music, and for the notation of particular grace notes, enclose the notes in curly brackets { } eg {GAGDG}G2.

The notes within curly brackets have no fixed time value, so their length cannot be modified by use of the usual symbols : in other words anything like {G2AG2D}, {GA/G/D/G}, or {GA>GD>G} is out of the question. The pitch of the notes is notated in the usual way, eg the octave modifiers, and ' are useable.

Slurs and Ties

The minus sign - should be used to tie two notes of equal pitch, whilst the round brackets () join two or more notes which are to be slurred, or played legato.

Two notes can be tied together with a minus sign - . This can be applied both within a bar and across bar lines, eg |DEF-|FGA| and |DEF-FGA| are both correct. The tie marking should be placed immediately after a note, but can be followed by a space.

To slur a group of notes or join them together as a phrase , use round brackets ( ) to enclose the grouped notes, eg (DEF|GAB).

Spaces can be used within the slur to improve the legibility of the file. However the first and last notes, (including any pitch and/or length markings) should be placed hard up against the beginning and ending brackets. So (^G A B/c/|E4 D4) is correct, but ( ^G A B/c/|E4 D4 ) is well wide of the mark.

It's also worth mentioning that you can 'nest' slurs inside each other, so that a passage of music finishing with a tied note can be shown either as (D E F (G | G4)) or (D E F G-| G4) are both understood.

Triplets, quadruplets, et al

The basic notation for duplets, triplets, quadruplets etc. is straightforward : an opening round bracket, the number, and the notes within the tuplet eg

Duplet (2GA
Triplet (3GAB
Quadruplet (4GABA

and so on, up to (9GABcdcBAG

Note that there are no spaces in the tuplet.

The values of the particular tuplets are (to quote the abc specification)

(2 2 notes in the time of 3
(3 3 notes in the time of 2
(4 4 notes in the time of 3
(5 5 notes in the time of n
(6 6 notes in the time of 2
(7 7 notes in the time of n
(8 8 notes in the time of 3
(9 9 notes in the time of n

n is 3 in compound time signatures (3/4, 3/8, 9/8 etc), and 2 in simple time signatures (C, 4/4, 2/4 etc.)


For more complicated notation of irregular rhythmic episodes, abc allows for the use of the form (p:q:r

p = the number of notes to be put into time q
q = the time that p notes will be played in
r = the number of notes to continue to do this action for.

If q is not specified, it defaults to 3 in compound time signatures and 2 in simple time signatures. If r is not specified, it is taken to be the same as p.

This comes into play when notating notes of different lengths within a tuplet eg (3:2:2G4c2 or (3:2:4G2A2Bc and explains exactly what is going on in situations such as (3D2E2F2 - which is the same as putting (3:2:3D2E2F2

Chords and Unisons

Chords for guitars etc. can be found here.

Chords within a melody, eg what classical Western notation would show as multiple note heads on a single stem, are shown in abc by enclosing the notes in square brackets [ ]. There should be no spaces within the chord, length and pitch modifiers can be included as required, and it is a convention to state the notes of the chord in ascending order, eg [Acea].

Chords can be arranged to form beamed groups using spaces in the same way that individual notes are, eg [GB][Ac] [B2d2] | [Bd][Ac] [G2B2] | [A4c4e4a4]

[GB][Ac] [B2d2] | [Bd][Ac] [G2B2] | [A4c4e4a4]

The syntax for chords can be used to notate more than one part in a single line of music - and in that case, or in cases where two strings play the same note, it will occasionally be necessary to notate a unison (eg both parts playing a note of the same pitch and length). Software which generates classical Western notation from abc will show unisons eg [AA] as a note with both an upwards and a downwards stem.

Guitar chords

Chords for accompanying instruments can be shown in abc using double quotation marks “ ” eg “Dm7”

The chord should appear before the first note of the section of melody which the chord applies to, eg “G”GB d2 | “D”DF A2

"G"GB d2 | "D"DF A2

Chords take the format note accidental type / bass

note :	A to G
accidental :	# or b
type :	m, min, maj, sus, dim, +, 7, 9, 11,#5, etc. etc
/ bass :	Bass note
accidental, type, and / bass are all optional.

You may occasionally come across an abc file which uses the older abc style of denoting guitar chords, by surrounding them with addition signs +Gm+ : more recent versions of the abc specification specify the use of the “Gm” style, so please do your chords like that.

Fiddle bowing marks

Up-bow and down-bow marks for fiddlers can be indicated by the letters u (up-bow) and v (down-bow), eg v_Au=Bv^c.

Line ends and line breaks

In software which generates standard Western notation from abc, the general rule is that one line of abc will generate one line of tadpoles-hanging-on-five-barred-gates.

Most packages will however 'wrap' the staff of music onto the next line if your printed page width isn't big enough.

To try to insist that two lines of abc notation make one line of tadpoles, put a back slash \ at the end of the first line. Again, this may be over-ridden by the software if you run out of space.

The other common symbol often seen used in marking line breaks is an exclamation mark ! placed at the end of a line of abc, to force the software generating the standard Western notation to start a new line. This is specific to one particular piece of abc software and is not actually a formal part of the abc notation specification, but (as so many abc files are generated in this particular software package, ABC2Win) it is worth mentioning here.


If you want to indicate that a particular note should be played staccato, place a dot . before the note, eg .A or even .G.A._B.c .d2.e.d.^c

Song words

The W: field (upper case W) in the header can be used as many times as needed to record the entire words of the song as a block of text eg

W:How much is that doggie in the window
W:The one with the waggly tail?
W:How much is that doggie in the window
W:I do hope that doggie's for sale
(etc. etc.)

This form of notating the song words will produce the words as a single text block below the tune, if the abc file is fed into a software package which generates standard Western notation.

Information fields in the tune header

As seen in the first part of this tutorial, the tune header contains a number of fields giving information about the tune such as title, rhythm, key signature, etc. The introductory tutorial mentioned the fields which must be shown in the tune header, and also described some of the optional information fields which are most commonly used.

The abc specification allows for many more optional descriptive or information fields to be used in the tune header - the full list is :

A: (Geographical) Area : eg A:Brittany or A:Sussex
B: Book, eg B:Encyclopeadia Blowzabellica or B:O'Neill's
C: Composer eg C:Andy Cutting or C:Trad
D: Discography eg D:New Victory Band, One More Dance And Then
F: File Name eg
G: Group eg G:Flute - this is used for the purpose of indexing tunes in software, NOT for naming the group / band you acquired the tune from (which should be recorded in the S: source field).
H: History - Multiple H: fields may be used as needed to record text about the history of the tune. (Many people (including me) seem to tend to forget about the H: field and instead always put information like that in the N: notes field instead.)
I: Information - used by certain software packages, NOT for historical information or notes (which should be recorded in the H: or N: fields).
K: Key -see part one of this tutorial for further details
L: Default note length -see part one of this tutorial for further details
M: Meter :see part one of this tutorial for further details
N: Notes : Multiple N: fields can be used as needed to record detailed text notes about, well, just about anything you want to say about the tune that won't go in any of the other fields really …
O: (Geographical) Origin : eg O:Irish or O:Swedish
P: Parts -see below for further details
Q: Tempo -see part one of this tutorial for further details
R: Rhythm -see part one of this tutorial for further details
S: Source - where you got the tune from eg S:Olio or S:Dave Praties
T: Title -see part one of this tutorial for further details
W: Words -see below for further details
X: Tune reference number -see part one of this tutorial for further details
Z: Transcription note - the identity of the transcriber or the source of the transcription, eg Z:Steve Mansfield

To repeat a small part of the first part of this tutorial:

The X: index, T: title, M: meter, L: default note length, and K: key field are obligatory : the others are optional.

The fields usually occur in the following order:

[optional fields]

And immediately following the K: field on the next line is the body of the tune, eg the representation of the notes of the melody.

Putting it all together

Example Source

T:Plead for Slough
T:Speed The Plough (arr.)
H:Illustrative file for abc tutorial
N:The tune that should be the English national anthem,
N:renamed in this version in honour of the John Betjeman poem
C:Trad.arr. Steve Mansfield June 2000
P:(2A2B)ad infinitum
Z:Steve Mansfield 6/6/2000
"G" (GAB)c dedB | "G" .d.e.d.B dedB |
"Am" c2ec "D7" B2dB | "D"A2"Dm"A2 "Am" A2BA |
"G" (GABc d)edB | "G" .d.e.d.B dedB | "C" ~c2ec "G" ~B2dB- |
"D7" BA A2 "G" ~G4 ::
"C" g2g2 {GABcdef}g4 | "G" g2fe dBGB |
"Am" cAEc "Bm"BGDB | "F#m"A2A2 "D"A4 |
"C"g2g2 "G"g4 | "G"g2fe dBGB |
"C" (5cdedc "Am" ec"Bm"B2"~G"dB |
"A"[A2c2]"Am"[A2a2] "G"[G4B4d4g4] :|


T:Plead for Slough
T:Speed The Plough (arr.)
H:Illustrative file for abc tutorial
N:The tune that should be the English national anthem,
N:renamed in this version in honour of the John Betjeman poem
C:Trad.arr. Steve Mansfield June 2000
P:(2A2B)ad infinitum
Z:Steve Mansfield 6/6/2000
"G" (GAB)c dedB | "G" .d.e.d.B dedB |
"Am" c2ec "D7" B2dB | "D"A2"Dm"A2 "Am" A2BA |
"G" (GABc d)edB | "G" .d.e.d.B dedB | "C" ~c2ec "G" ~B2dB- |
"D7" BA A2 "G" ~G4 ::
"C" g2g2 {GABcdef}g4 | "G" g2fe dBGB |
"Am" cAEc "Bm"BGDB | "F#m"A2A2 "D"A4 |
"C"g2g2 "G"g4 | "G"g2fe dBGB |
"C" (5cdedc "Am" ec"Bm"B2"~G"dB |
"A"[A2c2]"Am"[A2a2] "G"[G4B4d4g4] :|
wiki/abcmiditutorial.txt · Last modified: 2013/06/02 15:45 by