DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
dspark::ProcessorChain< T, Processors > Class Template Reference

Compile-time chain of audio processors. More...

#include <ProcessorChain.h>

Public Member Functions

void prepare (const AudioSpec &spec)
 Prepares all processors in order.
 
void processBlock (AudioBufferView< T > buffer) noexcept
 Processes a buffer through all non-bypassed processors in order.
 
void reset () noexcept
 Resets the internal state of all processors (e.g., clearing delay lines).
 
template<std::size_t Index>
auto & get () noexcept
 Accesses the processor at the given index.
 
template<std::size_t Index>
const auto & get () const noexcept
 Const access to the processor at the given index.
 
int getLatency () const noexcept
 Returns the total latency in samples across all processors.
 
template<std::size_t Index>
void setBypassed (bool bypassed) noexcept
 Thread-safe toggle to bypass or enable a processor.
 
template<std::size_t Index>
bool isBypassed () const noexcept
 Thread-safe read of the bypass state of a processor.
 

Static Public Member Functions

static constexpr std::size_t size () noexcept
 Returns the number of processors in the chain.
 

Detailed Description

template<typename T, typename... Processors>
class dspark::ProcessorChain< T, Processors >

Compile-time chain of audio processors.

Processors are stored in a std::tuple and invoked in order. Access individual processors via get<Index>() to configure parameters.

Template Parameters
TSample type (float or double).
ProcessorsProcessor types. Must be greater than 0.

Definition at line 43 of file ProcessorChain.h.

Member Function Documentation

◆ get() [1/2]

template<typename T , typename... Processors>
template<std::size_t Index>
const auto & dspark::ProcessorChain< T, Processors >::get ( ) const
inlinenoexcept

Const access to the processor at the given index.

Template Parameters
IndexZero-based index into the chain.
Returns
Const reference to the processor.

Definition at line 101 of file ProcessorChain.h.

◆ get() [2/2]

template<typename T , typename... Processors>
template<std::size_t Index>
auto & dspark::ProcessorChain< T, Processors >::get ( )
inlinenoexcept

Accesses the processor at the given index.

Template Parameters
IndexZero-based index into the chain.
Returns
Reference to the processor.

Definition at line 88 of file ProcessorChain.h.

◆ getLatency()

template<typename T , typename... Processors>
int dspark::ProcessorChain< T, Processors >::getLatency ( ) const
inlinenoexcept

Returns the total latency in samples across all processors.

Reporters are detected at compile time via requires expressions and summed at runtime. Only processors providing a const getLatency() convertible to int contribute; a non-const getLatency() is a compile error rather than a silent zero.

Note
Latency is summed over ALL slots regardless of per-slot bypass, so the reported value stays constant when toggling bypass at runtime. This is deliberate: a fluctuating latency would force the host to re-issue plugin delay compensation on every bypass change.

Definition at line 128 of file ProcessorChain.h.

◆ isBypassed()

template<typename T , typename... Processors>
template<std::size_t Index>
bool dspark::ProcessorChain< T, Processors >::isBypassed ( ) const
inlinenoexcept

Thread-safe read of the bypass state of a processor.

Definition at line 157 of file ProcessorChain.h.

◆ prepare()

template<typename T , typename... Processors>
void dspark::ProcessorChain< T, Processors >::prepare ( const AudioSpec spec)
inline

Prepares all processors in order.

Parameters
specAudio specification.

Definition at line 55 of file ProcessorChain.h.

◆ processBlock()

template<typename T , typename... Processors>
void dspark::ProcessorChain< T, Processors >::processBlock ( AudioBufferView< T >  buffer)
inlinenoexcept

Processes a buffer through all non-bypassed processors in order.

Parameters
bufferAudio buffer (modified in-place by each processor).

Definition at line 66 of file ProcessorChain.h.

◆ reset()

template<typename T , typename... Processors>
void dspark::ProcessorChain< T, Processors >::reset ( )
inlinenoexcept

Resets the internal state of all processors (e.g., clearing delay lines).

Definition at line 74 of file ProcessorChain.h.

◆ setBypassed()

template<typename T , typename... Processors>
template<std::size_t Index>
void dspark::ProcessorChain< T, Processors >::setBypassed ( bool  bypassed)
inlinenoexcept

Thread-safe toggle to bypass or enable a processor.

Warning
This is a hard bypass. Toggling this during live playback will cause audio clicks/pops and phase discontinuities if the processor introduces latency. For real-time clickless bypass, prefer using dry/wet controls within the specific processor itself.
Template Parameters
IndexZero-based index into the chain.
Parameters
bypassedTrue to bypass, false to enable.

Definition at line 147 of file ProcessorChain.h.

◆ size()

template<typename T , typename... Processors>
static constexpr std::size_t dspark::ProcessorChain< T, Processors >::size ( )
inlinestaticconstexprnoexcept

Returns the number of processors in the chain.

Definition at line 110 of file ProcessorChain.h.


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