Compare commits
1 Commits
8ad7f41d77
...
pi
Author | SHA1 | Date | |
---|---|---|---|
0c6ccb90af |
@@ -3,10 +3,10 @@
|
|||||||
{
|
{
|
||||||
"r": 255,
|
"r": 255,
|
||||||
"g": 0,
|
"g": 0,
|
||||||
"b": 0
|
"b": 255
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"r": 0,
|
"r": 255,
|
||||||
"g": 255,
|
"g": 255,
|
||||||
"b": 0
|
"b": 0
|
||||||
},
|
},
|
||||||
@@ -26,9 +26,9 @@
|
|||||||
"b": 255
|
"b": 255
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"r": 0,
|
"r": 255,
|
||||||
"g": 255,
|
"g": 255,
|
||||||
"b": 255
|
"b": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"r": 255,
|
"r": 255,
|
||||||
@@ -47,17 +47,17 @@
|
|||||||
],
|
],
|
||||||
"pattern_parameters": {
|
"pattern_parameters": {
|
||||||
"alternating": {
|
"alternating": {
|
||||||
"delay": 100,
|
"delay": 327,
|
||||||
"n1": 25,
|
"n1": 226,
|
||||||
"n2": 15,
|
"n2": 60,
|
||||||
"n3": 1,
|
"n3": 1,
|
||||||
"n4": 1
|
"n4": 1
|
||||||
},
|
},
|
||||||
"segmented_movement": {
|
"segmented_movement": {
|
||||||
"delay": 100,
|
"delay": 100,
|
||||||
"n1": 37,
|
"n1": 6,
|
||||||
"n2": 39,
|
"n2": 28,
|
||||||
"n3": 7,
|
"n3": 6,
|
||||||
"n4": 21
|
"n4": 21
|
||||||
},
|
},
|
||||||
"rd": {
|
"rd": {
|
||||||
@@ -82,9 +82,9 @@
|
|||||||
"n4": 1
|
"n4": 1
|
||||||
},
|
},
|
||||||
"radiate": {
|
"radiate": {
|
||||||
"delay": 3,
|
"delay": 1,
|
||||||
"n1": 32,
|
"n1": 43,
|
||||||
"n2": 10,
|
"n2": 11,
|
||||||
"n3": 1,
|
"n3": 1,
|
||||||
"n4": 1
|
"n4": 1
|
||||||
},
|
},
|
||||||
@@ -125,9 +125,9 @@
|
|||||||
},
|
},
|
||||||
"alternating_phase": {
|
"alternating_phase": {
|
||||||
"delay": 100,
|
"delay": 100,
|
||||||
"n1": 21,
|
"n1": 33,
|
||||||
"n2": 60,
|
"n2": 35,
|
||||||
"n3": 28,
|
"n3": 1,
|
||||||
"n4": 1
|
"n4": 1
|
||||||
},
|
},
|
||||||
"ap": {
|
"ap": {
|
||||||
@@ -138,6 +138,13 @@
|
|||||||
"n4": 1
|
"n4": 1
|
||||||
},
|
},
|
||||||
"alternating_pulse": {
|
"alternating_pulse": {
|
||||||
|
"delay": 100,
|
||||||
|
"n1": 90,
|
||||||
|
"n2": 78,
|
||||||
|
"n3": 1,
|
||||||
|
"n4": 1
|
||||||
|
},
|
||||||
|
"pulse": {
|
||||||
"delay": 100,
|
"delay": 100,
|
||||||
"n1": 10,
|
"n1": 10,
|
||||||
"n2": 10,
|
"n2": 10,
|
||||||
|
31
src/sound.py
31
src/sound.py
@@ -66,7 +66,7 @@ class SoundBeatDetector:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(f"Error getting audio device info for index {self.audioInputDeviceIndex}: {e}")
|
logging.error(f"Error getting audio device info for index {self.audioInputDeviceIndex}: {e}")
|
||||||
self.pa.terminate()
|
self.pa.terminate()
|
||||||
exit()
|
raise RuntimeError(f"Audio device {self.audioInputDeviceIndex} not available: {e}")
|
||||||
|
|
||||||
self.hopSize = self.bufferSize
|
self.hopSize = self.bufferSize
|
||||||
self.winSize = self.hopSize * self.windowSizeMultiple
|
self.winSize = self.hopSize * self.windowSizeMultiple
|
||||||
@@ -211,11 +211,26 @@ if __name__ == "__main__":
|
|||||||
MIDI_TCP_HOST = "127.0.0.1"
|
MIDI_TCP_HOST = "127.0.0.1"
|
||||||
MIDI_TCP_PORT = 65432
|
MIDI_TCP_PORT = 65432
|
||||||
|
|
||||||
sound_detector = SoundBeatDetector(MIDI_TCP_HOST, MIDI_TCP_PORT, input_device=args.input_device)
|
|
||||||
logging.info("Starting SoundBeatDetector...")
|
logging.info("Starting SoundBeatDetector...")
|
||||||
try:
|
while True:
|
||||||
sound_detector.start_stream()
|
try:
|
||||||
except KeyboardInterrupt:
|
sound_detector = SoundBeatDetector(MIDI_TCP_HOST, MIDI_TCP_PORT, input_device=args.input_device)
|
||||||
logging.info("\nProgram interrupted by user.")
|
sound_detector.start_stream()
|
||||||
except Exception as e:
|
break # If we get here, the stream ended normally
|
||||||
logging.error(f"An error occurred during main execution: {e}")
|
except KeyboardInterrupt:
|
||||||
|
logging.info("\nProgram interrupted by user.")
|
||||||
|
break
|
||||||
|
except RuntimeError as e:
|
||||||
|
if "Audio device" in str(e):
|
||||||
|
logging.error(f"Audio device error: {e}")
|
||||||
|
logging.info("Waiting 10 seconds before retrying...")
|
||||||
|
time.sleep(10)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
logging.error(f"Runtime error: {e}")
|
||||||
|
break
|
||||||
|
except Exception as e:
|
||||||
|
logging.error(f"An error occurred during main execution: {e}")
|
||||||
|
logging.info("Waiting 5 seconds before retrying...")
|
||||||
|
time.sleep(5)
|
||||||
|
continue
|
Reference in New Issue
Block a user