Typesetting music

Recently I’ve been typesetting a little music. My notational needs are simple: mostly single melodic lines, occasional chords or multiple voices, and a score consisting of two or three staves. The music I typeset is baroque; this snippet of a trio sonata by Buxtehude would be typical of the complexity of the music I’m typsetting:

With Linux, and sticking to open-source or free typesetting software, there are three that I’ve used:

  1. GNU Lilypond, very mature software in active development since at least 2004, and with a large user base. It is designed to meet pretty much all notational needs, and as you can see by hunting around on its web page, can be used for scores both simple and complex. Its aim is to be software suitable for use by professionals.
  2. ABC notation goes back even further than Lilypond, to the early 1980s, when its initial creator, Chris Walshaw, was looking for ways of notating folk tunes easily. Since that time ABC has been extended to manage polyphonic music, and with the program abcm2ps developed by Jef Moine it can handle very complex music. A good page which pulls all the strands of ABC together, with examples, is provided by Guido Gonzato. The ABC standard is at version 2.2, and is defined here.
  3. MusixTeX uses the power of TeX to typeset music. The results are impressive, but the raw input is fiddly in the extreme. For this reason there are several pre-processors, of which PMX is the most full-featured, and M-Tx for lyrics.

All of these programs require the user to write out the music in ascii notation; thus the input is an ascii document which defines the music to be typeset. This provides a nice backwards compatibility: you can grab an ascii file created 10 or more years ago for any of these programs, and maybe doctor it a little to take advantage of the newer functionality.

A small example

As an experiment, I’m going to typeset the first eight bars of the the third movement of the “Variation Sonata on Bonny Jean of Aberdeen” by the Scottish composer Charles McLean (fl 1732). A “variation sonata” was a local invention: a sonata in multiple movements where each movement was a variation on a popular folk tune. The variation sonata was supposedly invented by another shadowy figure in 18th century Scottish music: Alexander Munro.

First, Lilypond:

\version "2.19.53"

\header{
  title = "Variation Sonata on Bonny Jean of Aberdeen"
  composer = \markup {\column {" " \large "Charles McLean"} " "}
}

\layout{
    indent = 25\mm
}

global = {
  \language english
}

allegroVln = \new Voice \relative c'' {
  \set Staff.instrumentName = #"Violin "
  \override Staff.InstrumentName.self-alignment-X = #RIGHT
  \time 4/4
  \key g \major
  \partial 4 b8 a | g4 b8 c d4 d,8 e | g4 d'8 c b4 a8 g | c8 g'4 c,8 b g'4 b,8 | a4 b8 g e4 b'8 a | 
  g4 b8 c d4 d,8 e | g4 b8 d g4 fs8 e | d g4 c,8 b g'4 b,8 | a g'4 fs8 g4 \bar ":.|.:"
}

allegroBass = \new Voice \relative c' {
  \set Staff.instrumentName = #"Bass "
  \override Staff.InstrumentName.self-alignment-X = #RIGHT
  \clef bass
  \key g \major
  \time 4/4
  \partial 4 r4 | g4 d g, b8 c | b4. a8 g4 g' | e c g' g, | d' b c a | b4. a8 g4 b8 c | 
  b4 g'8 fs e4 d8 c | b4 a g g' | d d, g \bar ":.|.:"
}

\score {
\new StaffGroup <<
    \new Staff << \global \allegroVln >>
    \new Staff << \global \allegroBass >>
  >>
  \header{
    piece = \markup{\fontsize #2 "III. Allegro"}
  }
}

This is the result:

Next, ABC, using the abcm2ps software to turn the file into a page of music:

X: 1
T: Variation Sonata on Bonny Jean of Aberdeen
C: Charles McLean
L: 1/4
K: G
M: 4/4
Q:"III Allegro"
%%score [vln | Bc]
V:vln clef=treble name=Violin bracket=2 space=+5pt
V:Bc clef=bass name=Bass
[V:vln]
B/G/ | AB/c/dD/E/| Gd/c/B A/G/ | c/gc/ B/gB/ | AB/G/EB/A/ | GB/c/dD/E/ | GB/d/gf/e/ |
d/gc/ B/gB/ | A/gf/g :|
[V:Bc]
z | G,D,G,,B,,/C,/ | B,,>A,,G,,G, | E,C,G,G,, | D,B,,C,A,, | B,,>A,,C,A,, |
B,,G,/F,/E,D,/C,/ | B,,A,,G,,G, | D,D,,G,, :|

with result:

Finally, MusixTeX with the PMX pre-processor:

% Charles McLean, Variation Sonata on Bonny Jean of Aberdeen
% PREAMBLE:
% nstaves ninstr mtrnuml mtrdenl mtrnump mtrdenp
     2      2       4       4       0       6
% npickup nkeys
     1      1
% npages nsystems musicsize fracindent
    1       2        16        .08
Bass
Violin
bt
./
% BODY:
% HEADER:
Tc
Charles McLean (fl. 1732)
Tt
Variation Sonata on Bonny Jean of Aberdeen
h
III. Allegro
Abec4
% Bars 1 - 4
r4 g43 d g- b8 c | b4.a g4 g+ | e c g+ g- | d+ b c a | /
[ b84 a ] g4 b8 c d4 d8- e | g4 d8+ c b4 a8 g | c8 g4+ c8- b g4+ b8- | a4 b8 g e4 b8+ a  /
% Bars 5 - 7
b4.a g b8 c | b4 g8+ f e4 d8 c | b4 a g g+ | /
g4 b8 c d4 d8- e | g4 b8 d g4 f8 e | d8 g4 c8- b g4+ b8- | /
% Last partial bar
m3400
d4 d- g Rr /
a8 g4+ f8 g4 Rr /

and its result:

A few remarks

For me, the use of a music notation system is dependent on two aspects: ease of use; and quality of output. I think all of these systems – at least, for my needs – are roughly comparable in their output. They all make sensible suggestions about layout and spacing, and as far as I can tell all three outputs look pretty good.

For ease of use, I found ABC easiest, followed by Lilypond, and last by PMX. In fact PMX does so much checking that it won’t compile and typeset your music until the file is set up correctly. As you see from the preamble, there are many factors which affect the result, and which can be set by the user. PMX works by a sort of coding system, where the length of a note is given by one digit: 0, 1, 2, 4, 8, 3, 6, 9 for breve, whole-note (or semibreve), half-note (minim), quarter note (crotchet), eighth, sixteenth, thirty-second and sixty-fourth note. PMX shares with Lilypond a relative pitch naming system, where a note is placed automatically in the same octave as the previous note (that is, within one fourth), and can be moved into a higher or lower octave by extra symbols: in PMX plus and minus (+ and -); in Lilypond apostrophe and comma (‘ and ,).

Lilypond’s learning curve is steeper than ABC, and if you read through the manual you’ll come up against “contexts”, “engravers” which are initially confusing. Once mastered, however, you have almost infinite control over the output.

PMX was also the only system where the notes in the first partial, or pick-up, bar of the violin part weren’t automatically beamed. Also PMX is very fussy about final partial bars (such as in my example) – it requires you to formally define a partial bar by what is called a “blind meter change”.

ABC, or rather abcm2ps, is the least fussy of all the systems. For example if you make a mistake in your notation, and end up with a bar that has the wrong number of beats in it, ABC will just go ahead and try to print it out, even if it looks like rubbish. This makes debugging simple, as you can immediately see where you’ve gone wrong. On the other hand, ABC doesn’t support relative pitch notation, although this can be alleviated by defining your octave, and placing notes within it.

So which is better? For my purposes, ABC is certainly good enough and is by far and away the simplest, although Lilypond has the edge in terms of the way it is structured, and for professional control over the output. (Although, in fairness, ABC also allows fine control over the output, at least for placement of notes and other elements.) I don’t think MusixTeX/PMX is in the running: it’s too fiddly, and there are easier ways of obtaining equivalent output.

Leave a Reply

Your email address will not be published. Required fields are marked *