MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Core::MIDIBackend Class Reference

RtMidi-based MIDI input backend. More...

#include <MIDIBackend.hpp>

+ Inheritance diagram for MayaFlux::Core::MIDIBackend:
+ Collaboration diagram for MayaFlux::Core::MIDIBackend:

Classes

struct  Config
 
struct  MIDIPortInfo
 
struct  MIDIPortState
 

Public Member Functions

void close_device (uint32_t device_id) override
 Close a previously opened device.
 
std::vector< InputDeviceInfoget_devices () const override
 Get list of available devices.
 
std::string get_name () const override
 Get backend name/identifier string.
 
std::vector< uint32_t > get_open_devices () const override
 Get list of currently open device IDs.
 
InputType get_type () const override
 Get backend type.
 
std::string get_version () const override
 Get backend version string.
 
bool initialize () override
 Initialize the input backend.
 
bool is_device_open (uint32_t device_id) const override
 Check if a device is currently open.
 
bool is_initialized () const override
 Check if backend is initialized.
 
bool is_running () const override
 Check if backend is actively listening.
 
 MIDIBackend ()
 
 MIDIBackend (Config config)
 
 MIDIBackend (const MIDIBackend &)=delete
 
 MIDIBackend (MIDIBackend &&)=delete
 
bool open_device (uint32_t device_id) override
 Open a device for input.
 
MIDIBackendoperator= (const MIDIBackend &)=delete
 
MIDIBackendoperator= (MIDIBackend &&)=delete
 
size_t refresh_devices () override
 Refresh the device list.
 
void set_device_callback (DeviceCallback callback) override
 Register callback for device connect/disconnect events.
 
void set_input_callback (InputCallback callback) override
 Register callback for input values.
 
void shutdown () override
 Shutdown and release all resources.
 
void start () override
 Start listening for input events.
 
void stop () override
 Stop listening for input events.
 
 ~MIDIBackend () override
 
- Public Member Functions inherited from MayaFlux::Core::IInputBackend
virtual ~IInputBackend ()=default
 

Private Member Functions

void create_virtual_port_if_enabled ()
 
uint32_t find_or_assign_device_id (unsigned int rtmidi_port)
 
void notify_device_change (const InputDeviceInfo &info, bool connected)
 
InputValue parse_midi_message (uint32_t device_id, const std::vector< unsigned char > &message) const
 
bool port_matches_filter (const std::string &port_name) const
 

Static Private Member Functions

static void rtmidi_callback (double timestamp, std::vector< unsigned char > *message, void *user_data)
 

Private Attributes

std::mutex m_callback_mutex
 
Config m_config
 
DeviceCallback m_device_callback
 
std::mutex m_devices_mutex
 
std::unordered_map< uint32_t, MIDIPortInfom_enumerated_devices
 
std::atomic< bool > m_initialized { false }
 
InputCallback m_input_callback
 
uint32_t m_next_device_id { 1 }
 
std::unordered_map< uint32_t, std::shared_ptr< MIDIPortState > > m_open_devices
 
std::atomic< bool > m_running { false }
 

Detailed Description

RtMidi-based MIDI input backend.

Provides MIDI input functionality using RtMidi library. Supports:

  • Multiple simultaneous MIDI input ports
  • Port filtering by name
  • Virtual MIDI port creation
  • Automatic port detection

Threading model:

  • RtMidi callbacks fire on RtMidi's internal threads
  • Callbacks push to InputManager's queue (thread-safe)
  • No separate polling thread needed (RtMidi is callback-driven)

Definition at line 24 of file MIDIBackend.hpp.


The documentation for this class was generated from the following files: