2023-05-22 11:21:46 -04:00
|
|
|
import array
|
|
|
|
from math import sin, pi
|
|
|
|
from synthio import LFO, MathOperation, lfo_tick
|
|
|
|
|
|
|
|
bend_out = array.array("h", [0, 32767])
|
|
|
|
bend_in = array.array("h", [32767, 0])
|
|
|
|
sweep = array.array("h", [-32767, 32767])
|
|
|
|
triangle = array.array("h", [0, 32767, 0, -32767])
|
|
|
|
sine = array.array("h", [int(32767 * sin(i * 2 * pi / 600)) for i in range(600)])
|
|
|
|
|
|
|
|
|
|
|
|
def print_result(*blocks):
|
|
|
|
for i in range(48000 / 256):
|
|
|
|
print(*lfo_tick(*blocks))
|
|
|
|
|
|
|
|
|
|
|
|
def mathop_test(kind):
|
|
|
|
v = LFO(sweep, rate=1, scale=2, once=True)
|
|
|
|
varying_a = kind(v, 2, -3)
|
|
|
|
varying_b = kind(-3, v, 2)
|
|
|
|
varying_c = kind(2, -3, v)
|
|
|
|
print_result(v, varying_a, varying_b, varying_c)
|
|
|
|
|
|
|
|
|
|
|
|
def lfo_test(sweep_input_name, **inputs):
|
2023-05-22 11:43:57 -04:00
|
|
|
inputs.setdefault("rate", 5)
|
|
|
|
t = LFO(bend_out, rate=1, once=True)
|
|
|
|
v = LFO(bend_out, rate=1.5, scale=2, once=True)
|
2023-05-22 11:21:46 -04:00
|
|
|
test = LFO(sine, **inputs)
|
2023-05-22 11:43:57 -04:00
|
|
|
setattr(test, sweep_input_name, v)
|
|
|
|
print_result(t, v, test)
|