aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-05-28 21:02:50 +0200
committerBad Diode <bd@badd10de.dev>2021-05-28 21:02:50 +0200
commit9f3f6720e6ae92641d05b3126cf5b7ce6842d64d (patch)
tree03b6240002e6f6b2618cea42e4e7c61f716e2a0f
parent222596b93ec50c6503fef7632279d7e0d6a0985d (diff)
downloaduxngba-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.py22
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 @@
1import numpy as np
2
3# We consider that samples are pitched with respect to C4 (60).
4audio_freq = 18157
5precision = 17
6interval = 2 ** (1 / 12)
7
8freqz = np.zeros(120)
9freqz[60] = 261.6 / audio_freq
10for i in range(61, 120):
11 freqz[i] = freqz[i - 1] * interval
12
13r = list(range(0, 60))
14r.reverse()
15for i in r:
16 freqz[i] = freqz[i + 1] / interval
17
18if (4294967295 - int(max(freqz) * 2 ** precision * 44100)) < 0:
19 print("Not enough room in u32 for the given precision")
20else:
21 for f in freqz:
22 print("{},".format(int(f * 2 ** precision)))