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")
