-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drums.py
44 lines (32 loc) · 860 Bytes
/
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
from music import *
import time
class Drums:
CHANNEL = 9
def __init__(self):
self.beatNumber = 0
self.beat = None
def startBeat(self,beat,tempo):
beat()
if self.beat is not None:
self.beat.stop()
self.beat = Timer(tempo/4.0,beat)
self.beat.start()
#Plays beats that have different drum sound for beats 1 and 4
def classicBeat(self):
if self.beatNumber == 0:
Play.noteOn(45,127,self.CHANNEL)
Play.noteOn(BDR,127,self.CHANNEL)
Play.noteOn(ABD,127,self.CHANNEL)
elif self.beatNumber == 3:
Play.noteOn(44,127,self.CHANNEL)
else:
Play.noteOn(BDR,127,self.CHANNEL)
self.beatNumber+=1
self.beatNumber= self.beatNumber%4
def electroBeat(self):
if self.beatNumber == 0:
Play.noteOn(40,127,self.CHANNEL)
else:
Play.noteOn(39,127,self.CHANNEL)
self.beatNumber+=1
self.beatNumber= self.beatNumber%4