- Added OP-1 compatibilty (as good as possible via "continue" command instead of start.

This commit is contained in:
bklronin 2024-06-29 20:59:50 +02:00
parent 3ff162e780
commit 17a8a4b900

View File

@ -46,7 +46,7 @@ def determine_host(devices_in: list) -> str:
for port in inports:
for message in port.iter_pending():
#print(f"Received message: ({port.name}, {message})")
if 'start' in str(message):
if 'start' in str(message) or 'continue' in str(message):
master = port.name
break
@ -83,31 +83,40 @@ def relay_midi_host_to_out(host_name, devices_out):
recent_messages = []
try:
print(reset)
last_stop_time = 0
debounce_delay = 0.05 # 50 milliseconds debounce time
while not reset:
# Process all pending messages
for message in input_port.iter_pending():
read_message = str(message)
#print(read_message)
#current_time = time.time()
if 'start' in read_message or 'stop' in read_message:
if 'clock' in read_message:
for dev in output_ports:
dev.send(message)
if 'start' in read_message or 'continue' in read_message:
for dev in output_ports:
dev.send(message)
recent_messages.append(read_message)
elif 'clock' in read_message:
elif 'stop' in read_message:
#if current_time - last_stop_time > debounce_delay:
for dev in output_ports:
dev.send(message)
recent_messages.append(read_message)
#last_stop_time = current_time
#print(recent_messages)
# Keep only the last 3 messages
if len(recent_messages) > 3:
recent_messages.pop(0)
# Check if the last 3 messages are all 'stop'
if recent_messages[-3:] == ['stop time=0', 'stop time=0', 'stop time=0']:
if len(recent_messages) >= 3 and all(msg.startswith('stop') for msg in recent_messages[-3:]):
print("Exiting", recent_messages)
recent_messages.clear()
reset = True
break