Overview
TheVstAudioProcessor class implements the IAudioProcessor interface for VST2 plugins. It handles audio buffering, block size management, and bridges between Lumix’s audio processing pipeline and the VST plugin’s requirements.
Properties
The underlying
VstPlugin instance managed by this processor.Provides access to MIDI functionality, plugin information, and window management.Whether the audio processor is enabled. When disabled, audio passes through unprocessed.Defaults to
true.Flag indicating whether this processor should be deleted.When
true, the processor skips audio processing.Flag indicating whether this processor should be duplicated.
Constructor
The VST plugin instance to process audio with.
Example
Methods
Process
The incoming unprocessed audio buffer with interleaved stereo samples.
The buffer to write processed audio to.
The number of samples to process.
Implementation Details
- Automatically initializes circular buffers on first call
- Handles block size changes dynamically
- Uses circular buffering to adapt Lumix’s variable buffer sizes to VST’s fixed block size requirements
- For VSTi plugins, generates audio without requiring input
- For VST effects, processes the input audio
Example
GetPlugin
VstPlugin instance if T is VstPlugin.
The type to retrieve. Only
VstPlugin is supported.VstPlugin instance if T is VstPlugin, otherwise null.
Example
Audio Processing Pipeline
TheVstAudioProcessor uses a sophisticated buffering system to handle the impedance mismatch between Lumix’s variable buffer sizes and VST’s fixed block size requirements:
Processing Flow
- Input Buffering: Incoming audio is written to a circular input buffer
- Block Processing: When enough samples accumulate (≥ block size), they’re processed through the VST
- Output Buffering: Processed audio is stored in a circular output buffer
- Output Retrieval: The requested number of samples is read from the output buffer
Usage Example
Performance Considerations
- Circular Buffers: The processor maintains circular buffers sized at 2× the typical buffer size to prevent overflow
- Block Size Updates: Block size changes are detected and handled dynamically without audio glitches
- Lazy Initialization: Buffers are only created when audio processing first occurs
- Zero-Copy When Possible: The implementation minimizes buffer copying operations
Implementation Notes
- Audio format is interleaved stereo (L, R, L, R, …)
- The processor converts between interleaved format and VST’s planar format (separate L/R channels)
- Sample rate is configured from
AudioSettings.SampleRate - Processing precision is set to 32-bit float (
VstProcessPrecision.Process32) - For VSTi plugins, input buffers are not populated (the synth generates audio internally)
- The
DeleteRequestedflag should be checked before removal to ensure clean shutdown
See Also
- VstPlugin - VST plugin management
- IAudioProcessor - Audio processor interface
- PluginChainSampleProvider - Plugin chain management