Author Topic: How to use BASS_VST_SetCallback  (Read 57 times)

Phil75

  • Posts: 2
How to use BASS_VST_SetCallback
« on: 7 Jan '25 - 20:29 »
Hello,

everything works with the VST, but...
I display the VST. I modify the value of a potentiometer. The value of "param1" or "param2" remains the same.
Even if I modify another potentiometer.
I think I do not receive the parameter number or its value.
How to do it?
What does "param2" and "param2" transmit?

Thank you

Code: [Select]
    hVSTProc = New VSTPROC(AddressOf VSTproc)
    BassVst.BASS_VST_SetCallback(hVSThandle, hVSTProc, IntPtr.Zero)

    Private Function VSTproc(hVSThandle 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
                Me.LabelVST.Text = param2.ToString
            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

jpf

  • Posts: 201
Re: How to use BASS_VST_SetCallback
« Reply #1 on: 8 Jan '25 - 03:37 »
This is how I use the callback, and it works for me:

The callback is just a notification that something changed.

When BASSVSTAction is BASS_VST_PARAM_CHANGED you can get the new values of the parameters by calling BASS_VST_GetParamCount and BASS_VST_GetParam. This is useful if you want to preserve them for later runs of your app.

When BASSVSTAction is BASS_VST_EDITOR_RESIZED you're supposed to resize the window the editor is embedded into. Call BASS_VST_GetInfo and resize it according to the EditorHeight and the EditorWidth members of the BASS_VST_Info structure you pass to BASS_VST_GetInfo.

Even if the documentation says the new size should be in Param1 and Param2 of the callback I found this isn't always true, and most of the times some values are actually there they're not reliable.

With the VSTs I use BASS_VST_EDITOR_RESIZED is called only once a few ms after you call BASS_VST_EmbedEditor (which you should do each time you destroy and recreate the window).

Also, with the VSTs I use, the editor is always placed at the upper left corner of the work area of the window I supply. You can do whatever you want on the rest of the work area. I use that to place additional controls.

Notice that many VSTs don't expose a editor. Those (at least the ones I use) never fire the callback. For those I still provide a custom editor I build at runtime according to the info I get from  BASS_VST_GetInfo, BASS_VST_GetParamCount, BASS_VST_GetParamInfo and BASS_VST_GetParam. Beware! Some VSTs expose a lot of obscure parameters which may clog your custom editor window with the sliders you draw for them. It's wise to allow the user to themporarily hide the ones he/she doesn't need.

Many of the VSTs I tried sooner or later crash my apps. I was able to prevent some of the crashes by calling their functions inside try...catch exception blocks. To avoid all of the crashes the only workaround I found was calling the VSTs from a different process, which makes most of them useless for real time processing.

I'm still waiting for some kind soul to add support for VST3.

Phil75

  • Posts: 2
Re: How to use BASS_VST_SetCallback
« Reply #2 on: 8 Jan '25 - 12:05 »
So if I understand correctly, I can know that a parameter has changed, but I can't know which one (Index).
Thanks @jpf for all these explanations  :)