From cfaef0fba300b95fa28975c237ae3179289d57bb Mon Sep 17 00:00:00 2001 From: Zoredh Date: Tue, 19 Mar 2019 23:51:15 +0100 Subject: [PATCH] Drumsets-Feature --- drum.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drum.py b/drum.py index efdaa6f..e1acc0a 100644 --- a/drum.py +++ b/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: