Table of Contents

Class ParameterDispatchQueue

Namespace
NAudio.Effects
Assembly
NAudio.Core.dll

Lock-free single-producer/single-consumer queue that carries parameter writes from a control thread (UI, automation, presets) to the audio thread. The producer calls Post(EffectParameter, float) — invoked for you by Value once the parameter has been Attach(IParameterized)ed — and the audio thread calls Drain() once at the top of each processing block. Every pending write is then applied on the audio thread, so coefficient recomputation, delay-buffer resizes and filter swaps happen where there is no concurrent reader.

public sealed class ParameterDispatchQueue : IParameterDispatch
Inheritance
ParameterDispatchQueue
Implements
Inherited Members

Remarks

Both Post(EffectParameter, float) and Drain() are allocation-free and wait-free. The queue is intended for exactly one producer thread and one consumer thread, which matches the realtime harness (a single UI dispatcher and one audio callback). It is bounded: when full, Post(EffectParameter, float) drops the write — the next edit of the same parameter supersedes it anyway, and at audio-block rate the queue never approaches full under human-rate edits.

Constructors

ParameterDispatchQueue(int)

Creates the queue. capacity is rounded up to a power of two and bounds how many un-drained writes can be buffered between blocks.

public ParameterDispatchQueue(int capacity = 256)

Parameters

capacity int

Methods

Attach(IParameterized)

Routes every parameter of effect through this queue, so off-thread writes are deferred to the next Drain().

public void Attach(IParameterized effect)

Parameters

effect IParameterized

Detach(IParameterized)

Stops routing effect's parameters through this queue; subsequent writes apply inline again.

public void Detach(IParameterized effect)

Parameters

effect IParameterized

Drain()

Applies every pending parameter write. Call once at the top of the audio processing block, on the audio thread, before any DSP.

public void Drain()

Post(EffectParameter, float)

Posts a clamped parameter write to be applied later on the audio thread. Must be safe to call from a non-audio thread and must not block.

public void Post(EffectParameter parameter, float value)

Parameters

parameter EffectParameter
value float