A theme code is a way of representing the important notes at the beginning of a melody when searching for that melody.
Theme codes were created by Charles Gore and are used in a revised form by the Folk Archive Resource North East and the Traditional Tune Archive. I use them in a slightly more flexible way to represent melodies that are understood as sound rather than transcribed from printed notation (see below for more on the differences).
The notes represented in a theme code are determined by their pitch and their rhythm. Depending upon the rhythm, either 6 or 8 notes will be represented. Six notes are used for slip jigs, waltzes, and airs that are “in three”. Eight notes are used for all other tunes.
The notes in a theme code are the notes that fall on the beats of the music. If you tap your foot along with the melody, the notes are those that are played when you tap your foot, ignoring any notes that come between taps. If a note is held over more than one beat, that note is repeated in the theme code as if it were played on every beat. Pickup notes (notes played at the start of a tune before the first downbeat) are not included in the theme code.
Some tunes can be heard with either a faster beat or a slower beat. The melody search is designed to work regardless of which beat you hear.
The pitches of the notes are represented by numbers that do not depend upon the key of the tune, which means you will be able to find a tune even if you don't know what key it is normally played in or if the tune is played in different keys by different players.
The pitches of the notes are represented relative to the key or home note (tonic) of the tune, using 1 to represent the key note up to 7 for the seven notes of the (diatonic) scale. Think doh, re, mi etc. where 1 is doh, etc. If the notes extend beyond one octave, notes in the octave above the main octave are followed by H and notes in the octave below the main octave are followed by L. In very rare cases, notes in the next higher octave or the next lower octave may be needed; these are represented using T (higher) or F (lower), respectively.
Thus the scale looks like this:
...6F 7F 1L 2L 3L 4L 5L 6L 7L 1 2 3 4 5 6 7 1H 2H 3H 4H 5H 6H 7H 1T 2T 3T...
Many fiddle tunes have melodies that fit naturally using a particular range of notes as defined by this scale. Other tunes might be played in a high range or a low range. The melody search is designed to work regardless of which range you choose.
(Although I have used upper case letters in these examples as specified by Gore, lower case letters may also be used in a melody search.)
Accidentals can be represented in theme codes; however, accidentals are ignored by the melody search and so there is no point in specifying them.
To create a theme code, one must know how the melody relates to the home note (tonic) of the tune. The home note of a melody is often the last note of the melody, although there are exceptions (particularly pipe tunes) where the melody feels unresolved at the end. If you are working from printed notation, the tonic of the tune can usually be determined from the key signature. However, doing so requires knowing which scale or mode is used. For example, a key signature with no sharps or flats could represent C major, G mixolydian, A minor, or D dorian. Modern tune books generally specify the tonic and mode explicitly.
Tunes generally have more than one part (often each part is repeated) and usually the parts all have the same home note. If this is not the case, it is the home note of the first part of the tune that matters.
Comparison with the original
Theme codes were originally defined by Charles Gore as a way of representing printed musical notation. Some changes of interpretation were needed to use theme codes as a melody search pattern.
The original definition of theme code is based on time signatures. However, musical sounds do not come with time signatures and the choice of a time signature in part may represent an editorial choice for printed notation rather than a property of the music itself. Supporting search based on beats without regard to time signatures means that some tunes will match against multiple theme codes.
The original definition of theme code defines the main octave in terms of a specific home key. As melody searches are not based on key, it is necessary that some tunes match against multiple theme codes.