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

Fixed-capacity source-to-target router with per-route depth/smoothing. More...

#include <ModulationRouter.h>

Public Member Functions

int addRoute (std::function< T()> source, std::function< void(T)> target, T depth=T(1), T base=T(0), T smoothMs=T(20))
 Adds a route (call from setup/UI threads, not the audio callback).
 
void setDepth (int route, T depth) noexcept
 Changes a route's depth. Thread-safe (atomic, relaxed).
 
void clear () noexcept
 Removes all routes and releases their captures (setup threads only).
 
int getNumRoutes () const noexcept
 Number of configured routes.
 
void update (int numSamples, double sampleRate) noexcept
 Evaluates every route once. Call per audio block.
 

Detailed Description

template<FloatType T, int MaxRoutes = 16>
class dspark::ModulationRouter< T, MaxRoutes >

Fixed-capacity source-to-target router with per-route depth/smoothing.

Threading: addRoute()/clear() belong to setup threads and must not run concurrently with update() (same contract as prepare() elsewhere in the framework). setDepth() is safe from any thread (atomic). update() runs on the audio thread and is noexcept: the stored callables MUST NOT throw – DSPark setters never do.

Template Parameters
TValue type (float or double).
MaxRoutesRoute capacity (compile-time, no audio-thread allocation).

Definition at line 57 of file ModulationRouter.h.

Member Function Documentation

◆ addRoute()

template<FloatType T, int MaxRoutes = 16>
int dspark::ModulationRouter< T, MaxRoutes >::addRoute ( std::function< T()>  source,
std::function< void(T)>  target,
depth = T(1),
base = T(0),
smoothMs = T(20) 
)
inline

Adds a route (call from setup/UI threads, not the audio callback).

The applied value is base + source() * depth, one-pole smoothed.

Parameters
sourceReturns the current modulation value. Must be non-empty.
targetReceives the smoothed, scaled value (a setter). Must be non-empty.
depthMultiplier on the source value.
baseConstant offset.
smoothMsOne-pole smoothing time (0 = none).
Returns
Route index, or -1 if the router is full or a callable is empty.

Definition at line 73 of file ModulationRouter.h.

◆ clear()

template<FloatType T, int MaxRoutes = 16>
void dspark::ModulationRouter< T, MaxRoutes >::clear ( )
inlinenoexcept

Removes all routes and releases their captures (setup threads only).

Definition at line 98 of file ModulationRouter.h.

◆ getNumRoutes()

template<FloatType T, int MaxRoutes = 16>
int dspark::ModulationRouter< T, MaxRoutes >::getNumRoutes ( ) const
inlinenoexcept

Number of configured routes.

Definition at line 109 of file ModulationRouter.h.

◆ setDepth()

template<FloatType T, int MaxRoutes = 16>
void dspark::ModulationRouter< T, MaxRoutes >::setDepth ( int  route,
depth 
)
inlinenoexcept

Changes a route's depth. Thread-safe (atomic, relaxed).

Definition at line 91 of file ModulationRouter.h.

◆ update()

template<FloatType T, int MaxRoutes = 16>
void dspark::ModulationRouter< T, MaxRoutes >::update ( int  numSamples,
double  sampleRate 
)
inlinenoexcept

Evaluates every route once. Call per audio block.

Parameters
numSamplesSamples in the block (drives the smoothing rate).
sampleRateCurrent sample rate in Hz.

Definition at line 116 of file ModulationRouter.h.


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