Product
Lock-free audio graph scheduling, PDC, and parameter mailboxes
How Infinite compiles audio graphs on the main thread, schedules parallel DAG execution, aligns branches with idempotent PDC, and smooths parameters per sample.

on this page
Real-time audio engines fail in predictable ways when graph edits, multi-core scheduling, plugin latency, and UI automation collide on the audio callback thread. Taking a mutex inside the callback risks priority inversion and buffer underruns; reallocating delay lines on every cable edit produces audible clicks; reading raw UI knob values per block introduces staircase zipper noise.
In Infinite, AudioEngine avoids all three failure modes by separating graph compilation from graph execution across a strict wait-free boundary. The main thread builds an immutable ProcessList, pre-allocates its buffer pool, and resolves Plugin Delay Compensation (PDC) before publishing it atomically; the audio callback and its worker pool execute the DAG without locks, allocations, or shared mutable indices.

Main-thread topology compilation and atomic swap
Whenever a cable is connected, a node is added, or an arrangement clip changes, RebuildAudioTopology walks the editor graph on the main thread and produces a topologically sorted AudioTopology (sources before consumers). AudioEngine::SetTopology wraps that topology in a ProcessList and pre-allocates every PooledBuffer up front, bounded by compile-time ceilings (kAudioMaxBlockFrames = 4096, kAudioMaxChannels = 8, kAudioMaxNodeInputs = 32, kAudioMaxNodeOutputs = 12).
Inside RebuildAudioTopology, PrepareToPlay is only called when entry.node->preparedForSampleRate != sampleRate. Unconditionally calling PrepareToPlay on every topology rebuild would reset filter, delay, and reverb state inside already-running nodes whenever an unrelated cable changes elsewhere in the graph.
Once the ProcessList is ready, SetTopology increments mPublishedGeneration, computes the parallel execution schedule (BuildSchedule), and swaps mCurrent.exchange(fresh, std::memory_order_acq_rel). Superseded ProcessList objects are pushed onto mRetiring and freed by DrainRetired() only after the audio thread's CompletedGeneration() has moved past them, guaranteeing the audio callback never touches a deleted topology and never frees memory itself.
Parallel DAG execution with atomic work claiming
A modular patch with independent synth and effect chains should scale across cores without spin-lock contention or per-block thread creation. When a topology's graph width exceeds one (list->width > 1), AudioEngine::RunTopology dispatches work across AudioWorkerPool alongside the audio thread itself:
- Precomputed dependency counts:
BuildSchedulestores each node's upstream dependency count indepCount[p]and its downstream indices insucc[succStart[p]..succStart[p+1]). At the start of each block,pending[p]is initialised fromdepCount[p]. - Single-atomic work claiming:
mClaimpacks the 32-bit block sequence numberseq, the total node count, and the next unclaimed index into one 64-bitstd::atomic. Both the audio thread and woken workers loop inRunClaims, claiming the next schedule slot withcompare_exchange_weak. - Deadlock-free dependency waiting: Because
runOrderis topologically valid, any dependency of slotpsits at an earlier position and is already claimed by an active thread. A worker only waits whilelist->pending[p].load(std::memory_order_acquire) > 0, runsRunEntry, decrements each successor'spendingcounter withfetch_sub(1, std::memory_order_acq_rel), and incrementsmDone. - Consistent floating-point state: Workers synchronise their hardware floating-point control register (
AudioWorkerPool::ReadFpControl()/WriteFpControl()) to match the audio callback's denormal mode (mJob.fpControl) before processing any DSP.
If a topology has no parallel width (width <= 1), RunTopology skips the atomic dispatch and runs list->topology.order serially on the audio thread.
Idempotent plugin delay compensation at merge points
Latent nodes, such as lookahead limiters, spectral processors, or out-of-process VST3 and AU plugins, report their delay via LatencySamples(). Without alignment, parallel branches merging into a Mixer or Dynamics sidechain input would comb-filter or smear transients.
Because order is already topologically sorted, RebuildAudioTopology computes cumulative latency in one forward pass:
- For each node,
maxUpstreamis the maximumcumulativeLatencyByBufferacross its connectedinputBufferIndices. Note-only inputs do not enterinputBufferIndicesand add zero latency. - The node's output latency is
entry.node->LatencySamples() + maxUpstream, written tocumulativeLatencyByBufferfor every output pin. - At every node input pin, the required delay is
maxAmongConnected - cumulativeLatencyByBuffer[idx]. The same calculation runs across non-liveAudioTerminaloutputs feeding the device mix (maxAmongTerminals).
Crucially, CompensationDelay instances live on persistent owners (AudioNode::inputCompensation for input pins, AudioCaptureRing::compensation for canvas Audio Out terminals, and main-thread-managed slots for arrangement clip terminals) rather than inside the transient AudioTopologyEntry struct. CompensationDelay::Prepare(delaySamples, numChannels) is idempotent: if delaySamples and numChannels match what the ring buffer already holds, Prepare returns immediately without reallocating or zeroing in-flight audio. Branches with 0 samples of delay allocate nothing (mBuf stays empty) and run as a passthrough.
Per-sample parameter smoothing with ParamMailbox
UI sliders and modulation updates arrive once per visual frame, whereas DSP kernels like Reverb and Analog read parameters at audio sample rate. ParamMailbox bridges the two threads using a flat array of std::atomic<float> mTarget[128] (kMaxParams = 128) instead of a shared head/tail ring buffer, eliminating any consumer-index race under concurrent updates.
Before pushing a frame's parameter values, the main thread calls ParamMailbox::PublishFrame(stampSeconds, delaySeconds) to record the engine-time stamp and expected frame interval. On the audio thread, SmoothedValue(paramId) loads the latest atomic target:
- First-value priming: When the first
Pusharrives (mPushed),r.primedsnapscurandtargetstraight to the initial value rather than ramping up from0.0fover the first block. - Timestamped linear ramps: Subsequent changes compute a sample count clamped between
kMinRampSamples = 16andkMaxRampSeconds = 0.25 s(defaulting tokFallbackRampSeconds = 0.005 sin headless tests before any frame stamp exists) and step linearly per sample. - Single-slot ramp queueing: If a new target arrives while a ramp is still running and its end time is later than the current
r.endTime,OnNewTargetqueues it inpendingValue/pendingEndso the smoother reaches the previous frame's value before turning toward the next. - Block-rate hoisting: Nodes that read a parameter once per block call
BlockValue(paramId, numFrames), which advances the sample ramp bynumFrames, and kernels can checkIsSettled(paramId)to hoist coefficient updates out of the inner sample loop.
Exploring Infinite's signal graph
You can inspect how these audio-graph primitives behave in real patches by downloading Infinite or browsing ready-made synth, mixing, and audiovisual patches in the Infinite library.
There are honest limits to keep in mind. Infinite is a young, MIT-licensed open-source project: desktop plugin hosting supports VST3 and AU without AAX, live hardware audio inputs are refused in headless mode, and the pooled audio graph enforces fixed upper bounds of 4096 frames per block, 8 channels, 32 inputs per node, and 128 parameters per ParamMailbox.