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
Status:
Maintainer: Pm
Discussion: AbcMusic-Talk
Categories: Markup

(:music:) X: 1 T: Donald, Willie And His Dog M: 9/8 L: 1/8 R: slip jig K: Amix A2c Acc B2A|A2c Acc B3|A2c Acc B2A|c2A ABG A3:| B2e edc B2A|B2e edc B3|c2e edc B2A|c2A ABG A3:| A2c ABB c2B|A2c Acc B3|A2c ABB c2B|c2A ABG A3:| e2c dfd e2d|e2c d2c B3|e2c dfd e2d|c2A ABG A3:| (:musicend:)

Questions answered by this recipe

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

Description

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:)
...abc notation here...
(:musicend:)

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

Configuration:

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

include("cookbook/abcmusic.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';
include_once("cookbook/abcmusic.php");

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.

Notes

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:

Contributors

  • Pm

Sandbox

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

(:music:)
X:1
M:4/4
L:1/8
T:Speed the Plough
N:Simple version
Z:Steve Mansfield 1/2/2000
K:G
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 :|
(:musicend:)

(:music:) X:1 M:4/4 L:1/8 T:Speed the Plough N:Simple version Z:Steve Mansfield 1/2/2000 K:G 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 :| (:musicend:)

(:music:)
X: 61
T:Green grows the Rasses
R:air
S:Oswald's Collection of Curious Scot's Tunes Volume 1
N:pg.46
N: excerpt
Z:Hans Bracker 2005
M:C
L:1/8
K:G
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:|
(:musicend:)

(:music:) X: 61 T:Green grows the Rasses R:air S:Oswald's Collection of Curious Scot's Tunes Volume 1 N:pg.46 N: excerpt Z:Hans Bracker 2005 M:C L:1/8 K:G 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:| (:musicend:)

(:music:)
X: 1
T: Rolling In The Ryegrass
M: 4/4
L: 1/8
R: reel
K: Dmaj
|:A2AB AFDF|G2BG dGBG|ABAF DFAF|GBAG E2D2:|
|:ABde f2fd|g2ge fedB|ABde fefa|gfdf e2d2:|
(:musicend:)

(:music:) X: 1 T: Rolling In The Ryegrass M: 4/4 L: 1/8 R: reel K: Dmaj |:A2AB AFDF|G2BG dGBG|ABAF DFAF|GBAG E2D2:| |:ABde f2fd|g2ge fedB|ABde fefa|gfdf e2d2:| (:musicend:)

(:music:)
X: 1
T:Kuhhorn
S:Moench von Salzburg
K:F
M:3/8
L:1/8
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||
(:musicend:)

(:music:)
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 |]
(:musicend:)

(:music:) X: 1 T:Kuhhorn S:Moench von Salzburg K:F M:3/8 L:1/8 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|| (:musicend:)

(:music:) 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 |] (:musicend:)

(:music:)
X:1
T:Yellow Barber
M:2/4
L:1/8
S:Bruce Molsky
Z:AK/Fiddler’s Companion
K:D
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 :|
(:musicend:)

(:music:) X:1 T:Yellow Barber M:2/4 L:1/8 S:Bruce Molsky Z:AK/Fiddler’s Companion K:D 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 :| (:musicend:)

(:music:)
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
F:http://www.wprj.net/chor/index.php/Tunes/
C:Sammlung ABC-Tunes P.Ogay Jan 2008 
K:Dmin    % K minor
% midi settings
% http://www.wprj.net/chor/index.php/ABC/Instrumente
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] ||
(:musicend:)

(:music:) 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

1/8 = 120 % per minute

F:http://www.wprj.net/chor/index.php/Tunes/ C:Sammlung ABC-Tunes P.Ogay Jan 2008 K:Dmin % K minor % midi settings % http://www.wprj.net/chor/index.php/ABC/Instrumente V: S clef=treble name="Soprano" V: A clef=treble name="Alto" %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! %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] || (:musicend:)

(:music:)
X:1
T:Flatworld
R:waltz
C:Andy Cutting
D:Blowzabella, Vanilla
M:3/4
K:Am
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 |]
(:musicend:)
(:music:)
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:|

|:b2a2gf|e2e2fg|a2g2fe|d4ef|
g2f2ed|_d4=de|f2g2_a2|=a4ga|
b2c'2b2|e2e2fg|a2b2a2|d4ef|
g2f2ed|_d4=de|f2d2dc|d2 z z3:||
(:musicend:)
(:music:)
X: 1
T:Odenwaelder Blatschtanz
C:traditionell
A:Deutschland
%%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'
%%endtext
F:http://simonwascher.info/
Z:abc transcription Simon Wascher
M:2/4
L:1/8
F:http://simonwascher.info/TradArchiv_figuren-taenze/odenwaelder_blatsc_heijmans.abc	 2009-03-19 20:27:02 UT
K:C
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
(:musicend:)

(:music:) X:1 T:Flatworld R:waltz C:Andy Cutting D:Blowzabella, Vanilla M:3/4 K:Am 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 |]

(:musicend:) (:music:) X: 1 T: Horizonto M: 6/8 L: 1/8

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:|

|:b2a2gf|e2e2fg|a2g2fe|d4ef| g2f2ed|_d4=de|f2g2_a2|=a4ga| b2c'2b2|e2e2fg|a2b2a2|d4ef| g2f2ed|_d4=de|f2d2dc|d2 z z3:|| (:musicend:) (:music:) X: 1 T:Odenwaelder Blatschtanz C:traditionell Deutschland 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' endtext F:[(approve links) edit diff] Z:abc transcription Simon Wascher M:2/4 L:1/8 F:[(approve links) edit diff] 2009-03-19 20:27:02 UT K:C 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 (:musicend:)

(:music:)
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 |]
(:musicend:)

(:music:) 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 |] (:musicend:)

(:music:)
X: 1
T:Quand jetais chez mon pere
M:3/4
L:1/4
R:Bourree a 3 temps
O:France
A:Auvergne
K:C
C/2D/2|EEE|ECC/2D/2|EEE|D2D/2E/2|FFF|EEE/2E/2|DDD|C2G|
G2F|E2E|DDD|ECG|G2F|E2E|DDD|C2||
(:musicend:)

(:music:) X: 1 T:Quand jetais chez mon pere M:3/4 L:1/4 R:Bourree a 3 temps O:France Auvergne K:C C/2D/2|EEE|ECC/2D/2|EEE|D2D/2E/2|FFF|EEE/2E/2|DDD|C2G| G2F|E2E|DDD|ECG|G2F|E2E|DDD|C2|| (:musicend:)

(:music:) X: 1 T: Flatworld M: 3/4 L: 1/8 R: waltz K:Ain |: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|| (:musicend:)

(:music:)
X: 1
T: Flatworld
M: 3/4
L: 1/8
R: waltz
K:Ain
|: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||
(:musicend:)

(:music:) X: 1 T: Flatworld M: 3/4 L: 1/8 R: waltz K:Ain |: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|| (:musicend:)

Comments

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.