Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::gui::backend::DeviceManager Class Reference

Wrapper over juce::AudioDeviceManager that exposes changes as signals. More...

#include <src/gui/backend/device_manager.h>

Inheritance diagram for zrythm::gui::backend::DeviceManager:
Collaboration diagram for zrythm::gui::backend::DeviceManager:

Public Types

using XmlStateGetter = std::function<std::unique_ptr<juce::XmlElement> ()>
using XmlStateSetter = std::function<void (const juce::XmlElement &)>
Public Types inherited from zrythm::dsp::IHardwareMidiInterface
using BufferMap
using DeviceChangeCallback = std::function<void ()>

Public Member Functions

 DeviceManager (XmlStateGetter state_getter, XmlStateSetter state_setter)
void initialize (int max_input_channels, int max_output_channels, bool fallback_to_default)
 Opens a set of devices ready for use.
void save_state ()
void createAudioDeviceTypes (juce::OwnedArray< juce::AudioIODeviceType > &types) override
Q_INVOKABLE void showDeviceSelector ()
QVector< AudioInputInfoavailableAudioInputs () const
Q_SIGNAL void availableAudioInputsChanged ()
QVector< MidiInputInfoavailableMidiInputs () const
Q_SIGNAL void availableMidiInputsChanged ()
dsp::MidiDeviceBuffermidi_buffer_for_device (const utils::Utf8String &identifier) const
void set_device_change_callback (std::optional< DeviceChangeCallback > cb) override
 Registers a notification-only device change callback.
BufferMap device_buffers () const override
 Returns the current map of device identifiers to buffers.

Properties

QML_ELEMENT QVector< zrythm::gui::backend::AudioInputInfoavailableAudioInputs
QVector< zrythm::gui::backend::MidiInputInfoavailableMidiInputs

Friends

struct MidiImpl

Detailed Description

Wrapper over juce::AudioDeviceManager that exposes changes as signals.

Definition at line 62 of file device_manager.h.

Member Typedef Documentation

◆ XmlStateGetter

using zrythm::gui::backend::DeviceManager::XmlStateGetter = std::function<std::unique_ptr<juce::XmlElement> ()>

Definition at line 75 of file device_manager.h.

◆ XmlStateSetter

using zrythm::gui::backend::DeviceManager::XmlStateSetter = std::function<void (const juce::XmlElement &)>

Definition at line 76 of file device_manager.h.

Member Function Documentation

◆ device_buffers()

BufferMap zrythm::gui::backend::DeviceManager::device_buffers ( ) const
overridevirtual

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).

Implements zrythm::dsp::IHardwareMidiInterface.

◆ initialize()

void zrythm::gui::backend::DeviceManager::initialize ( int max_input_channels,
int max_output_channels,
bool fallback_to_default )

Opens a set of devices ready for use.

Parameters
max_input_channelsMax number of input channels (channels used might be less than this).
max_output_channelsMax number of output channels (channels used might be less than this).
fallback_to_defaultWhether to fallback to the default device if opening the device(s) from the state fails.

This calls juce::AudioDeviceManager::initialise() internally and passes the state obtained from state_getter_.

Exceptions
ZrythmExceptionError occurred in opening the device(s).

◆ set_device_change_callback()

void zrythm::gui::backend::DeviceManager::set_device_change_callback ( std::optional< DeviceChangeCallback > cb)
overridevirtual

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.

Implements zrythm::dsp::IHardwareMidiInterface.

◆ MidiImpl

friend struct MidiImpl
friend

Definition at line 126 of file device_manager.h.

Property Documentation

◆ availableAudioInputs

QML_ELEMENT QVector<zrythm::gui::backend::AudioInputInfo> zrythm::gui::backend::DeviceManager::availableAudioInputs
read

Definition at line 71 of file device_manager.h.

◆ availableMidiInputs

QVector<zrythm::gui::backend::MidiInputInfo> zrythm::gui::backend::DeviceManager::availableMidiInputs
read

Definition at line 72 of file device_manager.h.


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