diff --git a/lighting_config.json b/lighting_config.json index 758d176..4dc8367 100644 --- a/lighting_config.json +++ b/lighting_config.json @@ -3,10 +3,10 @@ { "r": 255, "g": 0, - "b": 0 + "b": 255 }, { - "r": 0, + "r": 255, "g": 255, "b": 0 }, @@ -26,9 +26,9 @@ "b": 255 }, { - "r": 0, + "r": 255, "g": 255, - "b": 255 + "b": 0 }, { "r": 255, @@ -47,17 +47,17 @@ ], "pattern_parameters": { "alternating": { - "delay": 100, - "n1": 25, - "n2": 15, + "delay": 327, + "n1": 226, + "n2": 60, "n3": 1, "n4": 1 }, "segmented_movement": { "delay": 100, - "n1": 37, - "n2": 39, - "n3": 7, + "n1": 6, + "n2": 28, + "n3": 6, "n4": 21 }, "rd": { @@ -82,9 +82,9 @@ "n4": 1 }, "radiate": { - "delay": 3, - "n1": 32, - "n2": 10, + "delay": 1, + "n1": 43, + "n2": 11, "n3": 1, "n4": 1 }, @@ -125,9 +125,9 @@ }, "alternating_phase": { "delay": 100, - "n1": 21, - "n2": 60, - "n3": 28, + "n1": 33, + "n2": 35, + "n3": 1, "n4": 1 }, "ap": { @@ -138,6 +138,13 @@ "n4": 1 }, "alternating_pulse": { + "delay": 100, + "n1": 90, + "n2": 78, + "n3": 1, + "n4": 1 + }, + "pulse": { "delay": 100, "n1": 10, "n2": 10, diff --git a/src/sound.py b/src/sound.py index 664ecf5..98c7ca7 100644 --- a/src/sound.py +++ b/src/sound.py @@ -66,7 +66,7 @@ class SoundBeatDetector: except Exception as e: logging.error(f"Error getting audio device info for index {self.audioInputDeviceIndex}: {e}") self.pa.terminate() - exit() + raise RuntimeError(f"Audio device {self.audioInputDeviceIndex} not available: {e}") self.hopSize = self.bufferSize self.winSize = self.hopSize * self.windowSizeMultiple @@ -211,11 +211,26 @@ if __name__ == "__main__": MIDI_TCP_HOST = "127.0.0.1" MIDI_TCP_PORT = 65432 - sound_detector = SoundBeatDetector(MIDI_TCP_HOST, MIDI_TCP_PORT, input_device=args.input_device) logging.info("Starting SoundBeatDetector...") - try: - sound_detector.start_stream() - except KeyboardInterrupt: - logging.info("\nProgram interrupted by user.") - except Exception as e: - logging.error(f"An error occurred during main execution: {e}") \ No newline at end of file + while True: + try: + sound_detector = SoundBeatDetector(MIDI_TCP_HOST, MIDI_TCP_PORT, input_device=args.input_device) + sound_detector.start_stream() + break # If we get here, the stream ended normally + 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 \ No newline at end of file