Jump to content

BASS VST Struct Issue - (SOLVED!)


Recommended Posts

I'm having trouble trying to get _BASS_VST_GetInfo() to return a struct.

I can't figure this struct nor the function out. IsDllStruct() say it's not a struct in 2 places.

I'm sorely lacking experience in DLL structures. I have included the section from bass_vst.h and BassVST.au3 UDF.

I also have a feeling that the function_BASS_VST_GetInfo() is also having troubles.

Would someone please take a glance and tell me what's wrong with them?

Thanks in advance.

 

#cs

; copied from C++ bass_vst.h

typedef struct
{
    DWORD    channelHandle;         /* the channelHandle as given to BASS_VST_ChannelSetDSP() or returned by BASS_VST_ChannelCreate; 0 if no channel was assigned to the VST plugin */
    DWORD    uniqueID;              /* a unique ID for the VST plugin (the IDs are registered at Steinberg) */
    char     effectName[80];        /* the plugin's name */
    DWORD    effectVersion;         /* the plugin's version */
    DWORD    effectVstVersion;      /* the VST version, the plugin was written for */
    DWORD    hostVstVersion;        /* the VST version supported by BASS_VST, currently 2.4 */
    char     productName[80];       /* the product name, may be empty */
    char     vendorName[80];        /* the vendor name, may be empty */
    DWORD    vendorVersion;         /* vendor-specific version number */
    DWORD    chansIn;               /* max. number of possible input channels */
    DWORD    chansOut;              /* max. number of possible output channels */
    DWORD    initialDelay;          /* for algorithms which need input in the first place, in samples */
    DWORD    hasEditor;             /* can the BASS_VST_EmbedEditor() function be called? */
    DWORD    editorWidth;           /* initial/current width of the editor, also note BASS_VST_EDITOR_RESIZED; if the editor is not yet opened, this value may be 0 for some (very few) plugins! */
    DWORD    editorHeight;          /* same for the height */
#ifdef __aeffect__
    AEffect* aeffect;               /* the underlying AEffect object (see aeffectx.h in the VST SDK) */
#else
    void*    aeffect;
#endif
    DWORD    isInstrument;          /* 1=the VST plugin is an instrument, 0=the VST plugin is an effect */
    DWORD    dspHandle;             /* the internal DSP handle */
} BASS_VST_INFO;

BASS_VSTSCOPE BOOL BASS_VSTDEF(BASS_VST_GetInfo)
    (DWORD vstHandle, BASS_VST_INFO* ret);

#ce


; copied from AutoIt UDF BassVST.au3

Global $BASS_VST_INFO = "dword channelHandle;" & _  ;the channelHandle as given to BASS_VST_ChannelSetDSP()
        "dword uniqueID;" & _               ;a unique ID for the effect (the IDs are registered at Steinberg)
        "char[79] effectName;" & _          ;the effect name
        "dword effectVersion;" & _          ;the effect version
        "dword effectVstVersion;" & _               ;the VST version, the effect was written for
        "dword hostVstVersion;" & _         ;the VST version supported by BASS_VST, currently 2.4
        "char[79] productName;" & _         ;the product name, may be empty
        "char[79] vendorName;" & _          ;the vendor name, may be empty
        "dword vendorVersion;" & _          ;vendor-specific version number
        "dword chansIn;" & _                ;max. number of possible input channels
        "dword chansOut;" & _               ;max. number of possible output channels
        "dword initialDelay;" & _           ;for algorithms which need input in the first place, in milliseconds
        "dword hasEditor;" & _              ;can the BASS_VST_EmbedEditor() function be called?
        "dword editorWidth;" & _            ;initial/current width of the editor, also note BASS_VST_EDITOR_RESIZED
        "dword editorHeight;" & _           ;initial/current height of the editor, also note BASS_VST_EDITOR_RESIZED
        "ptr aeffect;" & _                          ;the underlying AEffect object (see the VST SDK)
        "char[255] rsvd;"


; copied from AutoIt UDF BassVST.au3 (modified to show results)

; #FUNCTION# ====================================================================================================================
; Name ..........: _BASS_VST_GetInfo
; Description ...:
; Syntax ........: _BASS_VST_GetInfo($vstHandle)
; Parameters ....: -    $
; Return values .: Success      - Returns True
;                  Failure      - Returns False and sets @ERROR as set by _Bass_ErrorGetCode()
; Author ........: Brett Francis (BrettF)
; Modified ......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Func _BASS_VST_GetInfo($vstHandle)
    Local $struct = DllStructCreate($BASS_VST_INFO)

    ;========================================
    MsgBox(0, '', IsDllStruct($struct)); = 0
    ;========================================

    Local $aReturn = DllCall($_ghbassVSTDll, "int", "BASS_VST_GetInfo", $vstHandle, "ptr", DllStructGetPtr($struct))
    If @error Then Return SetError(1, 1, 0)
    If $aReturn[0] = $BASS_DWORD_ERR Then Return SetError(_BASS_ErrorGetCode(), 0, 0)

    ;========================================
    MsgBox(0, '', IsDllStruct($struct)); = 0
    ;========================================

    Return $struct
EndFunc ;==>_BASS_VST_GetInfo

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

@ripdad

Just by looking at the actual struct definition and the struct created in AutoIt, that you posted, there are several problems:

  1. The AutoIt char buffers should be defined with the array designator on the var name not the data type, if you use a var name. (i.e. char buffer[80]) That is why the DllStructCreate() function is failing.
  2. The char buffers in the actual struct are defined to be 80 bytes.  The AutoIt char definitions are only 79 bytes.
  3. There are 18 fields in the actual struct.  The AutoIt struct has 17.
  4. The char[255] at the end of the AutoIt struct is not defined in the actual struct.
  5. The actual struct has 2 dwords (isInstrument & dspHandle) at the end that are not defined in the AutoIt struct.

You should probably take care of those issues and retest before trying to move forward.

 

Local $BASS_VST_INFO = _
            "dword channelHandle;" & _          ;the channelHandle as given to BASS_VST_ChannelSetDSP()
            "dword uniqueID;" & _               ;a unique ID for the effect (the IDs are registered at Steinberg)
            "char  effectName[80];" & _         ;the effect name
            "dword effectVersion;" & _          ;the effect version
            "dword effectVstVersion;" & _       ;the VST version, the effect was written for
            "dword hostVstVersion;" & _         ;the VST version supported by BASS_VST, currently 2.4
            "char  productName[80];" & _        ;the product name, may be empty
            "char  vendorName[80];" & _         ;the vendor name, may be empty
            "dword vendorVersion;" & _          ;vendor-specific version number
            "dword chansIn;" & _                ;max. number of possible input channels
            "dword chansOut;" & _               ;max. number of possible output channels
            "dword initialDelay;" & _           ;for algorithms which need input in the first place, in milliseconds
            "dword hasEditor;" & _              ;can the BASS_VST_EmbedEditor() function be called?
            "dword editorWidth;" & _            ;initial/current width of the editor, also note BASS_VST_EDITOR_RESIZED
            "dword editorHeight;" & _           ;initial/current height of the editor, also note BASS_VST_EDITOR_RESIZED
            "ptr   aeffect;" & _                ;the underlying AEffect object (see the VST SDK)
            "dword isInstrument;" & _
            "dword dspHandle"

 

Edited by TheXman
Link to comment
Share on other sites

2 hours ago, TheXman said:

1. The AutoIt char buffers should be defined with the array designator on the var name not the data type, if you use a var name. (i.e. char buffer[80]) That is why the DllStructCreate() function is failing.

I saw that before I posted this topic, but I thought it was perhaps the way that AutoIt handles tag structure.

After changing all your 5 points, the struct shows to be 1 on first MsgBox(), but the function returns with no DLL errors and no BASS errors and IsDllStruct() in script returns 0. Crazy too, because you would think there would be some kind of error coming from the DLL call.

Maybe there's something wrong with the DLL call?

I don't know at this point. I'm out of ideas.

 

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

12 minutes ago, ripdad said:

Maybe there's something wrong with the DLL call?

The DllCall does not look correct.  Looking at its definition in the header file, I would say that it should be something like this:

Local $aReturn = DllCall( _
                         $_ghbassVSTDll, "int", "BASS_VST_GetInfo", _
                         "dword"  , $vstHandle, _
                         "struct*", 0 _
                         )

 

Edited by TheXman
Link to comment
Share on other sites

Try putting the struct's varname in the call.  I'm flying blind because I don't have or use bass.dll and have no idea what else is in your code.

Local $aReturn = DllCall( _
                         $_ghbassVSTDll, "int", "BASS_VST_GetInfo", _
                         "dword"  , $vstHandle, _
                         "struct*", <struct var> _
                         )

It would help if you posted the code that generates the errors.  I would assume that it could also mean that the vstHandle is invalid.

Edited by TheXman
Link to comment
Share on other sites

TheXman,

That call returned 1 on the struct from function.

Now, hopefully I can use DLLStructGetData() to get the information from it.

If this works, it will fix 2 functions in the BassVST UDF and maybe a 3rd one.

I'll report back in a little while.

Thanks for your help, I really do appreciate it!

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

Link to comment
Share on other sites

2 functions fixed and working great!

The third one will have to wait for now. It will be new to the current BASS VST UDF with an updated DLL.

btw, I found this in the hFile (been that way for awhile)...

-----------------------------------------

 *  Version 2.2.0.3 (09/05/2006)
 *      - Program handling functions added
 *      - In BASS_VST_EmbedEditor(): parameter "void* parentWindow" changed to
 *        "HWND parentWindow" if windows.h was included before
 *      - In structure BASS_VST_INFO: element "void* aeffect" changed to <---
 *        "AEffect* aeffect" if aeffectx.h was included before <---
 *      - In the BASS_VST_INFO and BASS_VST_PARAM_INFO structures: "rsvd" <---
 *        elements removed as they seem to make more problems as they help <---
 *      - BASS_ErrorGetCode() now always returns BASS_OK on success of any
 *        BASS_VST function
 *      - BASS_VST works with BASS 2.2 or BASS 2.3 now

-----------------------------------------

The dll is now at version 2.4.1 - August 23, 2019

You're not flying as blind as you thought! Thanks so much again!

 

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
Share on other sites

That's great!  I'm glad we were able to get the issues worked out so quickly.

You're welcome!

:dance:

Link to comment
Share on other sites

  • ripdad changed the title to BASS VST Struct Issue - (SOLVED!)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...