Author Topic: BASS_VST_EmbedEditor for macOS with Delphi 10.3.3 Rio  (Read 951 times)

victor

  • Posts: 137
while rewriting my app to macOS using Delphi 10.3.3 Rio i'm having trouble with the parameters of "BASS_VST_EmbedEditor".
What window handle do i need to pass to "BASS_VST_EmbedEditor" so that the editor window of the VST effect/instrument can be shown by macOS in 64bit on a Delphi form?

Thank you!
« Last Edit: 5 Dec '19 - 11:12 by victor »

Ian @ un4seen

  • Administrator
  • Posts: 22959
I haven't used BASS_VST with Delphi or on OSX myself, so I'm afraid I can't answer your question but perhaps looking at the BASS_VST_EmbedEditor function's source code will give you some ideas on what it wants? You can check that here:

   https://github.com/r10s/BASS_VST/blob/dc9677fd18328e770945c1df1f736db1da26b2c9/source/bass_vst_impl.cpp

victor

  • Posts: 137
thanks for the link.
On Windows BASS_VST_EmbedEditor needs the HWND of a regular form (created by Delphi).

On macOS 64-bit it needs to be a contentView of a cacaoWindow.
I made a small test app, that only loads the VST instrument and tries to display the editor window
Unfortunatelly on the first attempt to load it shows an empty editor window.
Only on the second atempt of load, embedEditor and show the editor is shown and is responsive ...  :(
« Last Edit: 13 Dec '19 - 03:00 by victor »

victor

  • Posts: 137
i found the solution by accident: it appears that with Delphi, the form that the VST plugin editor will be displayed on needs to be already visible at the moment BASS_VST_EmbedEditor links the editor to it.

Btw. is there any updated bass_vst.pas?
« Last Edit: 13 Dec '19 - 21:21 by victor »

Ian @ un4seen

  • Administrator
  • Posts: 22959
Good to see that you have found a solution. And thanks for posting it, in case anybody else has the same problem.

Regarding bass_vst.pas, I don't think there is one currently, at least not in the BASS_VST package. Where did you get it from?

please

  • Guest
Code: [Select]
Unit Bass_VST;

interface

uses
  Windows;


const
  BASS_VST_PARAM_CHANGED = 1;
  BASS_VST_EDITOR_RESIZED = 2;
  BASS_VST_AUDIO_MASTER = 3;

  BASS_VST_ERROR_NOINPUTS     = 3000;// the given effect has no inputs and is probably a VST instrument and no effect
  BASS_VST_ERROR_NOOUTPUTS    = 3001; // the given effect has no outputs
  BASS_VST_ERROR_NOREALTIME   = 3002; // the given effect does not support realtime processing


type

BASS_VST_PARAM_INFO = record
    name :  array [0..15] of Char;         // examples: Time, Gain, RoomType
    FUnit : array [0..15] of Char;         // examples: sec, dB, type
    Display : array [0..15] of Char;         // the current value in a readable format, examples: 0.5, -3, PLATE
    defaultValue : single;                 // the default value
    rsvd : array [0..255] of Char;
end;

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



VSTPROC = procedure (vstHandle : DWORD;Action : DWORD;Param1,Param2,User : DWORD);stdcall;

const BASS_VSTDLL = 'bass_vst.dll';

function BASS_VST_ChannelSetDSP (Channel : DWORD;const DLLFile : PChar;flags: DWORD; priority:Integer): DWORD;stdcall;external BASS_VSTDLL;
function BASS_VST_ChannelRemoveDSP(Channel : DWORD;vstHandle : DWORD): Bool;stdcall;external BASS_VSTDLL;

 function BASS_VST_EmbedEditor(Channel : DWORD;ParentWindow : hwnd): Bool;stdcall;external BASS_VSTDLL;

function BASS_VST_GetInfo(VSTHandle : DWORD;pInfo: Pointer):Bool;stdcall;external BASS_VSTDLL;
function BASS_VST_GetParam(vstHandle : DWORD;paramIndex : integer): single;stdcall;external BASS_VSTDLL;
function BASS_VST_SetParam(vstHandle : DWORD;paramIndex : integer;value : single): Bool;stdcall;external BASS_VSTDLL;
function BASS_VST_GetParamCount(vstHandle : DWORD) : integer;stdcall;external BASS_VSTDLL;
function BASS_VST_GetParamInfo(vstHandle : DWORD;paramIndex : Integer;var Info : BASS_VST_PARAM_INFO): boolean;stdcall;external BASS_VSTDLL;
function BASS_VST_Resume(vstHandle : DWORD):Bool;stdcall;external BASS_VSTDLL;
function BASS_VST_SetCallback(vstHandle : DWORD; PROC : Pointer; user : DWORD):Bool;stdcall;external BASS_VSTDLL;
function BASS_VST_SetLanguage(const Lang : PChar):Bool;stdcall;external BASS_VSTDLL;
function BASS_VST_SetBypass(vstHandle : DWORD; state:boolean):bool;stdcall;external BASS_VSTDLL;
function BASS_VST_GetBypass(vstHandle : DWORD):dword;stdcall;external BASS_VSTDLL;

implementation

end.

i hope that works and all function implement.


Ian @ un4seen

  • Administrator
  • Posts: 22959
Thanks for that. It looks like there are some things missing though. Perhaps it's based on an older version of BASS_VST?

please

  • Guest
Thanks for that. It looks like there are some things missing though. Perhaps it's based on an older version of BASS_VST?

https://codes-sources.commentcamarche.net/forum/affich-1321573-liberer-les-ressources-object


victor

  • Posts: 137
Regarding bass_vst.pas, I don't think there is one currently, at least not in the BASS_VST package. Where did you get it from?
I had a very old one writen by Chris (if i remember correctly) and updated it myself. Here's the one I use:

Code: [Select]
unit BassVST;

interface

uses
    Windows;


const
     BASS_VST_KEEP_CHANS       = 1;
     BASS_VST_PARAM_CHANGED    = 1;
     BASS_VST_EDITOR_RESIZED   = 2;
     BASS_VST_AUDIO_MASTER     = 3;

     BASS_VST_ERROR_NOINPUTS   = 3000; // the given effect has no inputs and is probably a VST instrument and no effect
     BASS_VST_ERROR_NOOUTPUTS  = 3001; // the given effect has no outputs
     BASS_VST_ERROR_NOREALTIME = 3002; // the given effect does not support realtime processing

     audioMasterAutomate = 0;
     audioMasterVersion = 1;
     audioMasterCurrentId = 2;
     audioMasterIdle = 3;
     audioMasterPinConnected = 4;
     // unsupported? = 5;
     audioMasterWantMidi = 6;
     audioMasterGetTime = 7;
     audioMasterProcessEvents = 8;
     audioMasterSetTime = 9;
     audioMasterTempoAt = 10;
     audioMasterGetNumAutomatableParameters = 11;
     audioMasterGetParameterQuantization = 12;
     audioMasterIOChanged = 13;
     audioMasterNeedIdle = 14;
     audioMasterSizeWindow = 15;
     audioMasterGetSampleRate = 16;
     audioMasterGetBlockSize = 17;
     audioMasterGetInputLatency = 18;
     audioMasterGetOutputLatency = 19;
     audioMasterGetPreviousPlug = 20;
     audioMasterGetNextPlug = 21;
     audioMasterWillReplaceOrAccumulate = 22;
     audioMasterGetCurrentProcessLevel = 23;
     audioMasterGetAutomationState = 24;
     audioMasterOfflineStart = 25;
     audioMasterOfflineRead = 26;
     audioMasterOfflineWrite = 27;
     audioMasterOfflineGetCurrentPass = 28;
     audioMasterOfflineGetCurrentMetaPass = 29;
     audioMasterSetOutputSampleRate = 30;
     // unsupported? = 31;
     audioMasterGetSpeakerArrangement = 31; // deprecated in 2.4?
     audioMasterGetVendorString = 32;
     audioMasterGetProductString = 33;
     audioMasterGetVendorVersion = 34;
     audioMasterVendorSpecific = 35;
     audioMasterSetIcon = 36;
     audioMasterCanDo = 37;
     audioMasterGetLanguage = 38;
     audioMasterOpenWindow = 39;
     audioMasterCloseWindow = 40;
     audioMasterGetDirectory = 41;
     audioMasterUpdateDisplay = 42;
     audioMasterBeginEdit = 43;
     audioMasterEndEdit = 44;
     audioMasterOpenFileSelector = 45;
     audioMasterCloseFileSelector = 46; // currently unused
     audioMasterEditFile = 47; // currently unused
     audioMasterGetChunkFile = 48; // currently unused
     audioMasterGetInputSpeakerArrangement = 49; // currently unused


     MIDI_EVENT_NOTE            = 1;
     MIDI_EVENT_PROGRAM         = 2;
     MIDI_EVENT_CHANPRES        = 3;
     MIDI_EVENT_PITCH           = 4;
     MIDI_EVENT_PITCHRANGE      = 5;
     MIDI_EVENT_DRUMS           = 6;
     MIDI_EVENT_FINETUNE        = 7;
     MIDI_EVENT_COARSETUNE      = 8;
     MIDI_EVENT_MASTERVOL       = 9;
     MIDI_EVENT_BANK            = 10;
     MIDI_EVENT_MODULATION      = 11;
     MIDI_EVENT_VOLUME          = 12;
     MIDI_EVENT_PAN             = 13;
     MIDI_EVENT_EXPRESSION      = 14;
     MIDI_EVENT_SUSTAIN         = 15;
     MIDI_EVENT_SOUNDOFF        = 16;
     MIDI_EVENT_RESET           = 17;
     MIDI_EVENT_NOTESOFF        = 18;
     MIDI_EVENT_PORTAMENTO      = 19;
     MIDI_EVENT_PORTATIME       = 20;
     MIDI_EVENT_PORTANOTE       = 21;
     MIDI_EVENT_MODE            = 22;
     MIDI_EVENT_REVERB          = 23;
     MIDI_EVENT_CHORUS          = 24;
     MIDI_EVENT_CUTOFF          = 25;
     MIDI_EVENT_RESONANCE       = 26;
     MIDI_EVENT_RELEASE         = 27;
     MIDI_EVENT_ATTACK          = 28;
     MIDI_EVENT_DECAY           = 29;
     MIDI_EVENT_REVERB_MACRO    = 30;
     MIDI_EVENT_CHORUS_MACRO    = 31;
     MIDI_EVENT_REVERB_TIME     = 32;
     MIDI_EVENT_REVERB_DELAY    = 33;
     MIDI_EVENT_REVERB_LOCUTOFF = 34;
     MIDI_EVENT_REVERB_HICUTOFF = 35;
     MIDI_EVENT_REVERB_LEVEL    = 36;
     MIDI_EVENT_CHORUS_DELAY    = 37;
     MIDI_EVENT_CHORUS_DEPTH    = 38;
     MIDI_EVENT_CHORUS_RATE     = 39;
     MIDI_EVENT_CHORUS_FEEDBACK = 40;
     MIDI_EVENT_CHORUS_LEVEL    = 41;
     MIDI_EVENT_CHORUS_REVERB   = 42;
     MIDI_EVENT_USERFX          = 43;
     MIDI_EVENT_USERFX_LEVEL    = 44;
     MIDI_EVENT_USERFX_REVERB   = 45;
     MIDI_EVENT_USERFX_CHORUS   = 46;
     MIDI_EVENT_DRUM_FINETUNE   = 50;
     MIDI_EVENT_DRUM_COARSETUNE = 51;
     MIDI_EVENT_DRUM_PAN        = 52;
     MIDI_EVENT_DRUM_REVERB     = 53;
     MIDI_EVENT_DRUM_CHORUS     = 54;
     MIDI_EVENT_DRUM_CUTOFF     = 55;
     MIDI_EVENT_DRUM_RESONANCE  = 56;
     MIDI_EVENT_DRUM_LEVEL      = 57;
     MIDI_EVENT_DRUM_USERFX     = 58;
     MIDI_EVENT_SOFT            = 60;
     MIDI_EVENT_SYSTEM          = 61;
     MIDI_EVENT_TEMPO           = 62;
     MIDI_EVENT_SCALETUNING     = 63;
     MIDI_EVENT_CONTROL         = 64;
     MIDI_EVENT_CHANPRES_VIBRATO = 65;
     MIDI_EVENT_CHANPRES_PITCH  = 66;
     MIDI_EVENT_CHANPRES_FILTER = 67;
     MIDI_EVENT_CHANPRES_VOLUME = 68;
     MIDI_EVENT_MODRANGE        = 69;
     MIDI_EVENT_BANK_LSB        = 70;
     MIDI_EVENT_KEYPRES         = 71;
     MIDI_EVENT_KEYPRES_VIBRATO = 72;
     MIDI_EVENT_KEYPRES_PITCH   = 73;
     MIDI_EVENT_KEYPRES_FILTER  = 74;
     MIDI_EVENT_KEYPRES_VOLUME  = 75;


type
    BASS_VST_PARAM_INFO = record
                          Name :  array [0..15] of char;   // examples : time, gain, roomtype
                          FUnit : array [0..15] of char;   // examples : sec, dB, type
                          Display : array [0..15] of char; // the current value in a readable format, examples: 0.5, -3, PLATE
                          DefaultValue : single;           // the default value
                          rsvd : array [0..255] of char;
                          end;

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

    BASS_VST_AUDIO_MASTER_PARAM = record
                                  aeffect : pointer;
                                  opcode : cardinal;
                                  index : cardinal;
                                  value : cardinal;
                                  ptr : pointer;
                                  opt : single;
                                  doDefault : cardinal;
                                  end;
   
    vstByte = array of byte;

    VSTPROC = procedure (vstHandle : cardinal; Action : cardinal; Param1, Param2, User : cardinal); stdcall;

const
     BASS_VSTDLL = 'bassvst.dll';

function BASS_VST_ChannelSetDSP (Channel : cardinal; const DLLFile : pchar; Flags : cardinal; Priority : integer) : cardinal; stdcall; external BASS_VSTDLL;
function BASS_VST_ChannelRemoveDSP (Channel : cardinal; vstHandle : DWORD) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetBypass (vstHandle : cardinal) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_SetBypass (vstHandle : cardinal; State : bool) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_EmbedEditor (Channel : cardinal; ParentWindow : HWND) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetInfo (VSTHandle : cardinal; var VST_Info : BASS_VST_INFO) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetParam (vstHandle : cardinal; ParamIndex : integer) : single; stdcall; external BASS_VSTDLL;
function BASS_VST_SetParam (vstHandle : cardinal; ParamIndex : integer; Value : single) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetParamCount (vstHandle : cardinal) : integer; stdcall; external BASS_VSTDLL;
function BASS_VST_GetParamInfo (vstHandle : cardinal; ParamIndex : integer; var Info : BASS_VST_PARAM_INFO) : boolean; stdcall; external BASS_VSTDLL;
function BASS_VST_GetProgram (vstHandle : cardinal) : integer; stdcall; external BASS_VSTDLL;
function BASS_VST_SetProgram (vstHandle : cardinal; ProgramIndex : integer) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetProgramCount (vstHandle : cardinal) : integer; stdcall; external BASS_VSTDLL;
function BASS_VST_GetProgramParam (vstHandle : cardinal; ProgramIndex : integer) : single; stdcall; external BASS_VSTDLL;
function BASS_VST_SetProgramParam (vstHandle : cardinal; ProgramIndex : integer; Value : single) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_GetProgramName (vstHandle : cardinal; ProgramIndex : integer) : pchar; stdcall; external BASS_VSTDLL;
function BASS_VST_SetProgramName (vstHandle : cardinal; ProgramIndex : integer; ProgramName : pchar) : boolean; stdcall; external BASS_VSTDLL;
function BASS_VST_Resume (vstHandle : cardinal) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_SetCallback (vstHandle : cardinal; Proc : pointer; User : cardinal) : bool; stdcall; external BASS_VSTDLL;
function BASS_VST_SetLanguage (const Lang : pchar) : bool; stdcall; external BASS_VSTDLL;

function BASS_VST_GetChunk (vstHandle : cardinal; isPreset : bool; var length : cardinal) : pchar; stdcall; external BASS_VSTDLL;
function BASS_VST_SetChunk (vstHandle : cardinal; isPreset : bool; Chunk : pchar; length : cardinal) : integer; stdcall; external BASS_VSTDLL;

function BASS_VST_ChannelCreate (freq : cardinal; Chans : cardinal; const DLLFile : pChar; flags : cardinal) : cardinal; stdcall; external BASS_VSTDLL;
function BASS_VST_ChannelFree (vstHandle : cardinal) : boolean; stdcall; external BASS_VSTDLL;
function BASS_VST_ProcessEventRaw (vstHandle : cardinal; const event : pointer; length : cardinal) : boolean; stdcall; external BASS_VSTDLL;


implementation

end.