Melody lab

Draw a melody on the grid and compare it with what a corpus of folksongs would have predicted at every step.

Melody grid
Presets:

Columns are eighth notes, rows the notes of the chosen scale. Click a cell to place a note; click the cell right after a note of the same pitch for a repeat, and once more for a held note.

The melody as drawn

Expectation from a corpus

Guess the next note:

The app draws a short phrase from the table, plays it, and asks which note comes next. Ten rounds.

More about this app

How it works

Much of a melody's effect comes from expectation: a listener who has grown up on a repertoire half-knows which note comes next, and feels it when the melody agrees or departs. The presets are written in C and follow the key selector; switch to chromatic to see all twelve rows.

The contour is pitch against time, and its name follows a simple rule. A range of two semitones or less is flat, and three or more changes of direction make a wave. Otherwise the notes are split into three parts in order: if the middle part averages at least a semitone above both ends the shape is an arch; if the last part is at least a semitone above the first it is ascending, below it descending; anything else is a wave.

The interval profile counts the distance from each note to the next in semitones, upward positive and downward negative, with the profile of the German folksong corpus in grey; a held note counts as one note. Steps are intervals of two semitones or less, repeats included, as in the chapter's count of the corpus.

Things to try

Draw a melody that is all leaps and watch the surprise climb, then smooth it into steps and watch it fall. Make a melody that avoids the tonic, or ends on the note just above it, and feel the lack of closure; then let the last note land on the tonic and hold it.

Place any note and look at the bars: the corpus most often predicts a repeat or a step, and after the leading note it predicts the tonic strongly. Play the game in another key and notice that the predictions follow the tonic, because the model, like a listener, hears relative pitch.