Mehr Akkorde

This commit is contained in:
Zoredh 2019-02-06 21:00:45 +01:00
parent 1dd5235944
commit 5283b64651

21
hero.py
View file

@ -41,10 +41,15 @@ CHORDS = {
} }
MAP = { MAP = {
1:"C", 16:"G",
2:"D", 64:"Em",
4:"Em", 128:"C",
8:"G" 32:"D",
4:"Am",
80:"F",
192:"E",
160:"B",
36:"A"
} }
# Hilfsfunktionen fuer die Bit-Manipulation (PRESSED) # Hilfsfunktionen fuer die Bit-Manipulation (PRESSED)
@ -65,6 +70,8 @@ def proc_event(event,midi_out):
exit(0) exit(0)
elif event.type == JOYAXISMOTION: elif event.type == JOYAXISMOTION:
print("axis %d value %0.3f" % (event.axis, event.value)) print("axis %d value %0.3f" % (event.axis, event.value))
print PRESSED
try:
if event.value > 0.2 or event.value < -0.2: if event.value > 0.2 or event.value < -0.2:
if PRESSED > 0: if PRESSED > 0:
CHORD = MAP[PRESSED] CHORD = MAP[PRESSED]
@ -81,11 +88,13 @@ def proc_event(event,midi_out):
if NOTE > (-1): if NOTE > (-1):
print MOF[i]+NOTE print MOF[i]+NOTE
midi_out.note_on(MOF[i]+NOTE+CAPO,127) midi_out.note_on(MOF[i]+NOTE+CAPO,127)
clock.tick(50) #clock.tick(50)
else: else:
#print "X" #print "X"
pass pass
i += j i += j
except:
pass
elif event.type == JOYBUTTONDOWN: elif event.type == JOYBUTTONDOWN:
try: try:
#print("button %d down." % event.button) #print("button %d down." % event.button)
@ -145,7 +154,7 @@ def main():
while 1: while 1:
try: try:
# 5 Millisekunden warten, bevor das Dingens hier weiterlaeuft # 5 Millisekunden warten, bevor das Dingens hier weiterlaeuft
clock.tick(5) clock.tick(50)
for event in pygame.event.get(): for event in pygame.event.get():
proc_event(event,midi_out) proc_event(event,midi_out)
except KeyboardInterrupt: except KeyboardInterrupt: