Kommentare hinzugefügt und ausgemistet
This commit is contained in:
parent
5283b64651
commit
e8f305939f
1 changed files with 8 additions and 19 deletions
27
hero.py
27
hero.py
|
@ -1,5 +1,4 @@
|
|||
#!/usr/bin/env python
|
||||
import json
|
||||
import pygame
|
||||
import pygame.midi
|
||||
from os import environ
|
||||
|
@ -72,25 +71,27 @@ def proc_event(event,midi_out):
|
|||
print("axis %d value %0.3f" % (event.axis, event.value))
|
||||
print PRESSED
|
||||
try:
|
||||
# Bei analogen Joysticks erst ab einem Fuenftel reagieren
|
||||
if event.value > 0.2 or event.value < -0.2:
|
||||
if PRESSED > 0:
|
||||
CHORD = MAP[PRESSED]
|
||||
print CHORD
|
||||
# Nach unten ist > 0 Chordarray wird von links nach rechts gespielt
|
||||
if event.value > 0:
|
||||
i = 0
|
||||
j = 1
|
||||
PLAY = CHORDS[CHORD]
|
||||
# nach oben halt von rechts nach links
|
||||
else:
|
||||
i = 5
|
||||
j = -1
|
||||
PLAY = CHORDS[CHORD][::-1]
|
||||
# Spiele jede Note fuer die angeschlagene Saite des Akkords
|
||||
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:
|
||||
|
@ -111,20 +112,6 @@ def proc_event(event,midi_out):
|
|||
#print("PRESSED = %s" % PRESSED)
|
||||
except:
|
||||
pass
|
||||
'''
|
||||
elif event.type == JOYAXISMOTION:
|
||||
print("axis %d value %0.3f" % (event.axis, event.value))
|
||||
if event.value > 0.2 or event.value < -0.2:
|
||||
midi_out.note_on(40,127)
|
||||
elif event.type == JOYBUTTONDOWN:
|
||||
print("button %d down." % event.button)
|
||||
elif event.type == JOYBUTTONUP:
|
||||
print("button %d up." % event.button)
|
||||
elif event.type == JOYHATMOTION:
|
||||
print("hat motion.")
|
||||
else:
|
||||
print("hat event %s." % event.type)
|
||||
'''
|
||||
|
||||
def main():
|
||||
|
||||
|
@ -151,10 +138,12 @@ def main():
|
|||
JOYSTICKS.append(pygame.joystick.Joystick(0))
|
||||
JOYSTICKS[-1].init()
|
||||
print("Detected joystick '%s'" % JOYSTICKS[-1].get_name())
|
||||
while 1:
|
||||
try:
|
||||
|
||||
# 5 Millisekunden warten, bevor das Dingens hier weiterlaeuft
|
||||
clock.tick(50)
|
||||
|
||||
while 1:
|
||||
try:
|
||||
for event in pygame.event.get():
|
||||
proc_event(event,midi_out)
|
||||
except KeyboardInterrupt:
|
||||
|
|
Loading…
Reference in a new issue