BASS.NET API for the Un4seen BASS Audio LibraryBassVstBASS_VST_SetCallback Method BASS.NET API for the Un4seen BASS Audio Library
Assign a callback function to a vstHandle.

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

[DllImportAttribute("bass_vst.dll", CharSet = CharSet.Auto)]
public static bool BASS_VST_SetCallback(
	int vstHandle,
	VSTPROC proc,
	IntPtr user
)

Parameters

vstHandle
Type: SystemInt32
The VST effect handle as returned by BASS_VST_ChannelSetDSP(Int32, String, BASSVSTDsp, Int32).
proc
Type: Un4seen.Bass.AddOn.VstVSTPROC
The user defined callback delegate (see VSTPROC).
user
Type: SystemIntPtr
User instance data to pass to the callback function.

Return Value

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

The callback function is called with one of the following actions (see BASSVSTAction):

Actions:
BASS_VST_PARAM_CHANGEDSome parameters are changed by the editor opened by BASS_VST_EmbedEditor(Int32, IntPtr), NOT called if you call BASS_VST_SetParam(Int32, Int32, Single).
BASS_VST_EDITOR_RESIZEDThe embedded editor window should be resized, the new width/height can be found in param1/param2 and in BASS_VST_GetInfo(Int32, BASS_VST_INFO).
BASS_VST_AUDIO_MASTERCan be used to subclass the audioMaster callback (see the VST SDK), param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure.

Unless defined otherwise, the callback function should always return 0.

Examples

VB
Private _myVstProc As VSTPROC ' keep the callback delegate in a global member
...
' your VST callback - referenced below by BASS_VST_SetCallback()
Private Function YourVstProc(vstHandle As Integer, action As BASSVSTAction, param1 As Integer, param2 As Integer, user As IntPtr) As Integer
  Select Case action
    Case BASSVSTAction.BASS_VST_PARAM_CHANGED
      ' we get notified that the user has changed some sliders in the editor - 
      ' do what to do here ...
    Case BASSVSTAction.BASS_VST_EDITOR_RESIZED
      ' the editor window requests a new size,
      ' maybe we should resize the window the editor is embedded in?
      ' the new width/height can be found in param1/param2
    Case BASSVSTAction.BASS_VST_AUDIO_MASTER
      ' this is only for people familiar with the VST SDK,
      ' param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure
      ' which contains all information needed
  End Select
  Return 0
End Function
...
' open the VST editor (e.g. if we are inside a System.Windows.Forms.Form)
BassVst.BASS_VST_EmbedEditor(vstHandle, Me.Handle)
' we want to get notified for parameter changes etc.
_myVstProc = New VSTPROC(AddressOf YourVstProc)
BassVst.BASS_VST_SetCallback(vstHandle, _myVstProc, IntPtr.Zero)
private VSTPROC _myVstProc; // keep the callback delegate in a global member
...
// your VST callback - referenced below by BASS_VST_SetCallback()
private int YourVstProc(int vstHandle, BASSVSTAction action, int param1, int param2, IntPtr user)
{
  switch (action)
  {
    case BASSVSTAction.BASS_VST_PARAM_CHANGED:
      // we get notified that the user has changed some sliders in the editor - 
      // do what to do here ...
      break;
    case BASSVSTAction.BASS_VST_EDITOR_RESIZED:
      // the editor window requests a new size,
      // maybe we should resize the window the editor is embedded in?
      // the new width/height can be found in param1/param2
      break;
    case BASSVSTAction.BASS_VST_AUDIO_MASTER:
      // this is only for people familiar with the VST SDK,
      // param1 is a pointer to a BASS_VST_AUDIO_MASTER_PARAM structure
      // which contains all information needed
      break;
  }
  return 0;
}
...
// open the VST editor (e.g. if we are inside a System.Windows.Forms.Form)
BassVst.BASS_VST_EmbedEditor(vstHandle, this.Handle);
// we want to get notified for parameter changes etc.
_myVstProc = new VSTPROC(YourVstProc);
BassVst.BASS_VST_SetCallback(vstHandle, _myVstProc, IntPtr.Zero);
See Also

Reference