-
Notifications
You must be signed in to change notification settings - Fork 1
/
drum.py
58 lines (45 loc) · 1.76 KB
/
drum.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
53
54
55
56
57
58
import tools
import performer
import conductor
import random
import watchman
import section
current_drums = "H................ S................ K................"
# AMBIENT
# def gen_drum():
# template = [".",".",".",".",".",".",".",".",".",".",".",".",".",".",".","."]
# for i in xrange(int(performer.tsig * performer.timing)):
# if random.random() < watchman.activities["drums"] / 4:
# template = section.place_note(template)
# return "".join(template)
def gen_drumline(type):
# Rhythm
template = [".",".",".",".",".",".",".",".",".",".",".",".",".",".",".","."]
if type == "hats":
for i in xrange(int(performer.tsig * performer.timing)):
if i % (performer.timing) == 0:
template[i] = "x"
elif random.random() < watchman.activities["drums"]:
template[section.note_no()] = "x"
elif type == "snare":
for i in xrange(int(performer.tsig * performer.timing)):
if i % (performer.timing * 2) == 4:
template[i] = "x"
elif random.random() < watchman.activities["drums"]:
template[section.note_no()] = "x"
elif type == "kick":
for i in xrange(int(performer.tsig * performer.timing)):
if i % (performer.timing * 2) == 0:
template[i] = "x"
elif random.random() < watchman.activities["drums"]:
template[section.note_no()] = "x"
return "".join(template)
def gen():
global current_drums
hats = gen_drumline("hats")
snare = gen_drumline("snare")
kick = gen_drumline("kick")
current_drums = "H" + hats + " S" + snare + " K" + kick
def play():
while len(performer.drumlines) <= performer.buff:
performer.add_drums(current_drums)