- Added wait for devices if none connected

This commit is contained in:
bklronin 2024-07-01 10:08:24 +02:00
parent 553892b034
commit 076f169c29

View File

@ -6,6 +6,19 @@ import os
import time
import mido
def check_devices() -> tuple:
# Retrieve the list of available input devices
devices_in = mido.get_input_names()
devices_out = mido.get_output_names()
devices_in = remove_through_ports(devices_in)
devices_out = remove_through_ports(devices_out)
print("Available MIDI input devices:", devices_in)
return devices_in, devices_out
def match_device_name(input_name, output_list):
# Function to match device names flexibly
for device in output_list:
@ -139,13 +152,13 @@ def relay_midi_host_to_out(host_name, devices_out):
main_run()
def main_run():
# Retrieve the list of available input devices
devices_in = mido.get_input_names()
devices_out = mido.get_output_names()
devices_in = remove_through_ports(devices_in)
devices_out = remove_through_ports(devices_out)
print("Available MIDI input devices:", devices_in)
devices_in, devices_out = check_devices()
# Check if at least one and one output device is connected
while len(devices_in) < 1 and len(devices_out) < 1:
time.sleep(3)
main_run()
base_frequency = 130 # Starting frequency in Hz
increment = 50 # Frequency increment for each device