Refresh the device list.
Re-enumerates available devices. May trigger device callbacks for newly connected or disconnected devices.
149{
151 return 0;
152 }
153
154 std::vector<InputDeviceInfo> newly_added_devices;
155
156 try {
157 RtMidiIn midi_in;
158 unsigned int port_count = midi_in.getPortCount();
159
160 {
162
163 for (unsigned int i = 0; i < port_count; ++i) {
164 std::string port_name = midi_in.getPortName(i);
165
167 continue;
168 }
169
171
172 MIDIPortInfo info {};
173 info.id = dev_id;
174 info.name = port_name;
176 info.is_connected = true;
177 info.is_input = true;
178 info.is_output = false;
179 info.port_number = static_cast<uint8_t>(i);
180 info.rtmidi_port_number = i;
181
183
185
186 if (is_new) {
187 newly_added_devices.push_back(info);
188 }
189 }
190 }
191
192 for (const auto& info : newly_added_devices) {
194 "MIDI port found: {}", info.name);
196 }
197
198 {
201 }
202 } catch (const RtMidiError& error) {
204 "Error enumerating MIDI ports: {}",
error.getMessage());
205 return 0;
206 }
207}
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
uint32_t find_or_assign_device_id(unsigned int rtmidi_port)
std::unordered_map< uint32_t, MIDIPortInfo > m_enumerated_devices
bool port_matches_filter(const std::string &port_name) const
std::atomic< bool > m_initialized
std::mutex m_devices_mutex
void notify_device_change(const InputDeviceInfo &info, bool connected)
@ MIDI
MIDI controllers and instruments.
@ InputBackend
Input device backend (HID, MIDI, OSC)
void error(Component component, Context context, std::source_location location, std::string_view message)
Log an error message and optionally throw an exception.
@ Core
Core engine, backend, subsystems.