The Melisma Music Analyzer, Version 2.0

David Temperley

This program analyzes a piece of music (represented as a “note list”) and extracts certain kinds of structure from it.

Download the program here: polyph.zip

The first version of the Melisma system consisted of several separate components that extracted meter, phrase, stream, harmony, and key information. By contrast, version 2.0 is a single integrated program. The program identifies metrical, harmonic, and stream information. It also estimates the probability of the note pattern itself.

The metrical output is a grid of several levels of beats, corresponding to different rhythmic values. (Level 2 is the tactus or “main beat”; level 3 is a higher level, and levels 1 and 0 are lower levels.) The harmonic output is a series of chord segments labeled with roots. The stream output is a grouping of the notes into numbered streams.

The graphic output shows all three structures — the harmonic structure on the left, then the metrical grid, then the note pattern with each note assigned a number indicating its stream. Below is the output for the first four measures of Bach’s Minuet in G.

 1150 (  23)        G     x x x x . . . . . . . . . . . . .1. . . . . . . . . 2 . . . . . . . 
 1250 (  25)        G     x             .           .      |    .           . |         .     
 1350 (  27)        G     x x           .           .      |    .           . |         .     
 1450 (  29)        G     x             .           .      |    .           . |         .     
 1600 (  32)        G     x x x   . . . . . . . . . . . . .|. . . . . .2. . . . . . . . . . . 
 1700 (  34)        G     x             .           .      |    .      |    .           .     
 1800 (  36)        G     x x           .           .      |    .        2  .           .     
 1900 (  38)        G     x             .           .      |    .        |  .           .     
 2000 (  40)        G     x x x   . . . . . . . . . . . . . .1. . . . . . .2. . . . . . . . . 
 2100 (  42)        G     x             .           .        |  .          |.           .     
 2250 (  45)        G     x x           .           .        |  .           2           .     
 2350 (  47)        G     x             .           .        |  .           |           .     
 2450 (  49)        G     x x x x . . . . . . . . . . . . . . .1. . . . . . . 2 . . . . . . . 
 2550 (  51)        G     x             .           .          |.           . |         .     
 2650 (  53)        G     x x           .           .          |.           . |         .     
 2750 (  55)        G     x             .           .          |.           . |         .     
 2900 (  58)        G     x x x   . . . . . . . . . . . . . . .|. . . .2. . . . . . . . . . . 
 3000 (  60)        G     x             .           .          |.      |    .           .     
 3100 (  62)        G     x x           .           .          |.      |    .           .     
 3200 (  64)        G     x             .           .          |.      |    .           .     
 3300 (  66)        G     x x x   . . . . . . . . . . . . . . .|. . . .2. . . . . . . . . . . 
 3400 (  68)        G     x             .           .          |.      |    .           .     
 3500 (  70)        G     x x           .           .          |.      |    .           .     
 3600 (  72)        G     x             .           .          |.      |    .           .     
 3750 (  75)       C      x x x x . . . . . . . . . . . . . . . 1 . . . . . . . 2 . . . . . . 
 3850 (  77)       C      x             .           .           |           .   |       .     
 3950 (  79)       C      x x           .           .           |           .   |       .     
 4050 (  81)       C      x             .           .           |           .   |       .     
 4200 (  84)       C      x x x   . . . . . . . . . . . . . . . | . . . . . 2 . . . . . . . . 
 4300 (  86)       C      x             .           .           |           |           .     
 4400 (  88)       C      x x           .           .           |           . 2         .     
 4500 (  90)       C      x             .           .           |           . |         .     
 4650 (  93)       C      x x x   . . . . . . . . . . . . . . . | . . . . . . . 2 . . . . . . 
 4750 (  95)       C      x             .           .           |           .   |       .     
 4850 (  97)       C      x x           .           .           |           .     2     .     
 4950 (  99)       C      x             .           .           |           .     |     .     
 5050 ( 101)        G     x x x x . . . . . . . . . . . . . . .1. . . . . . . . . .2. . . . . 
 5150 ( 103)        G     x             .           .          |.           .      |    .     
 5250 ( 105)        G     x x           .           .          |.           .      |    .     
 5350 ( 107)        G     x             .           .          |.           .      |    .     
 5500 ( 110)        G     x x x   . . . . . . . . . . . . . . .|. . . .2. . . . . . . . . . . 
 5600 ( 112)        G     x             .           .          |.      |    .           .     
 5700 ( 114)        G     x x           .           .          |.      |    .           .     
 5800 ( 116)        G     x             .           .          |.      |    .           .     
 5950 ( 119)        G     x x x   . . . . . . . . . . . . . . .|. . . .2. . . . . . . . . . . 
 6050 ( 121)        G     x             .           .          |.      |    .           .     
 6150 ( 123)        G     x x           .           .          |.      |    .           .     
 6250 ( 125)        G     x             .           .          |.      |    .           .     
 6400 ( 128)        G     x x x x . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 

The required input to the program is a “note list”, a list of notes with an ontime and offtime (both in milliseconds) and pitch number (middle C = 60) for each note. Thus the input for the beginning of the Bach minuet looks like this:

Note 0 434 74
Note 0 869 55
Note 434 652 67
Note 652 869 69
Note 869 1086 71
Note 869 1304 57
Note 1086 1304 72
Note 1304 1739 74
Note 1304 2608 59
Note 1739 2173 67
Note 2173 2608 67

The program mftext (available at the Melisma 1.0 download site) can be used to convert midifiles to notelists.

For further information about the program and how it works, see David Temperley, “A Unified Probabilistic Model for Polyphonic Music Analysis,” in Journal of New Music Research, Vol. 38 No. 1 (2009), pp. 3-18. [PDF]

Compiling and Running the Program. The program is written in C and assumes a Unix platform (e.g. a terminal window on a Mac). Download the zipped file and un-compress it. Within the polyph/ directory, type “make” to compile the program. This will produce the binary file “polyph”.

To run the program, type

./polyph -v [verbosity] [input-file]

“verbosity” is an integer specifying the amount and kind of information that is output:

  • 0: Basic statistics about the analysis. Most important is the “Total final score”, which is the probability of the note pattern.
  • 1: Basic statistics plus the graphic output.
  • -1: Just basic statistics about the metrical structure: The average tactus interval (in milliseconds), the division of the tactus level (2 if duple, 3 if triple), the division of the upper level (2 if duple, 3 if triple), the number of “pick-up” notes (preceding the first tactus beat), and the “phase” of the upper level (0 if the first L2 beat is the first of an L3 “measure”, 1 if it’s the second, 2 if it’s the third).
  • -2: Just a series of “chord statements”, showing chord segments, each one with a start-time, end-time, and root. (Roots are shown on the “line of fifths”: Bb = 0, F = 1, C = 2, G = 3, D = 4, etc.)
    Chord 0 2600 3
    Chord 2600 3900 2
    Chord 3900 5250 3
    
  • -3: A series of beat statements, note statements, and chord statements:
    Beat 1150 3
    Beat 1250 0
    Beat 1350 1
    Beat 1450 0
    Beat 1600 2
    ...
    Note 1150 2000 55 1
    Note 1150 1600 74 2
    Note 1600 1800 67 2
    Note 1800 2000 69 2
    Note 2000 2450 57 1
    ...
    Chord 0 2600 3
    Chord 2600 3900 2
    Chord 3900 5250 3
    ...
    

    Beat statements have a time point and a level (2 = the tactus level, 1 = the level below, etc.). Note statements are as in the input (ontime, offtime, pitch) but quantized to “pips” (normally 50 msec segments), and with an integer at the end indicating the stream to which the note is assigned. Chord statements are as described above: ontime, offtime, and root (on the line of fifths, C = 2).

The default verbosity is 1.

The JNMR paper also reports a version of the program that analyzes a piece in a left-to-right fashion, one 1-second “chunk” at a time, and after processing a chunk, makes a “prediction” for the following chunk. This is not available here but can be obtained from the author on request (dtemperley@esm.rochester.edu).

Speeding it up. If you find the program is running too slowly, most likely this is because it is allowing too many streams. The maximum number of streams can be adjusted with max_voices in globals.c. The default is 5, which usually yields pretty fast performance; setting it lower will make the program even faster. A value of 5 limits the program to finding chords with a maximum of five notes; increasing the value will allow more simultaneous notes but may also slow the program down considerably.