Drumsets-Feature
This commit is contained in:
parent
985edcceac
commit
cfaef0fba3
1 changed files with 18 additions and 1 deletions
19
drum.py
19
drum.py
|
@ -15,11 +15,18 @@ JOYSTICKS = []
|
|||
# Verwandle die gedrueckten Buttons ueber Bits in eine Zahl (Button 0 und 1 gedrueckt waeren dann 2^0 + 2^1 = 3)
|
||||
PRESSED = 0
|
||||
|
||||
DRUMSETS = [[41,38,45,42,36,49]]
|
||||
DRUMSETS = [
|
||||
[41,38,45,42,36,49],
|
||||
[48,38,46,42,36,49],
|
||||
[43,38,47,49,36,51],
|
||||
[43,38,47,42,36,57]
|
||||
]
|
||||
|
||||
DRUMSET = 0
|
||||
|
||||
def proc_event(event,midi_out):
|
||||
global PRESSED
|
||||
global DRUMSET
|
||||
global VELOCITY
|
||||
"Parse and act upon event"
|
||||
if event.type == QUIT:
|
||||
|
@ -31,12 +38,14 @@ def proc_event(event,midi_out):
|
|||
# Bei analogen Joysticks erst ab einem Fuenftel reagieren
|
||||
if abs(event.value) > 0:
|
||||
VELOCITY = int(abs(event.value) * 127)
|
||||
#VELOCITY = 100
|
||||
else:
|
||||
VELOCITY = 100
|
||||
if PRESSED > 0:
|
||||
print PRESSED
|
||||
print VELOCITY
|
||||
NOTE = DRUMSETS[DRUMSET][PRESSED-1]
|
||||
print DRUMSET
|
||||
print NOTE
|
||||
midi_out.note_on(NOTE,VELOCITY,9)
|
||||
except:
|
||||
|
@ -45,6 +54,14 @@ def proc_event(event,midi_out):
|
|||
try:
|
||||
if event.button < 6:
|
||||
PRESSED = event.button + 1
|
||||
elif event.button == 13:
|
||||
DRUMSET = (DRUMSET - 1) % len(DRUMSETS)
|
||||
print DRUMSET
|
||||
elif event.button == 14:
|
||||
DRUMSET = (DRUMSET + 1) % len(DRUMSETS)
|
||||
print DRUMSET
|
||||
else:
|
||||
print len(DRUMSETS)
|
||||
except:
|
||||
pass
|
||||
elif event.type == JOYBUTTONUP:
|
||||
|
|
Loading…
Reference in a new issue