Mehr Akkorde

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

59
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,27 +70,31 @@ 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))
if event.value > 0.2 or event.value < -0.2: print PRESSED
if PRESSED > 0: try:
CHORD = MAP[PRESSED] if event.value > 0.2 or event.value < -0.2:
print CHORD if PRESSED > 0:
if event.value > 0: CHORD = MAP[PRESSED]
i = 0 print CHORD
j = 1 if event.value > 0:
PLAY = CHORDS[CHORD] i = 0
else: j = 1
i = 5 PLAY = CHORDS[CHORD]
j = -1
PLAY = CHORDS[CHORD][::-1]
for NOTE in PLAY:
if NOTE > (-1):
print MOF[i]+NOTE
midi_out.note_on(MOF[i]+NOTE+CAPO,127)
clock.tick(50)
else: else:
#print "X" i = 5
pass j = -1
i += j PLAY = CHORDS[CHORD][::-1]
for NOTE in PLAY:
if NOTE > (-1):
print MOF[i]+NOTE
midi_out.note_on(MOF[i]+NOTE+CAPO,127)
#clock.tick(50)
else:
#print "X"
pass
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: