Class SendBus
An auxiliary effect send/return bus: a shared interleaved buffer that sources mix a portion of their signal into, run through one IAudioEffect (typically a reverb or chorus), with the wet result returned (added) into a destination mix.
This is the generic plumbing a mixer or sampler uses to share one reverb or chorus instance across many voices, rather than instantiating the effect per voice. The effect runs every block so its tail keeps sounding after the sends stop. Not thread-safe; drive it from the audio thread.
public sealed class SendBus
- Inheritance
-
SendBus
- Inherited Members
Constructors
SendBus(IAudioEffect)
Creates a send bus around an effect. The effect should be fully wet (return only its processed signal); Mix defaults to 1, which is correct here.
public SendBus(IAudioEffect effect)
Parameters
effectIAudioEffect
Properties
Effect
The hosted effect, exposed so callers can tweak or bypass it.
public IAudioEffect Effect { get; }
Property Value
IdleTimeoutFrames
How long (in frames) the effect keeps running after the last block of written input, i.e. a conservative upper bound on its audible tail. While input keeps arriving the effect always runs; once input has been silent for this long, ProcessReturn(Span<float>, int, bool) skips the effect entirely until input is written again. 0 (the default) disables idle skipping — the effect runs every block.
public int IdleTimeoutFrames { get; set; }
Property Value
IsIdle
Whether the bus is currently idle: idle skipping is enabled and the tail window since the last written input has fully elapsed (a fresh bus starts idle — it has no tail to flush).
public bool IsIdle { get; }
Property Value
Methods
Configure(WaveFormat, int)
Configures the bus for a format and a maximum block size (frames per ProcessReturn(Span<float>, int) call). Allocates the send buffer.
public void Configure(WaveFormat format, int maxFrames)
Parameters
formatWaveFormatmaxFramesint
PrepareSend(int)
The send buffer for the next frames frames, cleared
and ready for sources to accumulate into. Valid until the next
ProcessReturn(Span<float>, int).
public Span<float> PrepareSend(int frames)
Parameters
framesint
Returns
ProcessReturn(Span<float>, int)
Runs the effect over the accumulated send signal and adds the wet
result into destination (the dry mix). Call once per
block after sources have written their sends via PrepareSend(int).
This overload assumes input may have been written, so the effect always
runs (and any idle countdown re-arms).
public void ProcessReturn(Span<float> destination, int frames)
Parameters
ProcessReturn(Span<float>, int, bool)
As ProcessReturn(Span<float>, int), but with the caller reporting whether anything was actually mixed into the send buffer this block. When input has been silent for longer than IdleTimeoutFrames the effect's tail has decayed below audibility, so the effect processing (and the return add) is skipped until a send writes again — an idle reverb/chorus then costs nothing.
public void ProcessReturn(Span<float> destination, int frames, bool inputWritten)
Parameters
Reset()
Clears the hosted effect's internal state (delay lines, etc.).
public void Reset()