Recent Changes - Search:



Abc music notation

Summary: Display music scores from abc notation
Version: 2006-04-03
Prerequisites: abc2ps or abcm2ps, ghostscript, abc2midi or abcmidi, pnmcrop-ppmtogif or netpbm
Maintainer: Pm
Discussion: AbcMusic-Talk
Categories: Markup

Questions answered by this recipe

  • Can I use PmWiki to display music written in "abc notation"?


The abcmusic.phpΔ script converts music files in "abc notation" into PostScript scores, gif images, and midi files. Once configured (see below), this script enables markup of the form:

(:music:) notation here...

The gif image will display the notation as a musical score, and links underneath it will open the associated abc, ps and midi files.


Download abcmusic.phpΔ, copy to cookbook directory and install by adding to config.php:


Depending on the outputs you wish to produce, your system will also need some or all of the following external commands (executable programs):

  • abcm2ps - converts abc notation to postscript
  • abc2midi - converts abc notation to .mid file (package name: abcmidi)
  • gs - Ghostscript
  • ppmtogif - Convert .ppm files to .gif (packagename sometimes netpbm)
  • pnmcrop - crop a portable anymap

The basic format for configuring this script is:

$ABCProgs['abcm2ps'] = '/path/to/abcm2ps';
$ABCProgs['abc2midi'] = '/path/to/abc2midi';

If the "gs", "ppmtogif" and "pnmcrop" utilities aren't in PHP's executable path by default, you will also want to set appropriate values for $ABCProgs['gs'], $ABCProgs['ppmtogif']@ and [@$ABCProgs['pnmcrop'].

The options passed to each program are also controlled by the $ABCPSCmdFmt, $ABCGifCmdFmt, and $ABCMidiCmdFmt variables, so those can be set in addition to (or in lieu of) the $ABCProgs variables above.

Lastly, the script uses the variables $PubCacheDir and $PubCacheUrl to determine where to place temporary files and how to reach them by url.


Pm wrote the basic script above; but he would really appreciate it if someone else could fill out this recipe page with any information that ought to be here. :-) The script works fine, but details in ABC notations are quite tricky...

Release Notes

If the recipe has multiple releases, then release notes can be placed here. Note that it's often easier for people to work with "release dates" instead of "version numbers".

See Also

  • AbcTunebook - add and edit abc music using Fox and rendered as score and midi by abcjs javascript abc editor
  • The music recipe is a complete rewrite of Pm's AbcMusic recipe using the Content
    recipe. It supports two new formats, asciitab and tab, additonally it supports multi-page outputs.

ABC Notation

Sources of useful external programs:


  • Pm


The (:music:) markup has been enabled on this page -- feel free to experiment below.

T:Speed the Plough
N:Simple version
Z:Steve Mansfield 1/2/2000
GABc dedB | dedB dedB | c2ec B2dB | A2A2 A2 BA|
GABc dedB | dedB dedB | c2ec B2dB | A2A2 G4 ::
g2g2 g4 | g2fe dBGB | c2ec B2dB | A2A2 A4 |
g2g2 g4 | g2fe dBGB | c2ec B2dB | A2A2 G4 :|

X: 61
T:Green grows the Rasses
S:Oswald's Collection of Curious Scot's Tunes Volume 1
N: excerpt
Z:Hans Bracker 2005
d|TB3A ABde|d/e/f Te>dd3f|e3f gfga|{ga}b2e>fe2(Tf3/2e/4f/4)|
gfga{ga}b2(Ta>g)|(Tf>e) d/e/f/g/{fg}a2(Tg>f)|e2b2afef|{e}d2(Bc)B3:|

X: 1
T: Rolling In The Ryegrass
M: 4/4
L: 1/8
R: reel
K: Dmaj
|:ABde f2fd|g2ge fedB|ABde fefa|gfdf e2d2:|

X: 1
S:Moench von Salzburg
F2F |A2B|c2c|c2c|f2f|c2c|c2c|A2A|c3-|c3|
F2F |A2B|c2c|c2c|f2f|c2c|c2c|A2A|c3-|c3|
F2F |A2B|c2c|c2c|f2f|c2c|c2c|A2A|c3-|c3||

X: 1
T: Dawning Of The Day, The
M: 4/4
L: 1/16
R: polka
K: Dmaj
D2E2 |F4 F4 F4 E2F2 |A4 A4 B4 A2F2 |D4 E4 D4 D4 |D12 A4 |
B6 A2 B4 d4 |F6 E2 D4 F4 |A4 F4 d4 F4 |E12 A4 |
B6 A2 B4 d4 |F6 E2 D4 F4 |A4 F4 d4 F4 |E12 D2E2 |
F4 F4 F4 E2F2 |A4 A4 B4 A2F2 |D4 F2E2 D4 D4 |D12 |]

T:Yellow Barber
S:Bruce Molsky
Z:AK/Fiddler’s Companion
D/>=C/ | A,/G,/A,/=C/ D/E/D/C/ | A,/=C/D/E/ F/D/E/^C/ | A,/C/E/F/ E>F |
G/F/E/G/ F/D/E/D/ | F/AB/ A>=c | B/A/G/B/ A/F/A/g/ | (3f/a/f/ e/c/ d/B/A/G/ |
F/D/E/F/ D :: z | d2d2 | A/B/d/e/ f/d/e/c/ | A/c/e/f/ e>f | g/f/e/g/ f/c/e/g/ |
(3f/a/f/ e/c/  d/c/A/d/ | B/A/G/B/ A/F/A/g/ | (3f/a/f/ e/c/ d/B/A/G/ | F/D/E/F/ D :|

X:1    % Nr. of track (if more than one in a file)
T:Ubi Caritas   % title of song
M:2/4  % mesure   3/4, 4/4 od C, 2/2 od C|
L:1/8  % standard-Length of a note  
Q:1/8 = 120  % per minute
C:Sammlung ABC-Tunes P.Ogay Jan 2008
K:Dmin    % K minor
% midi settings
V: S clef=treble name="Soprano"
V: A clef=treble name="Alto"
%V: T clef=treble-8 name="Tenor"  %%in Treble notieren, sonst um Okt versch.
V: T clef=bass name="Tenor" !fff! %%in realer Tonhöhe notieren
V: B clef=bass name="Bass" !fff!
%staves {(S A) (T B)}     %%Stimmen Zusammenfassen
% 60: english Horn  19:Kirchen Orgel
% 58:Tuba  66:Tenor-Sax  70:fagott 73:flute
% 24: Gitarre 25:Steel 26:Jazz 0:Klavier 53:Choral Ah's 68:Oboe 75:Panflöte
% 4:E-Piano  71:Klarinette
% S:  >73:Flute 21: Akkordeon
% T - >68:Oboe  67: Bariton Sax 21:Akkordeon
% B -  68:Oboe  58:Tuba
%%MIDI program 1 26 %%Sopran  73-Flöte
%%MIDI program 2 26 %%Alt
%%MIDI program 3 26 %%TEnor 56
%%MIDI program 4 68 %%Bass 58:Tuba
%%midi 60 1
%%midi 60 2
%%midi 60 3
%%midi 120 4
%%staves {(S A)}  %%sopran, alt on one line
[V:S]!f!"^p" AA GG | F2 z F | (B2 A2) |  G4 "^," | AA  GG | F4 | DD ((3EDE) |F4 ||
w: U-bi car-ri-tas et a-*mor, |u-bi ca-ri-tas De-us i-*bi est
[V:A] !p!"^p" FF CC | D2 z C | (B,2 D2) | (D2C2)  "^," | FF  CC | D4| DD CC | [C4F,4] ||

C:Andy Cutting
D:Blowzabella, Vanilla
e de | ce Be Ae | F2 AB cA | f3 edc | B3 ede |
ce Be Ae | F2 fe dc | B3 dcB |1 A3 :|2 A6 |:
AB cA ag | f3 edc | Bc dG gf | e3 dcB |
AB cF fe | d3 cBA |1 B2 Bd ^cd | B3 dcB :|2
B2 Bd cB | A6 |]
X: 1
T: Horizonto
M: 6/8
L: 1/8
Q: 3/8=125
V: 1
C: Paul James
K: Dm

aba gaf|gef dec|A2d def|e2c cde|
f3 fgf|e2c cde|fed edc|A=Bc d3:|

|:B2d def|B2d def|A2d def|A2d def|
B2d def|B2d def|aba gaf|gef dec|
B2d def|B2d def|A2d def|A2d def|
B2d def|B2d def|=B2d def|=B2d def:|

g2f2ed|_d4=de|f2d2dc|d2 z z3:||
X: 1
T:Odenwaelder Blatschtanz
%%textfont Helvetica-Narrow 10pt
%%begintext align
B:Pijpersboek, Mart Heijmans, Muziekuitgeverij van Teeseling, Nijmegen, 1980
N:im buch nr 38
N:im buch ganz in C  1. ton g'
Z:abc transcription Simon Wascher
F: 2009-03-19 20:27:02 UT
G |:\
c>d ec | d>e ff | eg fe | de/d/ cG |\
c>d ec | d>e ff | eg f/e/d |1 c3 G :|\
                          [2 c3 e/f/ ||
gg g/f/e | a3 d/e/ | ff f/e/d | g3 c/d/ |\
ee e/d/c | fa a2 | gg fB |1 c3 e/f/ :|\
                        [2 c3 ||
%%wordsfont Times-Italic 11pt
W:aus Simon Waschers TradArchiv

X: 1
T: Jan Mijne Man
M: 4/4
L: 1/8
R: reel
K: Amin
c2 (cB) A2 Ac | BAGB AG A2 | c2 (cB) AB c/2B/2A |[1 BAGB A4 :|[2 BAGB A2 (AB) ||
c2 (cd) e3 d | cBcd edcB | c2 (cd) e3 d | cBcd edcB |
c2 (cB) A2 Ac | BAGB AG A2 | c2 (cB) AB c/2B/2A | BAGB A4 |]

X: 1
T:Quand jetais chez mon pere
R:Bourree a 3 temps

X: 1
T: Flatworld
M: 3/4
L: 1/8
R: waltz
|:e de|"Am"ce Be Ae|"F"F2 AB cA|"Dm"f2 fe dc|"E#m"B3 e de|
"Am"ce Be Ae|"F"F2 fe dc|"G"BA Bd cB|1"Am"A3:|2"Am"A4 E2||
|:"Am"AB cA ag|"F"f2 fe dc|"G"Bc dB gf|"E#m"e2 ed cB|
"F"AB cA fe|"Dm"d2 dc BA|1"E#m"B2 Bd ^cd|B3 B =cB:|2"G"BA Bd cB|"Am"A3||


See discussion at AbcMusic-Talk

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on April 06, 2013, at 02:44 AM