diff options
author | Bad Diode <bd@badd10de.dev> | 2021-05-28 21:02:50 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2021-05-28 21:02:50 +0200 |
commit | 9f3f6720e6ae92641d05b3126cf5b7ce6842d64d (patch) | |
tree | 03b6240002e6f6b2618cea42e4e7c61f716e2a0f | |
parent | 222596b93ec50c6503fef7632279d7e0d6a0985d (diff) | |
download | uxngba-9f3f6720e6ae92641d05b3126cf5b7ce6842d64d.tar.gz uxngba-9f3f6720e6ae92641d05b3126cf5b7ce6842d64d.zip |
Add script used to generate the pitch tables to the repo
-rw-r--r-- | tools/scripts/gen_pitch_table.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/scripts/gen_pitch_table.py b/tools/scripts/gen_pitch_table.py new file mode 100644 index 0000000..f83ff3e --- /dev/null +++ b/tools/scripts/gen_pitch_table.py | |||
@@ -0,0 +1,22 @@ | |||
1 | import numpy as np | ||
2 | |||
3 | # We consider that samples are pitched with respect to C4 (60). | ||
4 | audio_freq = 18157 | ||
5 | precision = 17 | ||
6 | interval = 2 ** (1 / 12) | ||
7 | |||
8 | freqz = np.zeros(120) | ||
9 | freqz[60] = 261.6 / audio_freq | ||
10 | for i in range(61, 120): | ||
11 | freqz[i] = freqz[i - 1] * interval | ||
12 | |||
13 | r = list(range(0, 60)) | ||
14 | r.reverse() | ||
15 | for i in r: | ||
16 | freqz[i] = freqz[i + 1] / interval | ||
17 | |||
18 | if (4294967295 - int(max(freqz) * 2 ** precision * 44100)) < 0: | ||
19 | print("Not enough room in u32 for the given precision") | ||
20 | else: | ||
21 | for f in freqz: | ||
22 | print("{},".format(int(f * 2 ** precision))) | ||