configurable wavetable files

This commit is contained in:
2026-02-07 18:08:38 -06:00
parent 8b4a09fc39
commit 18ff8dfc9f
6 changed files with 62 additions and 37 deletions

View File

@@ -1,5 +1,38 @@
import math
def process(phase):
WAVETABLE_FILE_NAME = "triangle"
def sine(phase):
return math.sin(phase)
def square(phase):
sample = 1.0
if(phase <= math.pi):
sample = -1
return sample
def saw(phase):
return (phase / math.pi) - 1.0
def triangle(phase):
sample = 0.0
if(phase <= math.pi/2.0):
sample = phase * 2.0/math.pi
elif(phase <= 3.0*math.pi/2.0):
sample = phase * (-2.0/math.pi) + 2.0
else:
sample = phase * 2.0/math.pi - 4.0
return sample
def sharkFin(phase):
return 1
def sphere(phase):
return 1
# process get called by generate_wavetable.py
# it calculates a single sample at a specified phase
# normalization is handled by generate_wavetable.py
def process(phase):
return triangle(phase)

View File

@@ -21,8 +21,9 @@ import example_wavetable
wavetableLength = 2048
def createFile():
print("creating file")
file = open("sine.wt", "wb")
filename = example_wavetable.WAVETABLE_FILE_NAME + ".wt"
print("creating file " + filename)
file = open(filename, "wb")
return file
def writeMetadata(file):