MayaFlux 0.2.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

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

Private Member Functions

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

Static Private Member Functions

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

Private Attributes

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

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: