Key-Finding

This week we will discuss:

A Brief History of Key-Finding

Key-finding has historically been closely tied with the computationalist approach to cognition. Modeling how a computer might infer the key of a piece can be an interesting problem that allows us to ask how we might be inferring keys.

For that reason, the correct answers are interesting, but not as interesting as the process and (sometimes) the mistakes.

Longuet-Higgins

One of the first key-finding algorithms was Longeut-Higgins' shape-matching algorithm (1976), which would use the process of elimination over the course of a piece. For example, if the first note was "C", D-major, A-major, E-major, F#-major, B-major, G-flat major, etc were all eliminated. If the next note was an B-natural, the choices were limited even further.

This method worked quite well with very tonal monophonic pieces, and surprisingly it was able to get all of the keys for Bach's Well-Tempered Clavier.

Overall, howver, it struggled with pieces that included functional chromaticism, and polyphony, in general.

Krumhansl-Schmuckler/Krumansl-Kessler

THe Krumhansl-Schmuckler model (1990) used a more experimental approach. It took the probe-tone ratings from an earlier experiment (Krumhansl and Kessler, 1982) to find the most likely tones in a piece.

In these probe tone experiments, participants would be presented with a cadence, followed by a tone. They would then rate the "goodness-of-fit" of each of these tones. This would generate a key-profile, that looked like this:

krumhansl-kessler

The key-finding algorithm would take the pitch count of each piece, and then run a correlation with this profile for each key. So if the total number of pitches against this key-profile provided a correlation of .80, and the others provided a correlation of .76, .74, etc. the highest number would be taken as the correct key. We might call this a correlational approach to key-finding.

The algorithms below use this approach, as well, but whereas this model uses the ratings from an experiment, the others use specific corpora.

Aarden-Essen

Bret Aarden (2003), for example, collected the pitch count of the entire Essen Folksong Collection (Schaffrath, 1995). His argument was that the "relationship between 'key-profile' and musical structure' is not as straightforwad as is often assumed." Real musical data, he argued, is more in line with what people have been exposed to.

Bellman-Budge

Bellman (2005) used a corpus curated by Helen Budge's stydy if chord frequencies of 18th and 19th century composers.(1943) It's a correlational model, but with Western Art Music.

Temperley-Kostka/Payne

Temperley (2001) curated the Kostka-Payne corpus, which included all of the musical examples from the Kostka-Payne textbook.

Craig Sapp's Simple Weightings

Sapp (2011) proposed a simple set of scale degree weights to be used with the Krumhansl-Schmuckler algorithm, con- sisting of only 2 (for tonic and dominant, 1 (for other diatonic tones), and 0 (for non-diatonic tones).

Despite the fact that it is technically using "less information", the algorithm outperfoms the Krumhansl-Schmuckler algorithm, and many others.

Results

Here is a table of results (from Albrecht and Shanahan, 2013):

key-finding-accuracy

A "Bag of Notes"?

The above stated methods are often collectively called a "bag-of-notes" approach. They put all pitches into a a big bag, not caring about context, or which tones move to another, or how they are placed metrically, and often that tonicizations, modulations, and middle sections just come out in the wash.

Keyscapes

Craig Sapp has implemented what he calls "keyscapes", which look at windows throughout the piece. Rather than looking at a single correlation score, it looks at the best possible option through the lens of smaller windows (i.e. 4 measures, 8-measures, etc.) This allows for a more thorough understanding of the tonal structure of the piece, and a visualization of these changes, like so:

sapp-keyscapes

Exercise #1

Exercise #2

Wednesday

Today's Plan

Windowed Graphs

On Monday, we discussed keys in terms of single answers, and briefly discussed Craig Sapp's notion of keyscapes. music21 implements something similar, which allows you to see the key is being determined throughout the piece.

In this version, it's a little bit more rigid Sapp's original triangle version, showing the key key determination of a certain section when the notes from a quarter note are included, half note, whole, measure, two measures, four measures, and the entire piece.

What key would this be in?

This is where it might not be ideal to use key-finding algorithms that return only a single key. At least, it's worth considering what data we are actually getting when we're returned a single key.

If you'll remember the Krumhansl key-profiles, you'll see that the distributions weren't quite as flat as this:

So this one isn't clear-cut at all. It'd be nice if we could get some sort of confidence rating, when we're given a key.

Looking at Confidence in the Chorales.

How would we look at the relative certainty of each key choice?

We could print the correlation coefficient next to every key choice.

Exercise #3

It would be really helpful to have a function that would provide the windowed keyscape of a certain piece, the score, and maybe the correlation coefficients of each key. What would that function look like?