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