Table of Contents

Class Vst3EffectSampleProvider

Namespace
NAudio.Vst3
Assembly
NAudio.Vst3.dll

Wraps a Vst3Plugin as an ISampleProvider — pulls samples from a source provider, feeds them through the plug-in, and returns the processed output to the caller. By default also renders the plug-in's tail past source EOF, so reverbs, delays and other effects with a release tail produce a full, untruncated render without the caller having to know the tail length in advance.

public sealed class Vst3EffectSampleProvider : ISampleProvider
Inheritance
Vst3EffectSampleProvider
Implements
Inherited Members
Extension Methods

Remarks

Block-size handling: callers may request any number of samples; the wrapper pulls from the source in chunks no larger than MaxBlockSize, processes each chunk, and writes it to the caller's buffer.

Tail rendering (RenderTail, default true) takes over after the source returns 0: the wrapper keeps feeding zero-input blocks to the plug-in and watches the output's RMS. After TailSilenceBlocks consecutive blocks whose RMS is below TailSilenceThresholdDb the wrapper declares the tail drained and returns 0. MaxTailDuration caps the wait for plug-ins that never settle (granular freeze, infinite feedback, etc.). Set RenderTail to false to recover the old source-bound behaviour — useful when building a chain where downstream handles the tail.

Channel and sample-rate handling: the source must match the plug-in's negotiated InputChannelCount and SampleRate. Output is at the plug-in's OutputChannelCount (often the same as input, but mono→stereo plug-ins do change channel count).

Constructors

Vst3EffectSampleProvider(ISampleProvider, Vst3Plugin)

Wires source through plugin. The source's WaveFormat must match the plug-in's input channel count and sample rate.

public Vst3EffectSampleProvider(ISampleProvider source, Vst3Plugin plugin)

Parameters

source ISampleProvider
plugin Vst3Plugin

Properties

CompensateLatency

When true (the default), the plug-in's processing latency (LatencySamples) is compensated by discarding that many output frames from the front of the render, so the output is sample-aligned with the input. A no-op for the common zero-latency case. The dropped leading frames are the plug-in's pre-roll; the matching real samples at the end emerge during tail rendering (so keep RenderTail on for a full aligned render). Latency is snapshotted on the first Read(Span<float>) and is not re-applied if the plug-in changes its latency at runtime (e.g. a linear-phase toggle that raises LatencyChanged): a later change leaves a fixed alignment offset for the rest of the stream. Fine for an offline render; for live use, rebuild the chain to re-align.

public bool CompensateLatency { get; init; }

Property Value

bool

MaxTailDuration

Safety cap on the tail-rendering phase. Plug-ins that report kInfiniteTail or that genuinely never settle (granular freeze, infinite-feedback delay) hit this limit instead of hanging the render. Default: 30 seconds.

public TimeSpan MaxTailDuration { get; init; }

Property Value

TimeSpan

RenderTail

When true (the default), after the source returns 0 the wrapper keeps feeding the plug-in zero-input blocks until its output settles to silence, so reverb / delay tails are rendered in full. When false, the wrapper stops as soon as the source ends — the classic source-bound behaviour, suitable when the wrapper is one stage of a longer chain or when the caller is feeding an infinite (live) source.

public bool RenderTail { get; init; }

Property Value

bool

TailSilenceBlocks

Number of consecutive silent output blocks required before the tail is considered drained. Default 4 — enough to avoid stopping on a momentary dip without significantly extending the render. Each block is up to MaxBlockSize samples.

public int TailSilenceBlocks { get; init; }

Property Value

int

TailSilenceThresholdDb

Per-block output RMS threshold (in dBFS) for declaring a block "silent". A block whose RMS is below this value counts toward the consecutive-silent-blocks gate. Default −80 dBFS — well below any practical hearing threshold for typical playback levels.

public double TailSilenceThresholdDb { get; init; }

Property Value

double

WaveFormat

Gets the WaveFormat of this Sample Provider.

public WaveFormat WaveFormat { get; }

Property Value

WaveFormat

The wave format.

Methods

Read(Span<float>)

Fill the specified buffer with 32 bit floating point samples

public int Read(Span<float> buffer)

Parameters

buffer Span<float>

The buffer to fill with samples.

Returns

int

The number of samples written. Return 0 to signal end of stream.

Remarks

buffer's length must be a whole number of frames (a multiple of WaveFormat's channel count). A non-frame-aligned length silently drops the trailing partial frame.