Music and Probability

In my book Music and Probability, I explore issues in music perception and cognition from a probabilistic perspective. I propose computational models for two basic cognitive processes, the perception of key and the perception of meter, using techniques of Bayesian probabilistic modeling. Drawing on my own research and surveying recent work by others, I explore a range of further issues in music and probability, including transcription, phrase perception, pattern perception, harmony, improvisation, and musical styles.

midifiles.zip – a zipped file of midifiles for the musical examples in the book

materials.zip – A zipped file with materials (code and data sets) related to the models and tests in the book

EXPLANATION OF MATERIALS

Source code

melprob7.c – the monophonic key-finding program.

mel-deform.c – takes a notelist and randomly deforms one of the notes in pitch or rhythm. (Used in error detection tests.)

pitch-gen3.c – used to generate random melodies.

ks-key.c – implements Krumhansl-Schmuckler key-finding algorithm.

lhs-key.c – implements Longuet-Higgins key-finding algorithm.

meter16.c – the probabilistic meter-finding program.

gen-add.c – generates a note-address file from a beat list.

compare-na.c – takes two note-address lists and compares them.

tally-na.c – takes a series of comparisons of note-address lists and combines them into a single score.

keyb.tar – the polyphonic key-finding program. This program requires several source files. Download the entire contents of the keyb directory and type “make” to compile. See the top of “main.c” for comments.

compare2.c – compares two sets of polyphonic (segmented) key analyses.

mftext.tar – converts a midifile into a “note list” and vice versa. See below for further information.

Datasets and Scripts

Many of the data files listed below are “notefiles” – in “notelist” format, “Note [ontime] [offtime] [pitch]”, where ontime and offtime are in milliseconds and pitch is an integer, middle C = 60.

essen-perf.tar – notefiles for the 65-song test corpus used for testing the monophonic key and meter programs.

wtc.tar – notefiles for the fugue subjects of the WTC.

cuddy-lunney-data – average expectedness values for 200 patterns in Cuddy & Lunney’s experiment (Cuddy LL & Lunney CA. Expectancies generated by melodic intervals: Perceptual judgments of melodic continuity. Perception & Psychophysics 1995, 57: 451-462). These are the averaged ratings across trained and untrained subjects.

5.3a.notes, 5.3b.notes, 5.3c.notes, 5.3d.notes – notefiles were used in expectation tests of the meter program: Figures 5.3A, B, C, and D. (Run these with verbosity =
-2.)

kp.tar – note-beat files for the Kostka-Payne corpus. (These have “TPCNote” rather than “Note” input; they also have “Chord” statements.) The file “kp-corpus-info” has the list of excerpts and other information about them.

Several other notefiles used for other tests of the polyphonic key program:

    pcsets-2.k – a bunch of pc sets. Run this through keyb/key with verbosity=3 to get information about ambiguity and tonalness (in book, Tables 7.3 and 7.5).

    chop.maz6-1.2.k – mm. 1-8 of Chopin Mazurka 6/1. Run this with verbosity=2 to get information about tonalness of each segment. (See fig. 7.7.)

    schum.pap.k – mm. 5-20 of Schumann Papillons, 1st mvt. Run this with verbosity=2 to get information about tonalness of each segment. (See fig. 7.9.)

essen-train-list – This is a list of the 6154 songs from the Essen corpus used to set the parameters for the monophonic key and meter programs. The songs themselves are not provided here; they are available in Kern format from CCARH.

essen-test-list – A list of the 65 songs from the Essen corpus used for testing the monophonic key and meter programs, along with their correct keys. Notelists of the songs are provided in essen-perf/.

kp-list – A list of the excerpts in the Kostka-Payne corpus, with information about them. This is the corpus used for testing the polyphonic key program. The excerpts are provided in kp/.

kp-npc-compare – the correct key analyses for the KP corpus. (Use the program compare2.c to compare these with output from a key-finding program.)

temperley-corpus-list – A list of the excerpts in the Temperley corpus, used in testing the polyphonic key program. The excerpts are not provided here.

Some Further information

Source Code

All source code materials are in C. See the top of each code file for instructions on how to compile and run each program. Unless otherwise indicated, compile each program by typing “cc -lm [program.c] -o [program]”. And then run it by typing “[program] [input-file]”. If flags can be used, they are placed after the program name, possibly with a number after them: if there’s a flag -x setting some parameter value, type “[program] -x [value] [input-file]”.

The “mftext” Program

The program mftext, written by Tim Thompson and modified by me and Daniel Sleator, converts a MIDI file into a “note list” and vice versa. This is the format required by the meter program and the monophonic key program. See “comments” in the mftext directory for further information.

One warning: A frequent problem with MIDI files is that “note off” events are often encoded as “on” events with velocity 0. The mftext program has an option for reading velocity-zero “on” events as “off” events; see mftext/comments.

The Note-Address System

You can evaluate a metrical model using the note-address system in the following way. (For more explanation, see Temperley, “An Evaluation System for Metrical Models”, Computer Music Journal 28/3, 28-44.)

1. It is recommended that you start by converting the output from your model into “note-beat list” format. A note list is statements of the form “Note [ontime] [offtime] [pitch]”; a beat list is statements of the form “Beat [time] [level]”. Not-beat lists can be generated using the probabilistic meter program; see instructions at the top of the code. (They can also be generated by the Melisma meter-finding program.)

2. Use the program gen-add to generate note address list from a note-beat list.

3. Use the program compare-na to compare your note-address list with the correct one.

4. Use the program tally-na (if desired) to take a series of outputs from compare-na and combine them.

All of these programs (gen-add, compare-na, tally-na) are available for download above.