MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::Buffers::AudioContextProcessor Class Reference

Runs a Yantra word pair context over a child AudioBuffer without blocking. More...

#include <AudioContextProcessor.hpp>

Inheritance diagram for MayaFlux::Buffers::AudioContextProcessor:
Collaboration diagram for MayaFlux::Buffers::AudioContextProcessor:

Classes

struct  Slot

Public Types

using ContextFactory = std::function<std::shared_ptr<Yantra::WordPairExecutionContext>()>
using StageFunction = std::function<void(Yantra::WordPairExecutionContext&, std::span<const double>, uint64_t)>
 Fills a context for one job from the child's samples and the call's sequence number.

Public Member Functions

 AudioContextProcessor (AudioContextProcessor &&)=delete
 AudioContextProcessor (const AudioContextProcessor &)=delete
 AudioContextProcessor (const ContextFactory &factory, uint32_t depth=2, StageFunction stage={})
uint32_t depth () const
bool is_compatible_with (const std::shared_ptr< Buffer > &buffer) const override
 Checks if this processor can handle the specified buffer type.
uint64_t missed () const
 Calls whose output was silent although a result was due.
void on_attach (const std::shared_ptr< Buffer > &buffer) override
 Called when this processor is attached to a buffer.
void on_detach (const std::shared_ptr< Buffer > &buffer) override
 Called when this processor is detached from a buffer.
AudioContextProcessor & operator= (AudioContextProcessor &&)=delete
AudioContextProcessor & operator= (const AudioContextProcessor &)=delete
void processing_function (const std::shared_ptr< Buffer > &buffer) override
 The core processing function that must be implemented by derived classes.
 ~AudioContextProcessor () override
Public Member Functions inherited from MayaFlux::Buffers::BufferProcessor
virtual ProcessingToken get_processing_token () const
 Gets the current processing token for this buffer.
void process (const std::shared_ptr< Buffer > &buffer)
 Applies a computational transformation to the data in the provided buffer.
virtual void set_processing_token (ProcessingToken token)
 Gets the preferred processing backend for this processor.
virtual ~BufferProcessor ()=default
 Virtual destructor for proper cleanup of derived classes.

Private Member Functions

void drain ()
void submit (Slot &slot, uint64_t sequence, std::span< const double > samples)

Private Attributes

uint64_t m_missed {}
bool m_missing {}
uint64_t m_next {}
std::vector< Slot > m_slots
StageFunction m_stage

Additional Inherited Members

Protected Attributes inherited from MayaFlux::Buffers::BufferProcessor
ProcessingToken m_processing_token { ProcessingToken::AUDIO_BACKEND }

Detailed Description

Runs a Yantra word pair context over a child AudioBuffer without blocking.

Install as the default processor of a child AudioBuffer under AUDIO_PARALLEL. Each call stages the child's samples into one of depth contexts, dispatches it asynchronously and returns. The child receives the result of the call made depth calls earlier, so the output lags the input by depth calls and nothing waits on the GPU. A call whose result is not complete yields a silent child, the late result is discarded, and an earlier block is never replayed.

Contexts come from a factory so each in-flight job owns its buffers. The default staging writes the samples to binding 0 as word pairs and reads the primary output back at the same size. A stage function replaces it when the shader takes other inputs.

Usage: auto proc = std::make_shared<AudioContextProcessor>(make_context, 2); child->set_default_processor(proc);

Definition at line 34 of file AudioContextProcessor.hpp.


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