Class Vst3InstrumentSampleProvider
Exposes a VST 3® instrument (VSTi) as a continuous ISampleProvider: each
Read(Span<float>) pulls the synth's output by driving Process(ReadOnlySpan<float>, Span<float>, int), with
notes supplied out-of-band via SendNoteOn(int, float, int, long) / SendNoteOff (e.g.
from a live MIDI input). Unlike Vst3EffectSampleProvider, this source never ends —
it keeps producing audio (silence when no notes are sounding), which is what a realtime output
such as WasapiPlayer expects.
public sealed class Vst3InstrumentSampleProvider : ISampleProvider
- Inheritance
-
Vst3InstrumentSampleProvider
- Implements
- Inherited Members
- Extension Methods
Remarks
Most instruments take no audio input; this provider feeds their (often present but ignored)
input bus silence. Instruments that genuinely consume audio — vocoders, or synths that mix an
incoming signal with their own output — can be driven by passing an audioInput
source to the constructor, whose format must match the plug-in's negotiated input.
All Read(Span<float>) calls happen on the audio render thread. Notes may be sent from any thread — Vst3Plugin marshals them across via a lock-free queue.
Constructors
Vst3InstrumentSampleProvider(Vst3Plugin, ISampleProvider?)
Wraps an instrument plug-in as a continuous sample source.
public Vst3InstrumentSampleProvider(Vst3Plugin plugin, ISampleProvider? audioInput = null)
Parameters
pluginVst3PluginAn instrument plug-in (see IsInstrument).
audioInputISampleProviderOptional audio fed to the instrument's input bus (for vocoders / audio-consuming synths). When
nullthe input bus, if present, receives silence. Must match the plug-in's negotiated input channel count and sample rate.
Properties
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
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.