Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::IHardwareMidiInterface Class Referenceabstract

Abstraction for hardware MIDI interface. More...

#include <src/dsp/hardware_midi_interface.h>

Inheritance diagram for zrythm::dsp::IHardwareMidiInterface:

Public Types

using BufferMap
using DeviceChangeCallback = std::function<void ()>

Public Member Functions

virtual void set_device_change_callback (std::optional< DeviceChangeCallback > cb)=0
 Registers a notification-only device change callback.
virtual BufferMap device_buffers () const =0
 Returns the current map of device identifiers to buffers.

Detailed Description

Abstraction for hardware MIDI interface.

Decouples the audio engine from specific MIDI backend implementations (JUCE AudioDeviceManager, raw ALSA, CoreMIDI, etc.).

The engine registers a notification callback via set_device_change_callback() and pulls the current buffer state via device_buffers().

All methods and the callback are main-thread-only.

Definition at line 27 of file hardware_midi_interface.h.

Member Typedef Documentation

◆ BufferMap

using zrythm::dsp::IHardwareMidiInterface::BufferMap
Initial value:
std::map<utils::Utf8String, std::shared_ptr<dsp::MidiDeviceBuffer>>

Definition at line 30 of file hardware_midi_interface.h.

◆ DeviceChangeCallback

using zrythm::dsp::IHardwareMidiInterface::DeviceChangeCallback = std::function<void ()>

Definition at line 32 of file hardware_midi_interface.h.

Member Function Documentation

◆ device_buffers()

virtual BufferMap zrythm::dsp::IHardwareMidiInterface::device_buffers ( ) const
pure virtual

Returns the current map of device identifiers to buffers.

The returned shared_ptrs remain valid as long as the caller holds them, even across device changes (buffers are only destroyed when no longer referenced).

Implemented in zrythm::gui::backend::DeviceManager, and zrythm::test_helpers::MockHardwareMidiInterface.

◆ set_device_change_callback()

virtual void zrythm::dsp::IHardwareMidiInterface::set_device_change_callback ( std::optional< DeviceChangeCallback > cb)
pure virtual

Registers a notification-only device change callback.

The implementation must call cb on the main thread whenever the set of active MIDI devices changes. The callback carries no data — the listener should call device_buffers() to pull the current state.

Passing nullopt unregisters the callback. Only one callback is supported. Calling again replaces the previous one.

Implemented in zrythm::gui::backend::DeviceManager, and zrythm::test_helpers::MockHardwareMidiInterface.


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