-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_key_tempering.py
49 lines (40 loc) · 1.52 KB
/
plot_key_tempering.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'''
Plotting the temperaments
'''
from temperament import *
import numpy as np
import matplotlib.pyplot as plt
circle_of_fifths = ['C', 'G', 'D', 'A', 'E', 'B', 'F#/Gb', 'C#/Db', 'G#/Eb', 'D#/Eb', 'A#/Bb', 'F']
order = [0, 7, 2, 9, 4, 11, 6, 1, 8, 3, 10, 5]
def key_tempering_for(tuning):
return np.vectorize(lambda i: key_tempering(tuning, MAJOR_DEGREES +
order[i], MAJOR_IDEALS))
def fifth_tempering_for(tuning):
correct_octaves = correct_octaves_for(tuning)
def fifth_tempering(i):
degrees = TONIC_FIFTH_DEGREES + order[i]
actual = combinatorial_difference(correct_octaves(degrees))
return mean_tempering(actual, TONIC_FIFTH_IDEAL)
return np.vectorize(fifth_tempering)
x = np.arange(0, 12, 1)
werck_iii = key_tempering_for(WERCK_III)(x)
werck_iv = key_tempering_for(WERCK_IV)(x)
meantone = key_tempering_for(MEANTONE)(x)
et = key_tempering_for(EQUAL_TEMPERAMENT)(x)
acs_i = key_tempering_for(ACS_I)(x)
acs_ii = key_tempering_for(ACS_II)(x)
plt.axis([0, 11, 0, 100])
plt.plot(x, werck_iii, 'r-<',
x, werck_iv, 'g->',
x, meantone, 'b-o',
x, et, 'k-x',
x, acs_i, 'y-d',
x, acs_ii, 'c-D')
# Set the axes markers
plt.xticks(x, circle_of_fifths)
plt.legend(['Werckmeister III', 'Werckmeister IV', 'Meantone', 'Equal Temperament', 'ACS I', 'ACS II'])
# Labels
plt.title('Figure 1: Mean tempering of diatonic triads')
plt.xlabel('Tonic of key', fontsize=14, color='black')
plt.ylabel('Mean tempering of diatonic triads', fontsize=14, color='black')
plt.show()