- Added throughport filter

This commit is contained in:
bklronin 2024-06-26 22:15:29 +02:00
parent 9f00bf1b9c
commit 9e01adbce5
1 changed files with 8 additions and 7 deletions

View File

@ -19,9 +19,9 @@ def match_device_name(input_name, output_list):
return None
def remove_through_ports(output_ports):
def remove_through_ports(ports):
# Filter out ports containing "Through" in their names
filtered_ports = [port for port in output_ports if 'through' not in port.lower()]
filtered_ports = [port for port in ports if 'through' not in port.lower()]
return filtered_ports
@ -135,21 +135,22 @@ def main_run():
devices_out = mido.get_output_names()
print("Available MIDI input devices:", devices_in)
devices_in = remove_through_ports(devices_in)
devices_out = remove_through_ports(devices_out)
# Listen for devices that send start and return the host name
midi_host_in = determine_host(devices_in)
print(midi_host_in)
devices_out_filtered = remove_through_ports(devices_out)
# Find and remove the matching output device to avoid feedback
matching_output_device = match_device_name(midi_host_in, devices_out_filtered)
matching_output_device = match_device_name(midi_host_in, devices_out)
print("Filtering", matching_output_device)
if matching_output_device:
devices_out_filtered.remove(matching_output_device)
devices_out.remove(matching_output_device)
if midi_host_in:
relay_midi_host_to_out(midi_host_in, devices_out_filtered)
relay_midi_host_to_out(midi_host_in, devices_out)
main_run()