Class PluginUIProcessor<TModel>
Base audio processor for plug-ins with a PluginUI editor: receives the notes played on the editor (TryDequeueUINote(out UINoteEvent)) and shares an object with the controller (CreateSharedState()), for meters, note activity or waveforms read by the UI without locks.
public abstract class PluginUIProcessor<TModel> : AudioProcessor<TModel>, IAudioConnectionPoint, IAudioProcessorProgramListData, IAudioProcessorUnitData, IAudioProcessor, IAudioPluginComponent, IAudioPluginObject where TModel : AudioProcessorModel, new()
Type Parameters
TModelParameter model shared with the controller.
- Inheritance
-
AudioPluginComponentAudioProcessor<TModel>PluginUIProcessor<TModel>
- Implements
-
IAudioConnectionPointIAudioProcessorProgramListDataIAudioProcessorUnitDataIAudioProcessorIAudioPluginComponentIAudioPluginObject
- Inherited Members
-
AudioProcessor<TModel>.AddDefaultStereoAudioInput()AudioProcessor<TModel>.AddDefaultStereoAudioOutput()AudioProcessor<TModel>.AddDefaultEventInput()AudioProcessor<TModel>.GetBusInfoList(BusMediaType, BusDirection)AudioProcessor<TModel>.GetAudioOutputBuses()AudioProcessor<TModel>.GetAudioInputBuses()AudioProcessor<TModel>.GetEventOutputBuses()AudioProcessor<TModel>.GetEventInputBuses()AudioProcessor<TModel>.IsSampleSizeSupported(AudioSampleSize)AudioProcessor<TModel>.Initialize(AudioHostApplication)AudioProcessor<TModel>.TryGetBusRoutingInfo(in BusRoutingInfo, out BusRoutingInfo)AudioProcessor<TModel>.OnSetupProcessing(in AudioProcessSetupData)AudioProcessor<TModel>.SaveState(PortableBinaryWriter)AudioProcessor<TModel>.PreProcess(in AudioProcessData)AudioProcessor<TModel>.Process(in AudioProcessData)AudioProcessor<TModel>.ProcessMain(in AudioProcessData)AudioProcessor<TModel>.ProcessRecalculate(in AudioProcessData)AudioProcessor<TModel>.ProcessParameterChanges(in AudioProcessData)AudioProcessor<TModel>.ProcessEvents(in AudioProcessData)AudioProcessor<TModel>.ProcessEvent(in AudioEvent)AudioProcessor<TModel>.ProcessByPass(in AudioProcessData)AudioProcessor<TModel>.PostProcessCheckSilence(in AudioProcessData)AudioProcessor<TModel>.SampleSizeSupportAudioProcessor<TModel>.ModelAudioProcessor<TModel>.ProcessContextRequirementFlagsAudioProcessor<TModel>.ControllerClassIdAudioProcessor<TModel>.InputOutputModeAudioProcessor<TModel>.LatencySamplesAudioProcessor<TModel>.TailSamplesAudioProcessor<TModel>.IsActiveAudioProcessor<TModel>.ProcessSetupDataAudioProcessor<TModel>.IsProcessingAudioProcessor<TModel>.ShouldByPassAudioPluginComponent.OnDisconnect(IAudioConnectionPoint)AudioPluginComponent.HostAudioPluginComponent.ConnectionPoint
Examples
public sealed class SynthShared { public NoteActivity Notes { get; } = new(); }
public sealed class SynthProcessor : PluginUIProcessor<SynthModel>
{
private readonly SynthShared _shared = new();
protected override object? CreateSharedState() => _shared;
protected override void ProcessMain(in AudioProcessData data)
{
while (TryDequeueUINote(out var note)) { /* start / stop voices */ }
...
}
}
Remarks
Messages arrive on the UI thread; notes wait in a bounded queue that the audio thread drains at the start of each block, so they play at sample offset 0 of the next block. Override OnMessage(AudioMessage), OnConnect(IAudioConnectionPoint), RestoreState(PortableBinaryReader) or Terminate() only with a call to the base method.
The shared state is a plain object created once per processor instance. Both VST3 components of a plug-in run in
the same process, which makes this the simplest way to feed real-time displays: write it from the audio thread
with lock-free types (PeakValue, AudioRingBuffer, NoteActivity), read it from the UI.
Constructors
PluginUIProcessor(AudioSampleSizeSupport)
Creates the processor.
protected PluginUIProcessor(AudioSampleSizeSupport sampleSizeSupport)
Parameters
sampleSizeSupportAudioSampleSizeSupportSample sizes the processor supports.
Properties
SharedState
The object shared with the controller, or null before the components connect.
protected object? SharedState { get; }
Property Value
UINotes
Notes received from the editor, waiting for the audio thread.
protected UINoteQueue UINotes { get; }
Property Value
Methods
CreateSharedState()
Creates the object shared with the controller (called on the UI thread when the components connect, once per
initialization). The default returns null: nothing is shared. The processor keeps its own reference to
the object for the audio thread.
protected virtual object? CreateSharedState()
Returns
- object
The shared object, or
null.
OnConnect(IAudioConnectionPoint)
Called when this component is connected to another component.
protected override void OnConnect(IAudioConnectionPoint connectionPoint)
Parameters
connectionPointIAudioConnectionPoint
OnMessage(AudioMessage)
Called when this component receives a message from another component.
protected override void OnMessage(AudioMessage message)
Parameters
messageAudioMessageThe message. The sender owns it: it is valid during this call only and must not be disposed.
RestoreState(PortableBinaryReader)
This method is called when restoring the state to the associated model of this processor.
protected override void RestoreState(PortableBinaryReader reader)
Parameters
readerPortableBinaryReaderThe output reader.
Terminate()
Called when this component is terminated.
protected override void Terminate()
TryConsumeStateRestored()
true once after the host restored the processor state (project or preset load): the parameters changed
without parameter-change events, so derived processors refresh their DSP settings (audio thread, no allocation).
protected bool TryConsumeStateRestored()
Returns
- bool
trueif a state was restored since the previous call.
TryDequeueUINote(out UINoteEvent)
Takes the next note played on the editor (audio thread, no allocation).
protected bool TryDequeueUINote(out UINoteEvent note)
Parameters
noteUINoteEventThe event.
Returns
- bool
falsewhen no note is waiting.