History

python/demos/demo_sink_create_woodblock.py: fix wavetable

Paul Brossier committed 12 years ago

Commit dedeffc1 parent 1e1a2c91 file · +6 −2Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_sink_create_woodblock.py+6−2
@@ -32,14 +32,18 @@ sinetone = zeros((duration,), dtype = 'float32') · 31 unmodified lines
3232 # compute sinetone at floating point period
3333 for i in range(duration):
3434 x = int((i % period) / float(period) * tablelen)
35− sinetone[i] = (sinetable[x] + sinetable[x+1]) / 2
35+ idx = int(x)
36+ frac = x - idx
37+ a = sinetable[idx]
38+ b = sinetable[idx + 1]
39+ sinetone[i] = a + frac * (b -a)
3640
3741 # apply some envelope
3842 float_ramp = arange(duration, dtype = 'float32')
3943 sinetone *= exp( - e * float_ramp / duration / decay)
4044 sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) )
4145
42−if 0:
46+if 1:
4347 import matplotlib.pyplot as plt
4448 plt.plot(sinetone)
4549 plt.show()

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t