Open a device for input.
210{
212
215 "MIDI port {} already open", device_id);
216 return true;
217 }
218
222 "MIDI port {} not found", device_id);
223 return false;
224 }
225
226 try {
227 auto state = std::make_shared<MIDIPortState>();
228 state->info = it->second;
229 state->device_id = device_id;
231 state->midi_in = std::make_unique<RtMidiIn>();
232
233 state->midi_in->openPort(state->info.rtmidi_port_number, state->info.name);
235 state->midi_in->ignoreTypes(false, false, false);
236 state->active.store(true);
237
239
241 "Opened MIDI port {}: {}", device_id, state->info.name);
242
243 return true;
244
245 } catch (const RtMidiError& error) {
247 "Failed to open MIDI port {}: {}", it->second.name,
error.getMessage());
248 return false;
249 }
250}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
std::unordered_map< uint32_t, MIDIPortInfo > m_enumerated_devices
InputCallback m_input_callback
std::unordered_map< uint32_t, std::shared_ptr< MIDIPortState > > m_open_devices
static void rtmidi_callback(double timestamp, std::vector< unsigned char > *message, void *user_data)
std::mutex m_devices_mutex
@ 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.