MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Vruta::audio_promise Struct Reference

Coroutine promise type for audio processing tasks with sample-accurate timing. More...

#include <Promise.hpp>

+ Inheritance diagram for MayaFlux::Vruta::audio_promise:
+ Collaboration diagram for MayaFlux::Vruta::audio_promise:

Public Member Functions

SoundRoutine get_return_object ()
 Creates the SoundRoutine object returned to the caller.
 
- Public Member Functions inherited from MayaFlux::Vruta::routine_promise< SoundRoutine >
void domain_mismatch_error (const std::string &awaiter_name, const std::string &suggestion)
 
std::suspend_always final_suspend () noexcept
 Determines whether the coroutine suspends before destruction.
 
SoundRoutine get_return_object ()
 
T * get_state (const std::string &key)
 Retrieves a value from the state dictionary.
 
std::suspend_never initial_suspend ()
 Determines whether the coroutine suspends immediately upon creation.
 
void return_void ()
 Handles the coroutine's void return.
 
void set_state (const std::string &key, T value)
 Stores a value in the state dictionary.
 
void unhandled_exception ()
 Handles exceptions thrown from within the coroutine.
 

Public Attributes

DelayContext active_delay_context = DelayContext::NONE
 The active delay context for this coroutine.
 
uint64_t next_buffer_cycle = 0
 The buffer cycle when this coroutine should next execute Managed by BufferDelay awaiter.
 
uint64_t next_sample = 0
 The sample position when this coroutine should next execute.
 
ProcessingToken processing_token { ProcessingToken::SAMPLE_ACCURATE }
 
bool sync_to_clock = true
 
- Public Attributes inherited from MayaFlux::Vruta::routine_promise< SoundRoutine >
bool auto_resume
 Flag indicating whether the coroutine should be automatically resumed.
 
uint64_t delay_amount
 Amount of delay requested by the coroutine.
 
const ProcessingToken processing_token
 Token indicating how this coroutine should be processed.
 
bool should_terminate
 Flag indicating whether the coroutine should be terminated.
 
std::unordered_map< std::string, std::any > state
 Dictionary for storing arbitrary state data.
 
const bool sync_to_clock
 Flag indicating whether the coroutine should synchronize with the audio clock.
 

Detailed Description

Coroutine promise type for audio processing tasks with sample-accurate timing.

The promise_type is a crucial component of C++20 coroutines that defines the behavior of SoundRoutine coroutines. It serves as the control interface between the coroutine machinery and the audio engine, managing:

  1. Coroutine lifecycle (creation, suspension, resumption, and destruction)
  2. Timing information for sample-accurate scheduling
  3. State storage for persistent data between suspensions
  4. Control flags for execution behavior

In the coroutine model, the promise object is created first when a coroutine function is called. It then creates and returns the SoundRoutine object that the caller receives. The promise remains associated with the coroutine frame throughout its lifetime, while the SoundRoutine provides the external interface to manipulate the coroutine.

This separation of concerns allows the audio engine to schedule and manage coroutines efficiently while providing a clean API for audio processing code.

Definition at line 197 of file Promise.hpp.


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