This document describes the Krumhansl-Schmuckler key-finding algorithm. If you have music data that consists of note pitch and duration information, this algorithm can be used to assign an appropriate major or minor key to the music data.
For a set of (x, y) coordinates, their correlation coefficient is a number from -1 to +1 that indicates if the coordinates have a linear relationship. 0 indicates no linear relationship. +1 indicates a perfectly linear relationship where when one coordinate increases, the other also increases. -1 indicates a perfectly linear relationship where when one coordinate increases, the other decreases.
For the coordinates (x_{1}, y_{1}) to (x_{n}, y_{n}), the correlation coefficient R is
where x is the mean of the x coordinates and y is the mean of the y coordinates.
In the key-finding algorithm one value of the coordinates represents a profile of a major key or a minor key.
do | do# | re | re# | mi | fa | fa# | so | so# | la | la# | ti |
6.35 | 2.23 | 3.48 | 2.33 | 4.38 | 4.09 | 2.52 | 5.19 | 2.39 | 3.66 | 2.29 | 2.88 |
la | la# | ti | do | do# | re | re# | mi | fa | fa# | so | so# |
6.33 | 2.68 | 3.52 | 5.38 | 2.60 | 3.53 | 2.54 | 4.75 | 3.98 | 2.69 | 3.34 | 3.17 |
The other value of the coordinates is the total durations of each pitch class in the piece of music being analyzed.
C | C# | D | D# | E | F | F# | G | G# | A | A# | B |
432 | 231 | 0 | 405 | 12 | 316 | 4 | 126 | 612 | 0 | 191 | 1 |
The key-finding algorithm calculates a correlation coefficient for each possible major and minor key by pairing the pitch class values to the profile values for the key in question.
R = -0.00009 |
R = 0.54 |
R = -0.74 | · · · |
R = -0.20 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
R = 0.62 |
R = 0.09 |
R = -0.31 | · · · |
R = -0.72 |
The key with the highest correlation coefficient is used as the key for the piece.
G# major
R = 0.97 |
The key-finding method described above is called the Krumhansl-Schmuckler key-finding algorithm (by Carol L. Krumhansl and Mark A. Schmuckler). The profile numbers came from experiments done by Krumhansl and Edward J. Kessler. The experiments consisted of playing a set of context tones or chords, playing a probe tone, and asking a listener to rate how well the probe tone fit with the context. You can read about the experiments and the algorithm in Krumhansl's book Cognitive Foundations of Musical Pitch. (The experiments are described in Chapter 2. The key-finding algorithm is described in Chapter 4.) You may be able to read portions of the book on Google Books.
The key-finding algorithm can be used with alternative profiles for the major and minor key. Humdrum extras - keycor manpage describes the same key-finding algorithm and lists alternative profiles you can use. The profiles shown on that page are labeled with C major pitches in uppercase for the major profile and C minor pitches in lower case for the minor profile.
Home >
Articles > Key-finding algorithm |
Robert Hart |