Notes on David Temperley s What s Key for Key? The Krumhansl-Schmuckler Key-Finding Algorithm Reconsidered By Carley Tanoue I. Intro A. Key is an essential aspect of Western music. 1. Key provides the framework whereby notes and harmonies are understood in tonal music. a) Perception of musical elements: (1) Perception of stability or appropriateness of pitches and chords (2) Perception of melody more easily remembered and more easily recognized. Perception of modulation: allows tonal music to convey a sense of long-range motion and drama.
B. Thesis 1. Point to some important problems with the key-profile algorithm of Carol Krumhansl and Mark Schmuckler and propose solutions. 2. He suggests that the key-profile model can provide a highly effective approach to key finding. 3. Also examines some alternative solutions to the keyfinding problem. 4. Using a computational approach, his goal is to model judgments of music theorists made reflectively and analytically. II. Basis: The Krumhansl-Schmuckler Key-Finding Algorithm A. Based on key profiles. Key profile: Vector of 12 values. B. Each of the 24 major and minor keys has its own key profile. C. The algorithm judges the key of a piece by correlating each key profile with the input vector of the piece 1. Input vector: A 12-valued vector, with each value representing the total duration of a pitch class in the piece. 2. The correlation value between the input vector and a given key-profile vector is calculated. 3. The key profile yielding the highest correlation gives the preferred key. D. Modifications: 1. Simplification in the way the key-profiles scores are calculated.
a) OLD: The current correlation formula uses a complex relationship and normalizes both vectors for their mean and variance. b) NEW: The same result by defining the key-profile score simply by the scalar product of the key-profile vector value and the input-vector value (_xy) Calculate the scores for all 24 keys and choose the highest score. E. Old Algorithm Tests 1. The algorithm was tested on the first four notes of each of the 48 preludes of Bach s Well-Tempered Clavier and on the first four notes of Shostakovich s and Chopin s preludes. a) The only test that provides clear data about the judgments of the basic algorithm for isolated segments of music. b) Unrealistic because of the pieces more complex tonal language. 2. The algorithm was given a series of notes sequences starting from the beginning of the piece until the algorithm chose the correct key, then the test was terminated. 3. The algorithm was tested on each measure of Bach s Prelude no. 2 in C minor and its judgments were compared to experts as to the key of each measure. F. New Test a) The context of each measure were taken into account in judging its key. 1. An easy and informal way of testing the algorithm is by giving it a piece, having it judge the key for many small segments of the piece in isolation, ex. measures, and comparing the results with our own judgments.
a) Each segment is to be regarded in isolation, without considering its context. G. Results of New Test 1. The algorithm makes incorrect judgments on 13 of 40 measures, a correct rate of 67.5%. H. Reason for Errors (analyzing the key-profile values) 1. Counterintuitive that diatonic degrees have only slightly higher values than chromatic keys. a) In minor: Flattened 7 th degree has a higher value than the leading tone. b) In Major: Leading tone has the lowest value of the seven diatonic degrees. 2. The dominant 7 th, which is usually taken as strong implications of the corresponding tonic key, is not so judged by the K-S algorithm. 3. It seems likely that some of the minor values are too high. Model chooses minor keys too often. I. Modification #1 New Key-Profile Values 1. Arrived at by a mixture of theoretical reasoning and trial and error, using a variety of different pieces for testing. 2. Improved performance on the Bach Courante. 3. New problem: Repetitions of notes affect the result, but do not appear to strongly tilt the key implications. J. Modification #2 Template Matching Approaches 1. K-S model a) Weighted-input/Weighted-key approach. 2. Longuet-Higgins and Steedman s approach
a) Flat-input/Flat-key approach. b) Processes a piece from left to right. c) Eliminates keys until it is left with only one. d) Each key has a flat key profile (1 = diatonic scale, 0 = chromatic pitch classes). e) Flat input vector (1 = present, 0 = absent). 3. L-H & S Problem #1 a) The algorithm has no way of judging passages in which all the pitches present are in more than one scale. (1) K-S model makes important distinctions between diatonic scale degrees.
b) Modification: Create a Flat-input/Weighted-key approach. K. Connections Between New approach and Other Theoretical Work 1. Fred Lerdahl Theory of tonal pitch space. a) Based on a basic space consisting of several levels, corresponding to the chromatic scale, diatonic scale, tonic triad, tonic and fifth, and tonic. b) Result: Modification of higher values for the 4 th, 7 th, and lower value for flat 7 th. Also equal values for 3 rd and 5 th diatonic degrees. 2. David Butler Rare-interval approach. a) Certain small pitch class sets have particular relevance for key finding, because of their rarity. b) Result: Modification of boosting 4 th and 7 th. (1) Effect: Sharpen the model. Lowers the similarity between each key s profile and the key profiles of its closest neighbors.
III. Modulation A. Definition: Vital part of tonal music. Tonicizations. B. Difficult: C. Result: 1. Problem: The division of the piece into key sections would allow to infer when the key is changing as well as the global key. a) Solution: Analyze in segments of a piece in insolation. b) Changes of key would emerge at places where one segment s key differed from that of the previous one. 2. Problem: Intuitively, key has inertia and would prefer to remain in one key unless there is strong and persistent evidence to change. a) Solution: Impose a penalty for choosing a key for one segment that differs from the key of the previous one. b) Optimizing the key-profile match for each segment while minimizing the number of key changes. 1. New Computational approach (Program): a) The score for an analysis is the sum of the keyprofile scores and change penalties for each segment. b) The program uses dynamic programming to find the highest-scoring possible analysis without having to generate them all. c) Parameters: (1) Change Penalty (2) Length of segments
(a) Problem: Because a flat input profile is being used for the individual segments, the combined input vectors for two segments are not the same as the input vector for a single larger segment containing both. (b) Solution: Adjust the key-profile scores by the length of the segments. IV. Preference Rule System vs. Procedural systems A. Procedural Systems: 1. ex. Longuet-Higgins and Steedman s model. 2. Systems that are more easily descrived in terms of the procedure they follow rather than the output they produce. 3. Holtzmann s model Searches a melody for certain features; first from the beginning and end of the melody and then at points in between. 4. Winograd s and Maxwell s Systems for harmonic analysis Roman numeral analysis, requiring inferring key information. 5. Vos and Van Geenen gathers weight for all keys, like a key-profile model, according to pitch and harmonic evidence. B. Preference Rule Systems (Temperley s Model): 1. Definition: A system that considers many possible analyses of a piece or passage, evaluates them by certain criteria and chooses the highest-scoring one. 2. Advantages: a) Handling of real-time processing. (1) The algorithm naturally handles the gardenpath effect: The phenomenon of revising one s hearing of a piece based on what happens afterwards.
(2) Insight into the kind of tonal analysis that goes on during listening. b) A numerical score for an analysis. (1) How much a piece satisfies the preference rules. (2) Key-fit scores. (a) Measure of the tonalness of pitch class sets. (b) Capture an important aspect of listening. (i) Rising and falling of musical tension of the phrase. (3) Problem: A segment containing more pitch classes will have a higher score. (a) Difficult to compare scores across segments. (4) Solution: Defining the key-fit score as the keyprofile scores divided by the number of pitch classes in the segment.
V. Testing the Model A. Input required for the program: 1. A list of notes, with a pitch, on-time and off-time for each note in the form of a MIDI file. 2. A list of segments, usually measures. B. Parameters: a) Rule: Given the tempo chosen, the segments used corresponded to the fastest level of metrical unit above 1 second. 1. Key Profiles: Not modified from last modification. 2. Change Penalty: Modified on each test, and the best performance value was used. C. Test #1: a) WHY: It seemed fair 1. Tested on 48 fugue subjects from Bach s Well- Tempered Clavier 2. Results: D. Test #2: a) On 42 of the 48 fugues, the system chose the correct key. b) 2 ties: _ point each, therefore score 43/48. c) There were four non-modulating themes where the program chose a single, incorrect, key. d) L-H & S System performed better, but has problems. 1. Tested on 46 excerpts from the Kostka-Payne theory textbook, Tonal Harmony by Stefan Kostka and Dorothy Payne.
E. Errors: 2. Results: a) Out of 896 segments, the program attained a score of 751: a rate of 83.8%. (1) Rate of 91.4% for examples related to diatonic chords. (2) Rate of 75.6% for examples related to chromatic sections. 1. Rate of modulation modulated too rarely or too often. a) Solution: Modify the change penalty. (1) The idea that this parameter has to be adjusted for different pieces is a flaw in the program. 2. Wrong chosen key due to harmony. a) Solution: Add a preference rule for tonic harmony and a primacy rule or implied tonic harmony. (1) For the program to use harmonic information, it would need to recover the harmonic structure of the input too complex and difficult. 3. Wrong chosen key due to the French sixth chords. a) Solution: Program needs inherent information on the conventional tonal implications of French 6 th Chords. (1) Harmonic information is needed where chromatic chords, whose tonal implications contradict the normal tonal implications of their pitch classes.
4. Key-Profile Refinement. a) Solution: Computational hill-climbing technique or by tallying of pitch classes in pieces for the basis of the key-profile values. VI. Spelling Distinctions A. Categories: 1. Tonal Pitch Classes (TPC s) 2. Neutral Pitch Classes (NPC s) B. Neutral Pitch Classes: 1. 12 pitches. Neutral model of pitch classes. C. Tonal Pitch Classes: 1. Spelling labels of pitch events are an important part of tonal perception. a) Labels can be inferred from context without relying on top-down key information, using preference rules. 2. There is a preference to spell events so that they are close together on the circle of fifths. 3. Possibility that spelling might be used as input to key determination. D. Results of testing with TPC instead of NPC 1. TCP version attained a score of 87.4% correct. 2. NPC version attained a score of 83.8% correct. 3. Spelling of key names themselves is musically important and the TPC-based model performs significantly better in choosing the correct spelling for each key.
VII. David Huron and Richard Parncutt: Huron-Parncutt algorithm. A. The key at each moment in a piece is determined by an input vectore of all the pitch events so far in the piece, weighted according to their recency. 1. Half-life curve. B. Implementation Test: 1. Used the Kostka-Payne test group. 2. Used the modified version of the key-profile values. 3. Used the same input format as in the previous tests. 4. Used the same segments as in the previous tests. a) Though Segmentation is not required. 5. NEW: For each segment, a global input vector was generated. C. Results: a) The sum of all the local input vectors for all the segments up to and including that segment, with each local vector weighted according to the exponential decay function. 1. With optimized half-life input: a) Scored correctly 628.5 out of 896 segments. b) Correct rate of 70.1%. D. Reasons for Disappointing performance. 1. Inability to backtrack. 2. No real defense against rapid modulation.
VIII. Conclusions A. Key-profile model 1. Successful solution to the key-finding problem B. Spelling, harmony and the Primacy factor appear to play a role in key finding.