BASS.NET API for the Un4seen BASS Audio LibraryBassVstBASS_VST_EmbedEditor Method BASS.NET API for the Un4seen BASS Audio Library
Many VST effects come along with an graphical parameters editor; with the following function, you can embed these editors to your user interface.

Namespace: Un4seen.Bass.AddOn.Vst
Assembly: Bass.Net (in Bass.Net.dll) Version:

public static bool BASS_VST_EmbedEditor(
	int vstHandle,
	IntPtr parentWindow


Type: SystemInt32
The VST effect handle as returned by BASS_VST_ChannelSetDSP(Int32, String, BASSVSTDsp, Int32).
Type: SystemIntPtr
The IntPtr to the window handle (HWND) of the parents window in which the editor should be embedded (e.g. use a new modeless dialog or user control).

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.

To embed the editor to another window, call this function with parentWindow set to the HWND (this.Handle) of the parent window. To check, if an effect has an editor, see the hasEditor flag set by BASS_VST_GetInfo(Int32, BASS_VST_INFO).

To "unembed" the editor, call this function with parentWindow set to .

If you create the editor window independently of a real channel (by skipping the channel parameter when calling BASS_VST_ChannelSetDSP(Int32, String, BASSVSTDsp, Int32)) and the editor displays any spectrums, VU-meters or such, the data for this come from the most recent channel using the same effect and the same scope. The scope can be set by BASS_VST_SetScope(Int32, Int32) to any ID, the default is 0.

In order to create a new window in which the editor should be embedded, it is a good idea to call BASS_VST_GetInfo(Int32, BASS_VST_INFO) in order to retrieve the editors height and width.


Private _vstHandle As Integer = 0
_vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, 
                     "C:\VstPlugins\Ambience.dll", BASSVSTDsp.BASS_VST_DEFAULT, 1)
' show the embedded editor
Dim vstInfo As New BASS_VST_INFO()
If BassVst.BASS_VST_GetInfo(vstHandle, vstInfo) AndAlso vstInfo.hasEditor Then
  ' create a new System.Windows.Forms.Form
  Dim f As New Form()
  f.Width = vstInfo.editorWidth + 4
  f.Height = vstInfo.editorHeight + 34
  AddHandler f.Closing, AddressOf f_Closing
  f.Text = vstInfo.effectName
  BassVst.BASS_VST_EmbedEditor(_vstHandle, f.Handle)
End If

Private Sub f_Closing(sender As Object, e As CancelEventArgs)
  ' unembed the VST editor
  BassVst.BASS_VST_EmbedEditor(_vstHandle, IntPtr.Zero)
End Sub
private int _vstHandle = 0;
_vstHandle = BassVst.BASS_VST_ChannelSetDSP(_stream, 
                     "C:\\VstPlugins\\Ambience.dll", BASSVSTDsp.BASS_VST_DEFAULT, 1 );
// show the embedded editor
if ( BassVst.BASS_VST_GetInfo(vstHandle, vstInfo) && vstInfo.hasEditor )
  // create a new System.Windows.Forms.Form
  Form f = new Form();
  f.Width = vstInfo.editorWidth+4;
  f.Height = vstInfo.editorHeight+34;
  f.Closing += new CancelEventHandler(f_Closing);
  f.Text = vstInfo.effectName;
  BassVst.BASS_VST_EmbedEditor(_vstHandle, f.Handle);

private void f_Closing(object sender, CancelEventArgs e)
  // unembed the VST editor
  BassVst.BASS_VST_EmbedEditor(_vstHandle, IntPtr.Zero);
See Also