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
32# compute sinetone at floating point period32# compute sinetone at floating point period
33for i in range(duration):33for i in range(duration):
34 x = int((i % period) / float(period) * tablelen)34 x = int((i % period) / float(period) * tablelen)
35 sinetone[i] = (sinetable[x] + sinetable[x+1]) / 235 idx = int(x)
36 frac = x - idx
37 a = sinetable[idx]
38 b = sinetable[idx + 1]
39 sinetone[i] = a + frac * (b -a)
36 40
37# apply some envelope41# apply some envelope
38float_ramp = arange(duration, dtype = 'float32')42float_ramp = arange(duration, dtype = 'float32')
39sinetone *= exp( - e * float_ramp / duration / decay)43sinetone *= exp( - e * float_ramp / duration / decay)
40sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) )44sinetone[:attack] *= exp( e * ( float_ramp[:attack] / attack - 1 ) )
41 45
42if 0:46if 1:
43 import matplotlib.pyplot as plt47 import matplotlib.pyplot as plt
44 plt.plot(sinetone)48 plt.plot(sinetone)
45 plt.show()49 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