- Added OP-1 compatibilty (as good as possible via "continue" command instead of start.
This commit is contained in:
parent
3ff162e780
commit
17a8a4b900
23
ashost.py
23
ashost.py
@ -46,7 +46,7 @@ def determine_host(devices_in: list) -> str:
|
|||||||
for port in inports:
|
for port in inports:
|
||||||
for message in port.iter_pending():
|
for message in port.iter_pending():
|
||||||
#print(f"Received message: ({port.name}, {message})")
|
#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
|
master = port.name
|
||||||
break
|
break
|
||||||
|
|
||||||
@ -83,31 +83,40 @@ def relay_midi_host_to_out(host_name, devices_out):
|
|||||||
recent_messages = []
|
recent_messages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print(reset)
|
last_stop_time = 0
|
||||||
|
debounce_delay = 0.05 # 50 milliseconds debounce time
|
||||||
|
|
||||||
while not reset:
|
while not reset:
|
||||||
# Process all pending messages
|
# Process all pending messages
|
||||||
for message in input_port.iter_pending():
|
for message in input_port.iter_pending():
|
||||||
read_message = str(message)
|
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:
|
for dev in output_ports:
|
||||||
dev.send(message)
|
dev.send(message)
|
||||||
recent_messages.append(read_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:
|
for dev in output_ports:
|
||||||
dev.send(message)
|
dev.send(message)
|
||||||
|
recent_messages.append(read_message)
|
||||||
|
#last_stop_time = current_time
|
||||||
|
#print(recent_messages)
|
||||||
|
|
||||||
# Keep only the last 3 messages
|
# Keep only the last 3 messages
|
||||||
if len(recent_messages) > 3:
|
if len(recent_messages) > 3:
|
||||||
recent_messages.pop(0)
|
recent_messages.pop(0)
|
||||||
|
|
||||||
# Check if the last 3 messages are all 'stop'
|
# 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)
|
print("Exiting", recent_messages)
|
||||||
recent_messages.clear()
|
recent_messages.clear()
|
||||||
|
|
||||||
reset = True
|
reset = True
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user