Visualizations of Tonality
CCRMA Affiliates, 10 May 2001
Craig Stuart Sapp (craig@ccrma.stanford.edu)
Key determination algorithm
Pitch Space
Basic Pitch Space   Earliest know use
of this configuration is by Leonhard Euler, 18th century
(*) 
Essential Properties  
 Minor 3rds at +45° angle
 Major 3rds at 45° angle
 All reasonable possible enharmonic spellings present
(e.g.: C#/Db/B##)

Compact Triads  
 Major and Minor triads in most compact spatial configuration.

Interval Space with root on C  
 Treating C as the root, organize other pitches with their
relative significance to a chord with a root on C.
(35 total pitches).

Relative Interval Space  
 Generalized intervals organized with respect to a hypothetical
root. (35 possible intervals, octave transposed)
 Horizontal axis scaled by factor alpha.
 alpha = 0.578 gives equal distance for M3 and P5.

Sample Graphical Determination of Root
Sample Music  
 C minor triad in second inversion.
 Root is on weak metrical position

C test root  
 Smallest sum of interval vectors  therefore assumed to be most
likely root.

Eb test root  

G test root  

B test root  
 Largest sum of inverval vectors  worst possible root
of 4 given hypothetical roots.

Rhythmic Weightings
 Duration scaling
 Long notes scaled away from root
 if note was
far from root originally, then the pitch is moved very
far from root.
 If note was close to root, then still not too far away.
 Short notes scaled towards root
 Nonharmonic notes are usually resolved in the chord, so
bringing these notes closer to the root is reasonable.
 Metric scaling
 Analygous to duration scaling
 Strong metrically attacked notes scaled away from root
 Weak metrically attacked notes scaled towards root
4/4 Meter Metric Levels  

Samples root scores for above musical example
C 10.87
E 16.90
G 17.45
A 18.55
A 18.97
F 23.13
E 24.80
C 26.59
F 27.70
F# 28.04
B 29.44
D 30.34
D 30.50
C# 33.13
B 36.14
A 36.23
D 37.27
D# 37.49
G# 37.77
B 39.64


A# 42.44
G 43.99
E# 46.32
B# 46.49
G 50.19
E 52.74
C 62.69
F## 1866.
C## 1871.
G## 1871.
X 2124.
F 2125.
X 2134.
X 2144.
D## 4207.
X 5771.
X 6026.
B## 6030.
E## 6034.
A## 7844.

Basic Algorithm Calculations
@vectorx = ( 0, 7, 7, 1000, 4, 4, 4, 4, 4, 1000, 8, 1, 1, 8, 8, 5, 5,
5, 5, 5, 1000, 9, 2, 2, 2, 9, 1000, 6, 6, 6, 6, 6, 1000, 3,
3, 3, 3, 10, 7, 7 );
@vectory = ( 0, 2, 4, 1000, 4, 2, 0, 2, 4, 1000, 3, 1, 1, 3, 5, 5,
3, 1, 1, 3, 1000, 4, 2, 0, 2, 4, 1000, 4, 2, 0, 2, 4,
1000, 3, 1, 1, 3, 5, 4, 2 );
$delta = 4;
$lambda = 3;
$alpha = 0.65;
For every hypothetical root,
measure the distance to all input notes.
Choose the hypothetical root with the lowest distance score as the
most likely root.
sub analysis {
my $count = @pitch;
my @analysis;
for ($i=0; $i<40; $i++) {
$asum = 0.0; $bsum = 0.0; $dsum = 0.0; $lsum = 0.0;
for ($j=0; $j<$count; $j++) {
$p = ($pitch[$j]  $i + 40) % 40;
$ipn = sqrt($alpha * $alpha * $vectorx[$p] * $vectorx[$p] +
$vectory[$p] * $vectory[$p]);
$asum += $ipn * ($delta + log($duration[$j]));
$bsum += $ipn * ($lambda + log($level[$j]));
}
$analysis[$i] = ($asum + $bsum)/$count;
}
return @analysis;
}