-
Notifications
You must be signed in to change notification settings - Fork 14
/
dir_drums.py
54 lines (43 loc) · 1.84 KB
/
dir_drums.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
46
47
48
49
50
51
52
import time
import random
import alles
# more refined and listenable version of bwhitman drums() demo in alles.py
# v0.2
def dir_drums(bpm=120, loops=-1, **kwargs):
alles.preset(13, osc=0, **kwargs) # sample bass drum
alles.preset(8, osc=3, **kwargs) # sample hat
alles.preset(9, osc=4, **kwargs) # sample cow
alles.preset(10, osc=5, **kwargs) # sample hi cow
alles.preset(11, osc=2, **kwargs) # sample snare
alles.preset(1, osc=7, **kwargs) # filter bass
[bass, snare, hat, cow, hicow, silent] = [1, 2, 4, 8, 16, 32]
pattern = [bass+hat, hat+hicow, bass+hat+snare, hat+cow, hat, hat+bass, snare+hat, hat]
basslines = [[50, 0, 0, 0, 50, 52, 51, 0],[56, 0, 0, 0, 56, 58, 57, 0],[57, 0, 0, 0, 57, 59, 58, 0],
[50, 50, 50, 50, 50, 50, 0, 50], [58, 58, 58, 58, 58, 58, 0, 58]]
next_sleepytime_in = 4
while (loops != 0):
loops = loops - 1
random.shuffle(pattern)
bassline = random.choice(basslines)
sleepytime = 1.0/(bpm*2.0/60)
for i,x in enumerate(pattern):
if(x & bass):
alles.send(osc=0, vel=4, **kwargs)
if(x & snare):
alles.send(osc=2, vel=1.5)
if(x & hat):
alles.send(osc=3, vel=1)
if(x & cow):
alles.send(osc=4, vel=1)
if(x & hicow):
alles.send(osc=5, vel=1)
if(bassline[i]>0):
alles.send(osc=7, vel=0.5, note=bassline[i]-12, **kwargs)
else:
alles.send(vel=0, osc=7, **kwargs)
if (next_sleepytime_in == 0):
sleepytime_multi = random.choice([[1.0,8], [0.5,4], [0.333,3], [0.25,4]])
sleepytime *= sleepytime_multi[0]
next_sleepytime_in = sleepytime_multi[1]
next_sleepytime_in -= 1
time.sleep(sleepytime)