2020-01-22 23:14:14 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import serial
|
|
|
|
import pygame
|
|
|
|
|
|
|
|
pygame.mixer.pre_init(buffer=32)
|
|
|
|
pygame.init()
|
|
|
|
pygame.mixer.quit()
|
|
|
|
pygame.mixer.init(buffer=32)
|
|
|
|
|
2020-06-29 22:11:07 +00:00
|
|
|
#SoundC = pygame.mixer.Sound('ogg/C3v16.ogg')
|
|
|
|
#SoundA = pygame.mixer.Sound('ogg/A3v16.ogg')
|
|
|
|
#SoundFF = pygame.mixer.Sound('ogg/F#3v16.ogg')
|
2022-01-15 12:24:15 +00:00
|
|
|
Sound = [pygame.mixer.Sound('guitar/guitar_C4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_D4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_E4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_F4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_G4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_A4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_H4_very-long_forte_normal.wav'),
|
|
|
|
pygame.mixer.Sound('guitar/guitar_C5_very-long_forte_normal.wav')
|
|
|
|
]
|
|
|
|
#SoundC = pygame.mixer.Sound('guitar/guitar_C4_very-long_forte_normal.wav')
|
|
|
|
#SoundD = pygame.mixer.Sound('guitar/guitar_D4_very-long_forte_normal.wav')
|
|
|
|
#SoundE = pygame.mixer.Sound('guitar/guitar_E4_very-long_forte_normal.wav')
|
|
|
|
#SoundF = pygame.mixer.Sound('guitar/guitar_F4_very-long_forte_normal.wav')
|
|
|
|
#SoundG = pygame.mixer.Sound('guitar/guitar_G4_very-long_forte_normal.wav')
|
|
|
|
#SoundA = pygame.mixer.Sound('guitar/guitar_A4_very-long_forte_normal.wav')
|
|
|
|
#SoundH = pygame.mixer.Sound('guitar/guitar_H4_very-long_forte_normal.wav')
|
|
|
|
#SoundC2 = pygame.mixer.Sound('guitar/guitar_C5_very-long_forte_normal.wav')
|
2020-01-22 23:14:14 +00:00
|
|
|
|
|
|
|
# port = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=.001)
|
|
|
|
port = serial.Serial("/dev/ttyS0", baudrate=115200)
|
2020-06-29 21:41:53 +00:00
|
|
|
# port = serial.Serial("/dev/ttyAMA0", baudrate=115200)
|
2020-01-22 23:14:14 +00:00
|
|
|
|
2020-06-29 21:41:53 +00:00
|
|
|
oldrcv = port.read()
|
2020-01-22 23:14:14 +00:00
|
|
|
while True:
|
|
|
|
# rcv decodieren
|
|
|
|
rcv = port.read()
|
2022-01-15 12:24:15 +00:00
|
|
|
i=0
|
2020-06-29 21:41:53 +00:00
|
|
|
# Zustand merken, und nur "neu" starten, wenn sich etwas von 0 auf 1 veraendert hat.
|
2022-01-15 12:24:15 +00:00
|
|
|
for cs in Sound:
|
|
|
|
if rcv[0] & ( 1 << i ) :
|
|
|
|
if not oldrcv[0] & ( 1 << i ):
|
|
|
|
print(i)
|
|
|
|
cs.stop()
|
|
|
|
cs.play()
|
|
|
|
i+=1
|
|
|
|
else:
|
|
|
|
cs.stop()
|
|
|
|
rcvstate0 = False
|
2020-01-22 23:14:14 +00:00
|
|
|
|
2020-06-29 21:41:53 +00:00
|
|
|
oldrcv = rcv
|