Materials Used in The Cognition of Basic Musical Structures

This page describes input files and scripts in our ftp site that can be used to reproduce the tests reported in Temperley's book The Cognition of Basic Musical Structures, available from MIT Press. (To visit a web page where you can hear midifiles of musical examples from the book, click here.)


The directory notefiles/kp contains quantized notefiles for the Kostka-Payne corpus, used in testing the meter program. The directory notefiles/kp-perf contains notefiles for performances on a MIDI keyboard of 16 of the excerpts from the Kostka-Payne corpus for solo piano, performed by a doctoral student in piano at Ohio State University. (midifiles/kp and midifiles/kp-perf contain midifiles for the corresponding excerpts.)

notefiles/misc/schum.kind1.q.notes provides a good example of the meter program's ability to handle a relatively large rubato (in m. 14); see Figure 2.6.

In notefiles/kp: chop.maz63-2.q.notes and schub.flusse.q.notes are analyzed with level 3 in incorrect phase (see Figure 2.10). With the two-pass system, they're analyzed correctly. This can be verified using the script "scripts/met-harm-twopass".

notefiles/misc/test1.q.notes: Eight middle C quarter notes, quarter = 500. The program assigns a tactus beat to each one. notefiles/misc/test2.q.notes: Eight middle C quarter notes, quarter = 1000. The program again assigns a tactus beat to each one. (See p. 52 of CBMS.)

notefiles/misc/beet.son14-2.small.q.notes - the first measures, plus pick-up, of Beethoven's Sonata Op. 14 No. 2, III (see Figure 8.3). The program analyzes this as duple at level 2 (i.e. with a quarter-note as opposed to a dotted-quarter note beat), correctly in my view, but it gets the phase wrong. notefiles/misc/beet.son14-2.medium.q.notes: this is the first eight measures of the same movement, which the program analyzes correctly, treating level 2 as a dotted-quarter level (as in the notation).

Three files contain segments of Mozart's Violin Sonata K. 526, I (see Figure 8.4):

mzt.amavnson.small.q.notes - the first three measures of the movement. The program gets the correct structure here at lower levels, but regards even-numbered rather than odd-numbered level 2 beats as strong.

mzt.amavnson.medium.q.notes - the first eight measures of the movement. The program now gets level 3 correct, even in the first three measures. This, then, is an example of the "garden-path" effect as applied to meter.

mzt.amavnson.q.notes - the first 19 measures of the movement.


The directory essen-notefiles contains quantized notefiles for a stratified sample of 65 songs from the Essen folksong database. The sample, which was compiled by Paul von Hippel, contains folksongs from a variety of regions in Europe. (Out of an original 80 songs in the sample, 15 were rejected because they had irregular or changing time signatures.) The tempi were set so that the tactus beat (e.g., quarter note in 2/4 or dotted quarter in 6/8) always equalled 600 ms. The directory essen-nbfiles contains "note-beat" files for this same corpus. Metrical structures were generated for the files, as dictated by the notation. (In cases where level 4 of the meter was not specified by the notation, a duple hypermeter was assumed with odd-numbered measures strong.)

This sample was used for testing the "grouper" program. The note-beat files contain markers of the phrase boundaries shown in the database. The grouper program can be run in such a way as to compare its own phrase boundaries with those specified in the input (see description of this in the grouper documentation). The shell script essen-script can be used to simulate the test. (Make sure "mode = 1" in the grouper parameter file.) If the script is run, all 65 folk melodies will be run through the grouper program, and both the correct phrase boundaries (as contained in the input files) and the program's phrase boundaries will be marked. Phrase boundaries found by the program are identified as "phrase"; false positives (boundaries identified by the program but not in the correct analyses) are identified also with "FP", false negatives (boundaries identified in the correct analyses but not by the program) with "FN". It will be found that the program finds 260 phrase boundaries, including 64 false positives. There are also 62 false negatives. The correct analyses contain 258 phrase boundaries.

The three Essen melodies shown in Figure 3.9 of the book are: A. czech35; B. italia08; C. czech01.

The directory ottman-notefiles contains notefiles for some melodies from Robert Ottman's book _Music for Sight Singing_, used in informal testing of the grouper program. The numbers in the filenames correspond to the numbers of the melodies in the book. (ottman-midi contains the corresponding midifiles; ottman-nbfiles contains the note-beat files.)


The directory nbfiles contains note-beat files for four Bach fugues used in testing the counterpoint program:

bach.cmafug - Book I C major Fugue
bach.cmifug - Book I C minor Fugue
bach.csmafug - Book I C# major Fugue
bach.csmifug - Book I C# minor Fugue

The program's output on these files is also referred to in several examples in chapter 4. Figure 4.17 refers to a portion of the analysis of the C major fugue, beginning at segment 149. Figure 4.18 refers to the opening of the C# minor fugue. Figure 4.22 refers to the portion of the C major fugue beginning at segment 183. Figure 4.23 refers to the portion of the C minor fugue beginning at segment 257.

The file mzt.fmason.q.nb is for the exposition of the first movement of Mozart's piano sonata K. 332; the file mzt.gmasq.nb is for the exposition of the first movement of Mozart's String Quartet K. 387; the file haydn.gmasq.nb is for the exposition of the first movement of Haydn's String Quartet Op. 76 No. 1. These files provide interesting and challenging tests for the counterpoint program, showing its strengths and weaknesses on classical-period music. They work well with the default parameters, with two exceptions: the "top_new_voice_penalty" and "top_blank_square_penalty" should be raised (20 is a good value for both) to help maintain the integrity of the top voice.

Figure 8.17 refers to an alternative contrapuntal analysis of the opening of the Bach C minor fugue, which somewhat resembles an analysis by Heinrich Schenker. This can be produced with the following changes in the default parameters: pitch_proximity_penalty = 4, blank_square_penalty = 10.

The file bach.csmafug.small.nb contains only the subject of the Bach C# major fugue, up to the low C# on the third beat of m. 2 (see Figure 8.19). If given only this portion, the program will treat it as a single line, as is correct. In the context of the entire piece, by contrast, the program treats the opening subject as two lines, as shown by the dotted lines in Figure 8.19.


The directory notefiles/kp contains the notefiles for the Kostka-Payne corpus. This corpus was used for testing the meter program (see CBMS, section 2.5). It was also used for testing the harmony program; in this case, the files had to be run through the meter program first to generate the metrical structure. (In cases where the meter program did not generate the correct metrical structure, this had to be corrected; the correct "nb-files" were then run directly into the harmonic program. The nb-files for these excerpts are found in the directory nbfiles.)

Section 8.2 of the book discusses Schumann's song "Aus meinen Thraenen spriessen", part of the Kostka-Payne corpus. (File schum.thranen.q.notes contains the entire song.) The program identifies the first chord as A major. The file schum.thranen.small.q.notes contains just the first four eighth-note beats of this song. In this case, I feel the first chord is heard as F# minor; the program, incorrectly, still considers it as A major. The file "schum.transition.q.notes" contains the last three measures of the previous song ("Im wundershoenen Monat Mai"), plus the first four eighth-beats of "Thraenen"; in this case the first chord is identified as F# minor (again correctly). (The file "schum.transition2.q.notes" contains the last three measures of "Monat" plus the entire first phrase of "Thranen"; in this case the first four beats of Thranen are analyzed F# A A F#.)

notefiles/misc/haydn.test1.q.notes: The first four measures of Haydn's Quartet Op. 64 No. 5, at a tempo of quarter = 500 (mm = 60). The harmonic program changes root on each of the dyads in the upper voices. (See Figure 6.12.)

notefiles/misc/haydn.test2.q.notes: The same excerpt, except with quarter = 125. Now the program analyzes the first two measures as a single chord-span of root D, the second two as a chord-span of root A.

notefiles/misc/schub.mm6.q.notes: This file can be run to simulate the analysis (and the numerical scores) in table 11.1. Run it with verbosity=2 to get the numerical data.


The directory kfiles/kp contains "key files" for the Kostka-Payne corpus; these were used to test the key program. These contain a list of beats, as well as a list of "TPC_Notes" (pitches with TPC values added by the harmonic program) and "Chords" (chord segments with roots). (The Chord statements are not necessary for testing purposes.) The default parameters were used on this test, except that different values of the change penalty were used and a value of 12.0 was found to be optimal. (The file kp-compare contains the key analyses for the Kostka-Payne excerpts given in Kostka's instructor's manual; our test was done by comparing the program's output against these analyses. Symbols with a slash, e.g. "C/G", indicate segments marked by Kostka as being "pivot segments" - in two keys simultaneously.)

The directory kfiles/wtc contains key files (like those described above for the Kostka-Payne corpus) for the subjects (themes) of the 48 fugues of Bach's Well-Tempered Clavier. The default parameters were used. (Different values of the change penalty were tried, and in this case the default value of 6.0 was found to be optimal.) The directory notefiles/wtc contains notefiles for these excerpts.

The shell script "scripts/kp-script" can be used to run the kostka-payne files through the key program. The script "scripts/wtc-script" can be used to run the WTC subjects.

The file kfiles/misc/bach.gmagav.q.k contains the harmony program's analysis of the Gavotte from Bach's French Suite No. 5; this can be run through the key program with the parameter "romnum" set to 1 to get a Roman numeral analysis. This is shown in Figure 7.10. (Set segment_beat_level to 4 to reproduce this analysis.) (Alternatively, this analysis can be reproduced directly from the notefile - notefiles/misc/bach.gmagav.q.notes - by running it through the meter, harmony, and key programs, using the met-harm-key script.)

The file chop.maz67-2.q.k also provides a demonstration of the importance of TPC information (i.e. spelling distinctions). If the parameter "npc_or_tpc_profile" is set to 0, the excerpt will be analyzed using an "NPC" profile, in which spelling distinctions are not recognized; in this case the excerpt will be analyzed, incorrectly, as being in Bb major. However, if npc_or_tpc_profile = 1 (the default), the excerpt will be analyzed in G minor.

The file kfiles/misc/bach.gmagav.q.k can also be run through the key program with the parameter "running" set to 1 to get a running analysis of the piece, as shown in Figure 8.7. Here again, set segment_beat_level = 4 to reproduce this analysis. The file kfiles/kp/chop.maz67-2.q.k, from the Kostka-Payne corpus, can also be run in this way (segment_beat_level = 3), to reproduce Figure 8.8.