gen_pitch_table: account for drop in higher frequency notes
This commit is contained in:
parent
882f164a24
commit
00d233ebe5
|
@ -8,11 +8,25 @@ pitch_C1 = 24
|
||||||
pitch_A4 = 69
|
pitch_A4 = 69
|
||||||
freq_A4 = 440
|
freq_A4 = 440
|
||||||
|
|
||||||
|
pitch_D5 = 74
|
||||||
|
pitch_F5 = 77
|
||||||
|
|
||||||
def pitch_to_freq(pitch):
|
def pitch_to_freq(pitch):
|
||||||
dist_A4 = pitch - pitch_A4
|
dist_A4 = pitch - pitch_A4
|
||||||
factor = pow(2, abs(dist_A4) / 12)
|
factor = pow(2, abs(dist_A4) / 12)
|
||||||
|
|
||||||
if dist_A4 > 0:
|
if dist_A4 > 0:
|
||||||
|
# Notes after A4 are about 20 cents flat
|
||||||
|
factor = factor * pow(2, 20 / 12 / 100)
|
||||||
|
|
||||||
|
if pitch >= pitch_D5:
|
||||||
|
# After D5 it's about another 10 cents flat
|
||||||
|
factor = factor * pow(2, 10 / 12 / 100)
|
||||||
|
|
||||||
|
if pitch >= pitch_F5:
|
||||||
|
# After F5 it's about another 10 cents flat
|
||||||
|
factor = factor * pow(2, 10 / 12 / 100)
|
||||||
|
|
||||||
return freq_A4 * factor
|
return freq_A4 * factor
|
||||||
else:
|
else:
|
||||||
return freq_A4 / factor
|
return freq_A4 / factor
|
||||||
|
|
Loading…
Reference in a new issue