A tutorial on how to encode key signatures in **kern data.

Key signatures

Key signatures are represented by interpretations in the form *k[X], where X is a list of the accidentals in the order in which they are displayed in the key signature. Here a scale in C-sharp major and C-flat major, showing all of the accidentals in their proper order:

Key designation

The key of the music is different from the key signature. Indicate the key of the music by adding an interpretation in this form *X:, where X is a pitch name plus possible accidental, with lower-case pitch names indicating minor keys, and upper-case pitch names indicating major keys. For example, *C: means C major, and *a: means A minor (note that both have the key signature *k[] where there are no sharps or flats).

The key designation typical follows the key signature, or can appear on its own if the key changes but the key signature does not.

Note that the music in the last measure does not have a key signature change even though the music modulates to C-sharp minor.

The following codes can be appended to the key designation to indicate a particular mode:

code meaning example
dor dorian *d:dor
phr phrygian *e:phr
lyd lydian *F:lyd
mix mixolydian *G:mix
aeo aeolian *a:aeo
ion ionian *C:ion
loc locrian *b:loc

If the mode is closest to a minor key, then a lower-case letter will be used for the tonic note; otherwise, modes closer to major use an upper-case for the tonic.