Table of Contents

Class Vst3PluginView

Namespace
NAudio.Vst3
Assembly
NAudio.Vst3.dll

A VST 3® plug-in's embedded editor window (its GUI). Wraps the native IPlugView and the host-side IPlugFrame callback.

public sealed class Vst3PluginView : IDisposable
Inheritance
Vst3PluginView
Implements
Inherited Members

Remarks

Windows-only in this release: the view is parented to an HWND supplied by the host UI framework — a WPF HwndHost, a WinForms Control.Handle, or a bare Win32 window. Obtain an instance from CreateView().

Threading. Every member must be called on the host's UI (STA) thread — the same thread that created the view. The VST 3 threading contract forbids touching the editor from the audio thread; violations crash inside plug-in code in ways that masquerade as plug-in bugs but are host bugs. The creating thread is captured at construction and asserted on each entry point.

Lifetime. Dispose the view before the owning Vst3Plugin. The native view is owned by the controller; releasing it after the controller has terminated is undefined.

Methods

AttachTo(nint, float)

Embeds the editor in the supplied parent window. Pushes the host's DPI scale to the view (if the view supports IPlugViewContentScaleSupport) before attaching.

public void AttachTo(nint parentHwnd, float contentScaleFactor = 1)

Parameters

parentHwnd nint

The parent window handle to host the editor under.

contentScaleFactor float

The host's DPI scale (1.0 at 96 DPI, 1.25 at 120 DPI, 2.0 at 192 DPI). Critical on high-DPI displays — without it many editors render at the wrong size.

Exceptions

NotSupportedException

The plug-in view does not support HWND embedding.

CanResize()

true when the plug-in advertises a resizable editor (IPlugView::canResize). Fixed-size editors return false; the host should not let the user resize the window.

public bool CanResize()

Returns

bool

CheckSizeConstraint(int, int)

Asks the plug-in to clamp a proposed size to one it can actually display (IPlugView::checkSizeConstraint). Returns the (possibly adjusted) size.

public Vst3ViewSize CheckSizeConstraint(int width, int height)

Parameters

width int
height int

Returns

Vst3ViewSize

Detach()

Detaches the editor from its parent window (IPlugView::removed). Call this before destroying the parent HWND — the SDK requires the view be removed while its parent is still valid. Idempotent and also invoked by Dispose(); safe to call if never attached.

public void Detach()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

GetSize()

Current size the plug-in reports for its editor (IPlugView::getSize).

public Vst3ViewSize GetSize()

Returns

Vst3ViewSize

SetContentScaleFactor(float)

Pushes an updated DPI scale to the view at runtime (e.g. the window moved monitors).

public void SetContentScaleFactor(float factor)

Parameters

factor float

SetSize(int, int)

Tells the plug-in the editor was resized by the host (IPlugView::onSize). Call this when the user resizes the host window, after honouring CheckSizeConstraint(int, int).

public void SetSize(int width, int height)

Parameters

width int
height int

Events

Resized

Raised when the plug-in asks the host to resize its window (IPlugFrame::resizeView). The host should resize the parent window to the supplied size; the view is told the new size automatically after the event returns. Raised on the UI thread.

public event EventHandler<Vst3ViewSize>? Resized

Event Type

EventHandler<Vst3ViewSize>