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

Compares and transforms each whole block against an earlier block. More...

#include <BlockFeedbackProcessor.hpp>

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

Classes

struct  State
 

Public Types

using Transform = std::function< double(std::span< double >, std::span< const double >, std::span< double >)>
 The per-block function.
 

Public Member Functions

 BlockFeedbackProcessor (Transform transform, size_t lag_blocks=1, std::vector< double > coefficients={})
 
std::shared_ptr< BlockFeedbackProcessor > 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.
 
double feature (const std::shared_ptr< Buffer > &buffer) const
 The feature of the last block of one attached buffer, zero if none.
 
size_t get_lag_blocks () const
 
bool get_retain_input () 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_observer (std::function< void(double)> observer)
 Called with the feature after every block.
 
void set_retain_input (bool retain_input)
 Keep the incoming block instead of the transformed one.
 
- 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 Attributes

std::vector< double > m_coefficients
 
size_t m_lag_blocks { 1 }
 
std::function< void(double)> m_observer
 
bool m_retain_input { false }
 
std::unordered_map< const Buffer *, State > m_states
 
Transform m_transform
 

Additional Inherited Members

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

Detailed Description

Compares and transforms each whole block against an earlier block.

Where FeedbackProcessor works sample by sample, this works on the block as a unit: every cycle it hands a function the current block, the block from a set number of cycles ago and a coefficient array, and keeps what the function leaves in the buffer for later cycles. The function may rewrite the current block in place and returns one number, a feature of the block (a distance, a correlation, a level against the earlier one), which is stored per buffer and passed to an optional observer.

State (retained blocks, coefficient array, last feature) is kept per attached buffer. Works on any AudioBuffer. Until enough cycles have passed the earlier block is zeros.

Definition at line 23 of file BlockFeedbackProcessor.hpp.


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