From dedeffcb077ac7dbac6f54eb1a4dbdcfc1d98d28 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 20 Nov 2013 02:50:37 +0100 Subject: [PATCH] python/demos/demo_sink_create_woodblock.py: fix wavetable --- python/demos/demo_sink_create_woodblock.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/python/demos/demo_sink_create_woodblock.py b/python/demos/demo_sink_create_woodblock.py index 398c41e0..2c06a5fa 100755 --- a/python/demos/demo_sink_create_woodblock.py +++ b/python/demos/demo_sink_create_woodblock.py @@ -32,14 +32,18 @@ sinetone = zeros((duration,), dtype = 'float32') # compute sinetone at floating point period for i in range(duration): x = int((i % period) / float(period) * tablelen) - sinetone[i] = (sinetable[x] + sinetable[x+1]) / 2 + idx = int(x) + frac = x - idx + a = sinetable[idx] + b = sinetable[idx + 1] + sinetone[i] = a + frac * (b -a) # apply some envelope float_ramp = arange(duration, dtype = 'float32') sinetone *= exp( - e * float_ramp / duration / decay) sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) ) -if 0: +if 1: import matplotlib.pyplot as plt plt.plot(sinetone) plt.show() -- 2.11.0