|
DSPark 1.8.0
Header-only C++20 DSP for real-time and offline audio
|
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. Control thread (relaxed atomic word, adopted by the next update()). | |
| 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. | |
Fixed-capacity source-to-target router with per-route depth/smoothing.
Threading (SPSC model, see docs/threading.md): addRoute()/clear() belong to the setup thread and must not run concurrently with update() or setDepth() (same contract as prepare() elsewhere in the framework; numRoutes_ is a plain word published by that setup ordering). setDepth() belongs to the control thread (ONE non-audio writer; single-word relaxed atomic adopted at the next update()). update() runs on the audio thread and is noexcept: the stored callables MUST NOT throw – DSPark setters never do. getNumRoutes() reflects setup-time state; read it from setup or from the control side once configuration is complete.
| T | Value type (float or double). |
| MaxRoutes | Route capacity (compile-time, no audio-thread allocation). |
Definition at line 61 of file ModulationRouter.h.
|
inline |
Adds a route (call from setup/UI threads, not the audio callback).
The applied value is base + source() * depth, one-pole smoothed.
| source | Returns the current modulation value. Must be non-empty. |
| target | Receives the smoothed, scaled value (a setter). Must be non-empty. |
| depth | Multiplier on the source value. |
| base | Constant offset. |
| smoothMs | One-pole smoothing time (0 = none). |
Definition at line 77 of file ModulationRouter.h.
|
inlinenoexcept |
Removes all routes and releases their captures (setup threads only).
Definition at line 103 of file ModulationRouter.h.
|
inlinenoexcept |
Number of configured routes.
Definition at line 114 of file ModulationRouter.h.
|
inlinenoexcept |
Changes a route's depth. Control thread (relaxed atomic word, adopted by the next update()).
Definition at line 96 of file ModulationRouter.h.
|
inlinenoexcept |
Evaluates every route once. Call per audio block.
| numSamples | Samples in the block (drives the smoothing rate). |
| sampleRate | Current sample rate in Hz. |
Definition at line 121 of file ModulationRouter.h.