2013-05-11

Hallelujah -- Adventures in LilyPond 3: Chords

The definition of global

By convention, LilyPond source files define the command \global, which is then used to insert, well, globally relevant constants at the appropriate places.  In practice, this is typically the key and time signature.  Because I made the basic mistake of writing the music in the key of G, I'll specify G major and rely on the \transpose command to correct it later.

global = {
    \key g \major
    \time 12/8
}


The \global command is then called in each of the \sopMusic, \altoMusic, and \bassMusic definitions.

LilyPond version

Another convention is to add the LilyPond version statement at the top of the source file.  In fact, LilyPond will warn you if you don't.  In theory, this will protect your work if you run a very old source file through the LilyPond compiler, by reverting to old interpretations if the current ones have changed since then.  This is in contrast to say, POV-Ray, where I'm told old source files simply stop working with newer versions of the program.

\version "2.16.2"

I've never had any version problems with LilyPond, but then I always do add the version statement (mostly because I hate warnings).

The chords

With those things out of the way, I could start writing the source for the lead sheet.  Chords first, the backbone of the song.

verseChords = \chordmode {
    g2. e:m g e:m
    c2. d g d
    g2. c4. d e2.:m c4. d
    d2. b:7 e:m e:m
}

refrChords = \chordmode {
    c2. c e:m e:m
    c2. c g d g
}


The command \chordmode tells LilyPond not to try to read the following as notes, which is the default input format, but as chords.  Each of the verses use the same chord sequence, as do the refrains, but I don't have to repeat the chords for each verse/refrain.  By the magic of LilyPond definitions I can define two commands that contain verse chords and refrain chords, and later use the commands three times each.  I believe it's hard to do that in a WYSIWYG music editor.

Most of the chords have a half-measure (6 eights) duration, or the equivalent of a dotted half-note (written as 2. after the chord name).  In a couple of cases the cords have a quarter-measure (3 eights) duration, written as 4. (a dotted quarternote), and in some places a chord lasts for a full measure.  I could have written that as chordname1., but instead I doubled the chords (e.g. e:m e:m).  There is a special syntax for repeating chords, e:m q, which I, for no good reason, don't use here.  I might in the future (it's an old syntax which was gone for a couple of versions and then reintroduced).

So, let's put the chord definitions together and transpose them to A:

theChords = \transpose g a {
    \set chordChanges = ##t

    \chordmode { s8 }
    \verseChords
    \refrChords

    \chordmode { d2. }
    \verseChords
    \refrChords

    \chordmode { d2. }
    \verseChords
    \refrChords
}


Note that I have some additional chords here: a spacer (invisible) chord for the pickup measure in the beginning of the song, and a half-measure D chord joining each refrain to the following verse.  Also, by setting the chordChanges property to true (##t), I instruct LilyPond to leave out chord names except where they change or at the beginning of a new line.  This is very handy and should be the default if you ask me.

Once \theChords is defined, all the chords for the song are put together in a neat package, ready to be dropped into the score.  They are also transposed from G major to A without any brainwork on my part (even I could go from G to A, but LilyPond will happily do transpositions that are much harder).

The lyrics mention four (I, IV, V, vi) of the five chords used as they occur in the song (the fifth one being a III7 chord that is used only once in each verse):

"It [I]goes like this: the [IV]fourth, the [V]fifth, the [vi]minor fall, the [IV]major [V]lift"

One of us, Mr Cohen.  One of us.

To be continued.

No comments:

Post a Comment