From 9f00bf1b9c67d7347b04edd54724d3cf45a61454 Mon Sep 17 00:00:00 2001 From: bklronin Date: Wed, 26 Jun 2024 22:12:37 +0200 Subject: [PATCH] - Added throughport filter --- ashost.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/ashost.py b/ashost.py index fa3f8f9..69218db 100644 --- a/ashost.py +++ b/ashost.py @@ -19,6 +19,12 @@ def match_device_name(input_name, output_list): return None +def remove_through_ports(output_ports): + # Filter out ports containing "Through" in their names + filtered_ports = [port for port in output_ports if 'through' not in port.lower()] + + return filtered_ports + def determine_host(devices_in: list) -> str: master = None @@ -133,14 +139,17 @@ def main_run(): 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) + matching_output_device = match_device_name(midi_host_in, devices_out_filtered) + print("Filtering", matching_output_device) if matching_output_device: - devices_out.remove(matching_output_device) + devices_out_filtered.remove(matching_output_device) if midi_host_in: - relay_midi_host_to_out(midi_host_in, devices_out) + relay_midi_host_to_out(midi_host_in, devices_out_filtered) main_run()