IAudioNode
#include "crosspad/audio/IAudioNode.hpp"Generated from crosspad/audio/IAudioNode.hpp in crosspad-core. Edit the header’s doxygen comments to change this page.
crosspad::IAudioNode
Section titled “crosspad::IAudioNode”A DSP unit in the audio module’s node chain.
Nodes operate on interleaved stereo float32 buffers in [-1.0, 1.0]. Generators (synths, samplers) override mix() to add into the bus buffer. Effects override process() and may be in-place (in == out is allowed).
── Lifecycle ─────────────────────────────────────────────────────────────
- Constructed on any thread.
- Registered into a module/mixer (addNode / addChannel).
- Module/mixer calls onPrepare(maxFrames, sampleRate) once during setup and again on any restart-time change. This is where SR-dependent state (filter coefficients, delay lines, scratch buffers sized to maxFrames) must be allocated.
- Audio thread calls mix() / process() repeatedly, never beyond maxFrames.
── RT-safety contract for mix() / process() ───────────────────────────── These run on the audio thread and MUST be real-time safe:
- No heap allocation (no new, no vector::resize, no string formatting).
- No blocking primitives (no mutex, no condvar, no ring-buffer wait).
- No syscalls / logging / file I/O.
- No printf-family or any unbounded code path. Communicate with non-audio threads via std::atomic on POD scalars or lock-free SPSC queues. Any setup-time work belongs in onPrepare().
setEnabled() / enabled() and any setter exposed to UI code may be called from any thread; back them with std::atomic.
Members
| Member | Description |
|---|---|
process | Effect-style processing. |
mix | Generator-style mixing. |
isGenerator | Marks this node as a generator (mix() called) vs effect (process() called). |
name | |
enabled | |
setEnabled | |
onPrepare | Called by the host (IAudioModule or AudioMixerEngine) once both the audio buffer size and sample rate are known, and again on any restart-time change. |
onSampleRateChange | Legacy SR-only notification. |
Methods
process
Section titled “process”virtual void process(const float *in, float *out, uint32_t frames)Effect-style processing.
Interleaved stereo [L,R,L,R,…] in [-1.0, 1.0]. Default impl is pass-through; override for actual DSP. RT-safe contract applies — see class doc.
virtual void mix(float *, uint32_t)Generator-style mixing.
Adds into existing bus buffer; default no-op. RT-safe contract applies — see class doc.
isGenerator
Section titled “isGenerator”virtual bool isGenerator() constMarks this node as a generator (mix() called) vs effect (process() called).
virtual const char * name() const =0enabled
Section titled “enabled”virtual bool enabled() constsetEnabled
Section titled “setEnabled”virtual void setEnabled(bool)onPrepare
Section titled “onPrepare”virtual void onPrepare(uint32_t, uint32_t sampleRate)Called by the host (IAudioModule or AudioMixerEngine) once both the audio buffer size and sample rate are known, and again on any restart-time change.
Allocate scratch buffers sized to maxFrames * 2 (stereo) here so subsequent mix()/process() calls stay alloc-free. Default impl forwards to legacy onSampleRateChange() for nodes that only care about sample rate.
onSampleRateChange
Section titled “onSampleRateChange”virtual void onSampleRateChange(uint32_t)Legacy SR-only notification.
Prefer overriding onPrepare() for new nodes that need the buffer size for pre-allocation.
Declared in crosspad/audio/IAudioNode.hpp:36.