1 of 42

Keyscapes

https://bit.ly/music254-keyscapes

Craig Sapp

4 April 2024

Music 254 / CS 275b

Stanford University

2 of 42

Key Identification

3 of 42

Computational Key Identification

Pearson correlation:

Krumhansl-Schmuckler

key-finding algorithm:

(normalized dot product)

“The key is the case where the correlation is highest when comparing the measured pitch histogram with the key prototypes”

4 of 42

Computational Key Identification

5 of 42

Computational Key Identification

KS algorithm:

DFT:

dot product

“Key spectrum”: key is highest peak

“z-scores”

6 of 42

Prototype weights

7 of 42

Scape Plotting Domain

original

sequence:

← time axis →

start

end

← analysis window size →

small

large

“multi time resolution key spectrogram”

Problem: musical keys are not static in a composition

8 of 42

Scape Plotting Domain

9 of 42

Showing all segmentations of music

10 of 42

Beethoven Piano Sonata #5 mvmt 1

C minor

Eb major

11 of 42

Sonata No. 5 Internal Key Structure

Theme 1 (C minor):

Theme 2

(Eb major):

Theme 2 (recap):

Theme 2 (F major):

12 of 42

Other C-Minor Beethoven Sonatas

No. 5:

13 of 42

Beethoven sonatas

14 of 42

Sonata form

15 of 42

Rondo form

16 of 42

Chopin mazurkas

17 of 42

More Keyscapes

J.N. Hummel

18 of 42

Variability in key profile behaviors

Chopin prelude 28/1

19 of 42

Evaluating prototype weights

20 of 42

21 of 42

22 of 42

23 of 42

24 of 42

25 of 42

26 of 42

27 of 42

Twelvetone music (Webern op 27/1)

28 of 42

Petrus de Cruce (1200’s)

twelvetone

Antitonality

Weak tonality

29 of 42

Showing best match

30 of 42

Clarity plot (modulation boundaries)

31 of 42

Post-processing

32 of 42

Key boundaries

33 of 42

Removing unlikely key analyses

34 of 42

Filling in invalidated with secondary adjacent keys

35 of 42

Trimming regions

36 of 42

Tunneling

37 of 42

Interpreted

38 of 42

mkeyscape

http://extras.humdrum.org/man/mkeyscape

39 of 42

Using mkeyscape in the terminal

mkeyscape -nl --trim \

h://beethoven/sonatas/sonata01-1.krn \

| convert - sonata01-1.png

open sonata01-1.png

In MacOS, “open” is similar to double-clicking on file in Finder:

40 of 42

Keyscapes in VHV

41 of 42

POPC2 website

42 of 42

Implementation notes

P3

4 4

255

0 0 0 0 0 64 0 224 128 0 0 191

64 0 0 64 0 64 64 0 128 64 0 191

128 0 0 128 0 64 128 0 128 128 0 191

191 0 0 191 0 64 191 0 128 191 0 191

columns rows

levels per pixel (-1)

ASCII PPM image:

https://en.wikipedia.org/wiki/Netpbm

imagedemo -x 400 -y 200 > image.ppm