/
perlin-score.py
46 lines (29 loc) · 1.05 KB
/
perlin-score.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from pippi import dsp
from noise import pnoise1
import seq
freqs = [200, 350, 500, 700, 1000, 1400, 2000, 3500]
bpm = 100.0
beat = int(dsp.bpm2frames(bpm) * 0.25)
nump = 100
def make_pulse(snd):
snd_len = dsp.flen(snd)
blip = dsp.cut(snd, 0, dsp.mstf(20))
blip = dsp.env(blip, 'sine')
blip = dsp.pad(blip, 0, snd_len - dsp.flen(blip))
return blip
def make_vary(index, length, freq):
def i(index, offset):
return ((index + offset) % nump) / float(nump)
pulsewidth = int(pnoise1(i(index, 100), 2) * (length / 2))
snd = dsp.tone(pulsewidth, freq, amp=pnoise1(i(index, 99), 3) * 0.5)
snd = dsp.env(snd, 'sine')
snd = dsp.pad(snd, 0, length - pulsewidth)
return snd
p = 'XxxXxxxXxXxxXxxxxXx'
beats = seq.toFrames(p, beat) * 100
layers = []
for l in range(2):
beats = dsp.rotate(beats, dsp.randint(50, 100))
layers += [ ''.join([ make_pulse(dsp.tone(length, freqs[i % len(freqs)], amp=dsp.rand(0.1, 0.5))) for i, length in enumerate(beats) ]) ]
out = dsp.mix(layers)
dsp.write(out, 'buchla-perlin')