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

Combines each sample with lagged values of its own carried stream. More...

#include <FeedbackBuffer.hpp>

+ Inheritance diagram for MayaFlux::Buffers::FeedbackProcessor:
+ Collaboration diagram for MayaFlux::Buffers::FeedbackProcessor:

Classes

struct  State
 
struct  Step
 Result of a combiner that carries a different value than it outputs. More...
 
struct  Tap
 

Public Types

using Combine = std::function< double(double, std::span< const double >, std::span< double >)>
 Combiner returning one value, written to the buffer and carried.
 
using CombineStep = std::function< Step(double, std::span< const double >, std::span< double >)>
 Combiner returning an output and a carried value.
 
using WindowKernel = std::function< double(std::span< double >, std::span< double >)>
 A function of one window and one array, as in Kinesis::Discrete::Kernels.
 

Public Member Functions

void clear_lag_source ()
 
std::shared_ptr< FeedbackProcessor > clone () const
 Same configuration, no attached state.
 
std::span< double > coefficients (const std::shared_ptr< Buffer > &buffer)
 The coefficient array of one attached buffer, empty if it is not attached.
 
 FeedbackProcessor (Combine combine, const std::vector< double > &lags, std::vector< double > coefficients={})
 
 FeedbackProcessor (CombineStep combine, const std::vector< double > &lags, std::vector< double > coefficients={})
 
 FeedbackProcessor (float feedback=0.5F, uint32_t feed_samples=512)
 Single tap, output = input + feedback * tap.
 
 FeedbackProcessor (WindowKernel kernel, const std::vector< double > &lags, std::vector< double > coefficients={})
 
uint32_t get_feed_samples () const
 
float get_feedback () const
 
size_t get_interpolation () const
 
bool is_compatible_with (const std::shared_ptr< Buffer > &buffer) const override
 Checks if this processor can handle the specified buffer type.
 
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.
 
void processing_function (const std::shared_ptr< Buffer > &buffer) override
 The core processing function that must be implemented by derived classes.
 
void set_coefficients (std::vector< double > coefficients)
 Set the initial coefficient array and reset every attached buffer's copy.
 
void set_combine (Combine combine)
 
void set_combine (CombineStep combine)
 
void set_combine (WindowKernel kernel)
 
void set_feed_samples (uint32_t samples)
 Lag of the first tap, in samples.
 
void set_feedback (float amount)
 
void set_interpolation (size_t order)
 Interpolation used for fractional lags.
 
void set_lag (size_t tap, Kinesis::TimeMap seconds, double max_seconds)
 Drive one tap's lag from a TimeMap.
 
void set_lag_source (const std::shared_ptr< FeedbackBuffer > &source)
 Read the taps from another FeedbackBuffer's ring.
 
void set_lags (const std::vector< double > &lags)
 Replace all taps with fixed lags in samples.
 
- 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 recompute_capacity ()
 
State & state_for (const std::shared_ptr< Buffer > &buffer)
 

Static Private Member Functions

static double read (const Memory::HistoryBuffer< double > &ring, double lag)
 
static double read_at (const Memory::HistoryBuffer< double > &ring, double position, size_t order) noexcept
 

Private Attributes

size_t m_capacity { 1 }
 
std::vector< double > m_coefficients
 
Combine m_combine
 
bool m_default_combine { false }
 
uint32_t m_feed_samples { 512 }
 
float m_feedback_amount { 0.5F }
 
WindowKernel m_kernel
 
std::weak_ptr< FeedbackBuffer > m_lag_source
 
size_t m_order { 1 }
 
std::unordered_map< const Buffer *, State > m_states
 
CombineStep m_step
 
std::vector< Tap > m_taps
 

Additional Inherited Members

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

Detailed Description

Combines each sample with lagged values of its own carried stream.

Per sample the processor reads one value per tap from a ring of carried values, calls the combiner with the current sample, those tap values and the coefficient array, writes the result to the buffer and pushes the carried value into the ring. Lags start at one sample, so recursion within a block is possible. State (ring, coefficient array, lag ramps) is kept per attached buffer, so one processor can serve many buffers and clones never share history.

Works on any AudioBuffer. On a FeedbackBuffer the ring is the buffer's own.

Definition at line 91 of file FeedbackBuffer.hpp.


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