Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::dsp::AudioEngine Class Reference

The audio engine. More...

#include <src/dsp/engine.h>

Inheritance diagram for zrythm::dsp::AudioEngine:
Collaboration diagram for zrythm::dsp::AudioEngine:

Public Types

enum class  State : std::uint8_t { Uninitialized , Initialized , Active }
enum class  ProcessReturnStatus : std::uint8_t { ProcessCompleted , ProcessSkipped , ProcessFailed }

Public Member Functions

 AudioEngine (dsp::Transport &transport, const dsp::TempoMap &tempo_map, std::shared_ptr< juce::AudioDeviceManager > device_mgr, dsp::DspGraphDispatcher &graph_dispatcher, QObject *parent=nullptr)
 Create a new audio engine.
 ~AudioEngine () override
 Closes any connections and free's data.
Q_INVOKABLE int xRunCount () const
Q_INVOKABLE double loadPercentage () const
int sampleRate () const
Q_SIGNAL void sampleRateChanged (int sampleRate)
void wait_for_pause (EngineState &state, bool force_pause, bool with_fadeout)
void resume (const EngineState &state)
void activate (bool activate)
 Activates the audio engine to start processing and receiving events.
bool process_prepare (dsp::Transport::TransportSnapshot &transport_snapshot, nframes_t nframes, SemaphoreRAII< moodycamel::LightweightSemaphore > &sem) noexcept
 To be called by each implementation to prepare the structures before processing.
auto process (const dsp::PlayheadProcessingGuard &playhead_guard, nframes_t total_frames_to_process) noexcept -> ProcessReturnStatus
 Processes current cycle.
void advance_playhead_after_processing (dsp::Transport::TransportSnapshot &transport_snapshot, const dsp::PlayheadProcessingGuard &playhead_guard, nframes_t roll_nframes, nframes_t nframes) noexcept
 Advances the playhead if transport is rolling.
auto & get_monitor_out_port ()
auto * midi_panic_processor () const
void panic_all ()
 Queues MIDI note off to event queues.
auto get_device_manager () const
bool activated () const
bool running () const
void set_running (bool run)
auto & graph_dispatcher ()
bool exporting () const
void set_exporting (bool exporting)
auto get_processing_lock ()
nframes_t get_block_length () const
units::sample_rate_t get_sample_rate () const
void execute_function_with_paused_processing_synchronously (const std::function< void()> &func, bool recalculate_graph)
 Executes the given function after pausing processing and then resumes processing.

Properties

int sampleRate

Detailed Description

The audio engine.

Definition at line 21 of file engine.h.

Member Enumeration Documentation

◆ ProcessReturnStatus

enum class zrythm::dsp::AudioEngine::ProcessReturnStatus : std::uint8_t
strong

Definition at line 102 of file engine.h.

◆ State

enum class zrythm::dsp::AudioEngine::State : std::uint8_t
strong

Definition at line 29 of file engine.h.

Constructor & Destructor Documentation

◆ AudioEngine()

zrythm::dsp::AudioEngine::AudioEngine ( dsp::Transport & transport,
const dsp::TempoMap & tempo_map,
std::shared_ptr< juce::AudioDeviceManager > device_mgr,
dsp::DspGraphDispatcher & graph_dispatcher,
QObject * parent = nullptr )

Create a new audio engine.

This only initializes the engine and does not connect to any backend.

Member Function Documentation

◆ activate()

void zrythm::dsp::AudioEngine::activate ( bool activate)

Activates the audio engine to start processing and receiving events.

Parameters
activateActivate or deactivate.

◆ activated()

bool zrythm::dsp::AudioEngine::activated ( ) const
inline

Definition at line 146 of file engine.h.

◆ advance_playhead_after_processing()

void zrythm::dsp::AudioEngine::advance_playhead_after_processing ( dsp::Transport::TransportSnapshot & transport_snapshot,
const dsp::PlayheadProcessingGuard & playhead_guard,
nframes_t roll_nframes,
nframes_t nframes )
noexcept

Advances the playhead if transport is rolling.

Parameters
roll_nframesFrames to roll (add to the playhead - if transport rolling).
nframesTotal frames for this processing cycle.

◆ execute_function_with_paused_processing_synchronously()

void zrythm::dsp::AudioEngine::execute_function_with_paused_processing_synchronously ( const std::function< void()> & func,
bool recalculate_graph )

Executes the given function after pausing processing and then resumes processing.

Parameters
recalculate_graphWhether to also recreate the processing graph before resuming processing.

◆ exporting()

bool zrythm::dsp::AudioEngine::exporting ( ) const
inline

Definition at line 151 of file engine.h.

◆ get_block_length()

nframes_t zrythm::dsp::AudioEngine::get_block_length ( ) const
inline

Definition at line 159 of file engine.h.

◆ get_device_manager()

auto zrythm::dsp::AudioEngine::get_device_manager ( ) const
inline

Definition at line 144 of file engine.h.

◆ get_monitor_out_port()

auto & zrythm::dsp::AudioEngine::get_monitor_out_port ( )
inline

Definition at line 135 of file engine.h.

◆ get_processing_lock()

auto zrythm::dsp::AudioEngine::get_processing_lock ( )
inline

Definition at line 154 of file engine.h.

◆ get_sample_rate()

units::sample_rate_t zrythm::dsp::AudioEngine::get_sample_rate ( ) const
inline

Definition at line 166 of file engine.h.

◆ graph_dispatcher()

auto & zrythm::dsp::AudioEngine::graph_dispatcher ( )
inline

Definition at line 149 of file engine.h.

◆ loadPercentage()

Q_INVOKABLE double zrythm::dsp::AudioEngine::loadPercentage ( ) const
inline

Definition at line 59 of file engine.h.

◆ midi_panic_processor()

auto * zrythm::dsp::AudioEngine::midi_panic_processor ( ) const
inline

Definition at line 137 of file engine.h.

◆ process()

auto zrythm::dsp::AudioEngine::process ( const dsp::PlayheadProcessingGuard & playhead_guard,
nframes_t total_frames_to_process )->ProcessReturnStatus
noexcept

Processes current cycle.

To be called by each implementation in its callback.

◆ process_prepare()

bool zrythm::dsp::AudioEngine::process_prepare ( dsp::Transport::TransportSnapshot & transport_snapshot,
nframes_t nframes,
SemaphoreRAII< moodycamel::LightweightSemaphore > & sem )
noexcept

To be called by each implementation to prepare the structures before processing.

Clears buffers, marks all as unprocessed, etc.

Parameters
semSemamphoreRAII to check if acquired. If not acquired before calling this function, it will only clear output buffers and return true.
Returns
Whether the cycle should be skipped.

◆ running()

bool zrythm::dsp::AudioEngine::running ( ) const
inline

Definition at line 147 of file engine.h.

◆ sampleRate()

int zrythm::dsp::AudioEngine::sampleRate ( ) const
inline

Definition at line 64 of file engine.h.

◆ set_exporting()

void zrythm::dsp::AudioEngine::set_exporting ( bool exporting)
inline

Definition at line 152 of file engine.h.

◆ set_running()

void zrythm::dsp::AudioEngine::set_running ( bool run)
inline

Definition at line 148 of file engine.h.

◆ wait_for_pause()

void zrythm::dsp::AudioEngine::wait_for_pause ( EngineState & state,
bool force_pause,
bool with_fadeout )
Parameters
force_pauseWhether to force transport pause, otherwise for engine to process and handle the pause request.

◆ xRunCount()

Q_INVOKABLE int zrythm::dsp::AudioEngine::xRunCount ( ) const
inline

Definition at line 58 of file engine.h.

Property Documentation

◆ sampleRate

int zrythm::dsp::AudioEngine::sampleRate
read

Definition at line 24 of file engine.h.


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