From 5a40f51085e2132bf91eccdd37e1a8dabe588efd Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Thu, 24 Jul 2025 10:34:13 +0200 Subject: Rough implementation of autoconnect --- daemon/src/device_connection.h | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'daemon/src/device_connection.h') diff --git a/daemon/src/device_connection.h b/daemon/src/device_connection.h index 17e354d..a2af8cc 100644 --- a/daemon/src/device_connection.h +++ b/daemon/src/device_connection.h @@ -41,39 +41,13 @@ struct Device_Connection : public Sender } void - open() - { - if (!open_port(midi_in, device_name)) - { - std::cerr << "Input port not found for device " << device_name << "\n"; - } - - if (!open_port(midi_out, device_name)) - { - std::cerr << "Output port not found for device " << device_name << "\n"; - } - } - - void - close() + reconnect(std::size_t port) { midi_in.closePort(); midi_out.closePort(); - } -private: - bool - open_port(RtMidi & midi, std::string const & name) - { - for (std::size_t i = 0; i < midi.getPortCount(); ++i) - { - if (midi.getPortName(i).contains(name)) - { - midi.openPort(i); - return true; - } - } - return false; + midi_in.openPort(port); + midi_out.openPort(port); } }; -- cgit v1.2.3