summaryrefslogtreecommitdiff
path: root/sw/Core/Src/tables.py
diff options
context:
space:
mode:
authorStijn Kuipers <stijnkuipers@gmail.com>2023-06-29 16:26:07 +0200
committerStijn Kuipers <stijnkuipers@gmail.com>2023-06-29 16:26:07 +0200
commitfb5a321dd7c2848128b04b306f3e1e59c87a3f70 (patch)
treea8ef6273f9f331ebb1971a9baf20a8c897955612 /sw/Core/Src/tables.py
parentbae7568fd4dd0676b370be8548c7ec95d6521ba1 (diff)
downloadplinky-fb5a321dd7c2848128b04b306f3e1e59c87a3f70.tar.gz
Initial Filedump
Tadaaa!!
Diffstat (limited to 'sw/Core/Src/tables.py')
-rwxr-xr-xsw/Core/Src/tables.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/sw/Core/Src/tables.py b/sw/Core/Src/tables.py
new file mode 100755
index 0000000..4b018d9
--- /dev/null
+++ b/sw/Core/Src/tables.py
@@ -0,0 +1,64 @@
+import math,random,struct,sys
+sys.stdout = open("tables.h", "w")
+
+s16 = lambda x: x if (x<32768) else x-65536
+print("// generated by tables.py")
+print("const static float lpf_ks[1025]={ ")
+for i in range(1025):
+ x=i/1024
+ if (x==0): x=1./65536.
+ x=x*x;
+ print("%.8ff" % (1.-math.pow(2,-0.00125/x)), end=',') # constants nearer 0 mean longer max decay
+ if (i%16==15): print(" ")
+print("};\n")
+
+print("const static float pitches[1025]={ // 10 octaves, 8th of a semitone steps")
+for i in range(1025):
+ x=(i-512)/(12*8)
+ print("%.8ff" % math.pow(2,x),end=',')
+ if (i%16==15): print(" ")
+print("};\n")
+
+
+#maxf=10000
+#imul=(maxf/32000)*math.pi /1024
+#print("const static float svfg[1025]={ // used for SVF g term")
+#for i in range(1025):
+# g=math.tan(i*imul)
+# print("%.8ff" % g,end=',')
+# if (i%16==15): print(" ")
+#print("};\n")
+#
+#print("const static float svfa1[1025]={ // used for SVF a1 term")
+#for i in range(1025):
+# g=math.tan(i*imul)
+# a1=1/(1+g*g)
+# print("%.8ff" % a1,end=',')
+# if (i%16==15): print(" ")
+#print("};\n")
+#
+#print("const static float svfa2[1025]={ // used for SVF a2 term")
+#for i in range(1025):
+# g=math.tan(i*imul)
+# a1=1/(1+g*g)
+# a2=g*a1
+# print("%.8ff" % a2,end=',')
+# if (i%16==15): print(" ")
+#print("};\n")
+
+print("const static short sigmoid[65536]={")
+for j in range(1024):
+ for i in range(64):
+ x=s16(i+j*64)
+ fx=x/32768.0*4.0
+ hy=math.tanh(fx)+math.tanh(fx*fx*0.0005); # bit of even distortion too
+ y=0.5*32500.*hy
+ print(int(y), end=',')
+ print(" ")
+print("};\n")
+
+print("const static u8 rndtab[65536]={")
+for j in range(1024):
+ for i in range(64): print(random.randint(0,255), end=",")
+ print(" ")
+print("};\n")