aboutsummaryrefslogtreecommitdiffstats
path: root/tools/scripts/gen_pitch_table.py
blob: f83ff3ecaee039718ff6d28915ffd29d300e1984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import numpy as np

# We consider that samples are pitched with respect to C4 (60).
audio_freq = 18157
precision = 17
interval = 2 ** (1 / 12)

freqz = np.zeros(120)
freqz[60] = 261.6 / audio_freq
for i in range(61, 120):
    freqz[i] = freqz[i - 1] * interval

r = list(range(0, 60))
r.reverse()
for i in r:
    freqz[i] = freqz[i + 1] / interval

if (4294967295 - int(max(freqz) * 2 ** precision * 44100)) < 0:
    print("Not enough room in u32 for the given precision")
else:
    for f in freqz:
        print("{},".format(int(f * 2 ** precision)))