Initial commit
This commit is contained in:
commit
778fe31c38
35 changed files with 1849 additions and 0 deletions
29
loop.py
Normal file
29
loop.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import synthlib, math, sys
|
||||
|
||||
rate = 44100
|
||||
|
||||
# freq is multiplied by factor every period
|
||||
def sine(t, period, decay, factor, full_period):
|
||||
tt = (t + decay) % full_period
|
||||
if tt == 0:
|
||||
volume = 0
|
||||
elif tt <= full_period/2:
|
||||
volume = tt/(full_period/2)
|
||||
else:
|
||||
volume = (full_period-tt)/(full_period/2)
|
||||
freq_factor = 27.5*factor**(tt/period)
|
||||
return volume**2*math.sin(tt*freq_factor/rate*2*math.pi)
|
||||
|
||||
nb = 3
|
||||
|
||||
sound_encoder = synthlib.SoundEncoder(env={
|
||||
"sampling": rate,
|
||||
"signed": True,
|
||||
"verbose": False,
|
||||
"bits": 32,
|
||||
"msbfirst": True,
|
||||
"tempo": 130
|
||||
})
|
||||
for t in range(rate*16):
|
||||
sound_encoder.write_sample(sum([sine(t, rate, i*rate/nb*4, 2, rate*4) for i in range(nb)])/nb)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue