Author Topic: Help for Vst on OSX  (Read 256 times)

Salvo

  • Posts: 162
Help for Vst on OSX
« on: 23 Sep '24 - 14:09 »
I have always had a doubt and it has never worked for me on Osx.
Does the library Bass_vst work on OSX??
Can you upload files with the VST or Dylib ??
Because loading a vst gives me as I always return 0.

    filename:='limiter.vst';
    ch := BASS_StreamCreate(48000, 2, BASS_SAMPLE_FLOAT, nil, nil);
    dsp := BASS_VST_ChannelSetDSP(ch, PChar(FileName), BASS_UNICODE, 0);
    ---->>>>dsp = 0

Chris

  • Posts: 2216
Re: Help for Vst on OSX
« Reply #1 on: 23 Sep '24 - 20:09 »
Just Call Bass_ErrorGetCode after the DSP Call to Catch the ErrorCode.
By the way , which Delphi Header do you use for the VST Stuff ?
« Last Edit: 23 Sep '24 - 20:47 by Chris »

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #2 on: 24 Sep '24 - 17:25 »
Delphi Header translation bass_vst.dll v2.4.0.3 (21/01/2008) by AxelLang

Chris

  • Posts: 2216
Re: Help for Vst on OSX
« Reply #3 on: 24 Sep '24 - 17:39 »
try this one .

Ian @ un4seen

  • Administrator
  • Posts: 26077
Re: Help for Vst on OSX
« Reply #4 on: 24 Sep '24 - 17:51 »
Just to be sure, are you using a VST that's intended for macOS, not Windows? And it's VST2, not VST3?

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #5 on: 24 Sep '24 - 20:31 »
Just Call Bass_ErrorGetCode after the DSP Call to Catch the ErrorCode.
By the way , which Delphi Header do you use for the VST Stuff ?
i:=Bass_ErrorGetCode;
>>>> i =41

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #6 on: 24 Sep '24 - 20:33 »
Just to be sure, are you using a VST that's intended for macOS, not Windows? And it's VST2, not VST3?
exact for MAC and is a 64-bit VST2.

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #7 on: 24 Sep '24 - 21:18 »
try this one .
There are several errors on the file and correcting errors and compiling is always the same thing
Bass_ErrorGetCode---->41


Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #8 on: 24 Sep '24 - 21:54 »
one thing I forgot to say is that the executable is under Apple M1 chip with Sequoia compiled for both Osx 64 bit and also for ARM64.

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #9 on: 25 Sep '24 - 13:26 »
In my opinion, this library on OSX has never worked.
Because on windows loading it is a DLL library, while on OSX (. SVT) is a Bundle as if it were an application.

Is anyone who has implemented bass_VST on OSX 64 bit or OSx Arm64 there that works ?
« Last Edit: 25 Sep '24 - 14:14 by Salvo »

Ian @ un4seen

  • Administrator
  • Posts: 26077
Re: Help for Vst on OSX
« Reply #10 on: 25 Sep '24 - 16:18 »
i:=Bass_ErrorGetCode;
>>>> i =41

Error code 41 (BASS_ERROR_FILEFORM) means that BASS_VST was able to open the VST bundle but a VSTPluginMain function wasn't found in it or that function didn't return an AEffect instance. What VST plugin are you trying to use?

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #11 on: 25 Sep '24 - 18:16 »
Different plugins all with the same problem, don't work.
Can you attach a VST FREE PLUGIN for OSX ?

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #12 on: 25 Sep '24 - 20:10 »
i:=Bass_ErrorGetCode;
>>>> i =41

Error code 41 (BASS_ERROR_FILEFORM) means that BASS_VST was able to open the VST bundle but a VSTPluginMain function wasn't found in it or that function didn't return an AEffect instance. What VST plugin are you trying to use?
You can download this and test it : https://acondigital.com/software/Remix_macOS_1_0_5.pkg.zip

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #13 on: 25 Sep '24 - 21:35 »
I took a step forward.
correcting the line a
dsp := BASS_VST_ChannelSetDSP(ch, PChar(ANSISTRING(FileName)), BASS_UNICODE, 0);

Now it gives me dsp=1
and
Bass_ErrorGetCode ->>> 0
Hurrah.

The problem now is in the editor view.
On the line
BASS_VST_EmbedEditor(dsp, WindowHandleToPlatform(Form_Vst.Handle). Wnd) ->>>Crash

On bass_vst.pas the line has been corrected like this:
function BASS_VST_EmbedEditor(vstHandle : DWORD; ParentWindow :{$IFDEF MSWINDOWS} HWND {$ELSE} NSWindow {$ENDIF}) : BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassvstdll;


Ian @ un4seen

  • Administrator
  • Posts: 26077
Re: Help for Vst on OSX
« Reply #14 on: 26 Sep '24 - 13:17 »
It looks like the macOS BASS_VST version is currently ignoring the BASS_UNICODE flag and always expecting UTF-8 filenames. Here's an update that should add support for BASS_UNICODE:

   www.un4seen.com/stuff/bass_vst-osx.zip

Regarding embedding a VST editor, I haven't tried it myself but I gather "ParentWindow" should be a pointer to an NSView on macOS.

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #15 on: 26 Sep '24 - 14:09 »
Perfect now it works even without ANSISTRING.
dsp := BASS_VST_ChannelSetDSP(ch, PChar(FileName), BASS_UNICODE, 0);
    ---->>>>dsp = 1

Now I see the editor problem as it can be.

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #16 on: 26 Sep '24 - 14:21 »
Regarding embedding a VST editor, I haven't tried it myself but I gather "ParentWindow" should be a pointer to an NSView on macOS.

Insert NSView crashes the program on the line
BASS_VST_EmbedEditor(d, Pointer(NSViewHandle))

on bass_vst :
function BASS_VST_EmbedEditor(vstHandle : DWORD; ParentWindow :{$IFDEF MSWINDOWS}HWND {$ELSE}Pointer{$ENDIF}) : BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassvstdll;

on programm:
          WindowHandle := Form_Vst.Handle;
          if WindowHandle is TMacWindowHandle then
             NSViewHandle := TMacWindowHandle(WindowHandle).View;
          if BASS_VST_EmbedEditor(d, pointer(NSViewHandle)) then >>>>crash



this is the OSX report:
hread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                  0x191f72b4c __abort_with_payload + 8
1   libsystem_kernel.dylib                  0x191f98e84 abort_with_payload_wrapper_internal + 104
2   libsystem_kernel.dylib                  0x191f98e1c abort_with_reason + 32
3   libobjc.A.dylib                         0x191c0c040 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 128
4   libobjc.A.dylib                         0x191c0bfc0 _objc_fatal(char const*, ...) + 44
5   libobjc.A.dylib                         0x191bd61ac lookUpImpOrForward + 836
6   libobjc.A.dylib                         0x191bd5b84 _objc_msgSend_uncached + 68
7   Remix                                   0x328a30934 juce::attachComponentToWindowRefVST(juce::Component*, void*, bool) + 44
8   Remix                                   0x32899fbbc JuceVSTWrapper::handleOpenEditor(JuceVSTWrapper::VstOpCodeArguments) + 124
9   Remix                                   0x32899dd90 JuceVSTWrapper::dispatcherCB(Vst2::AEffect*, int, int, long long, void*, float) + 648
10  libbass_vst.dylib                       0x10953c898 BASS_VST_EmbedEditor + 288
« Last Edit: 26 Sep '24 - 14:53 by Salvo »

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #17 on: 26 Sep '24 - 15:29 »
Regarding embedding a VST editor, I haven't tried it myself but I gather "ParentWindow" should be a pointer to an NSView on macOS.

There is some error on the library libbass_vst.dylib tried in a thousand ways (Pointer, NSView, NSWindow) always crashes.

But does anyone work with delphi on OSX ?

Ian @ un4seen

  • Administrator
  • Posts: 26077
Re: Help for Vst on OSX
« Reply #18 on: 26 Sep '24 - 15:45 »
Insert NSView crashes the program on the line
BASS_VST_EmbedEditor(d, Pointer(NSViewHandle))

on bass_vst :
function BASS_VST_EmbedEditor(vstHandle : DWORD; ParentWindow :{$IFDEF MSWINDOWS}HWND {$ELSE}Pointer{$ENDIF}) : BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassvstdll;

on programm:
          WindowHandle := Form_Vst.Handle;
          if WindowHandle is TMacWindowHandle then
             NSViewHandle := TMacWindowHandle(WindowHandle).View;
          if BASS_VST_EmbedEditor(d, pointer(NSViewHandle)) then >>>>crash

Are you sure that NSViewHandle is a NSView pointer? Is there another Delphi function that takes a NSView pointer that you can test it with?

You could also try other VST plugins to check it isn't something plugin-specific. There are some available here:

   https://www.audiopluginsforfree.com/mac/vst-mac/

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #19 on: 26 Sep '24 - 16:02 »
Insert NSView crashes the program on the line
BASS_VST_EmbedEditor(d, Pointer(NSViewHandle))

on bass_vst :
function BASS_VST_EmbedEditor(vstHandle : DWORD; ParentWindow :{$IFDEF MSWINDOWS}HWND {$ELSE}Pointer{$ENDIF}) : BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassvstdll;

on programm:
          WindowHandle := Form_Vst.Handle;
          if WindowHandle is TMacWindowHandle then
             NSViewHandle := TMacWindowHandle(WindowHandle).View;
          if BASS_VST_EmbedEditor(d, pointer(NSViewHandle)) then >>>>crash

Are you sure that NSViewHandle is a NSView pointer? Is there another Delphi function that takes a NSView pointer that you can test it with?

You could also try other VST plugins to check it isn't something plugin-specific. There are some available here:

   https://www.audiopluginsforfree.com/mac/vst-mac/
Of course it's an NSView
This is the statement
var NSViewHandle=NSView;

then this function TMacWindowHandle(WindowHandle).View
returns NSView;

I tried it with many others.
In my opinion, no one has programmed bass_svt with OSx on Delphi.

Chris

  • Posts: 2216
Re: Help for Vst on OSX
« Reply #20 on: 26 Sep '24 - 16:29 »
can you try the following :
Code: [Select]
var
FInfo: BASS_VST_INFO;
  begin
    if DSP <> 0 then
    begin
        BASS_VST_GetInfo(DSP, @Finfo);
        if(Finfo.HasEditor > 0) and (Finfo.EditorWidth > 0) and (Finfo.EditorHeight > 0) then
        BASS_VST_EmbedEditor(dsp, NSViewHandle) ;
     else
   // just check the Returnvalues of HasEditor, EditorWidth, EditorHeigth
     end;

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #21 on: 26 Sep '24 - 17:40 »
can you try the following :
Code: [Select]
var
FInfo: BASS_VST_INFO;
  begin
    if DSP <> 0 then
    begin
        BASS_VST_GetInfo(DSP, @Finfo);
        if(Finfo.HasEditor > 0) and (Finfo.EditorWidth > 0) and (Finfo.EditorHeight > 0) then
        BASS_VST_EmbedEditor(dsp, NSViewHandle) ;
     else
   // just check the Returnvalues of HasEditor, EditorWidth, EditorHeigth
     end;
yes of course already tried it is a haseditor with width and heigth.

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #22 on: 26 Sep '24 - 18:14 »
I found the error need to use NSWindow on bass_vst I put a Pointer:
function BASS_VST_EmbedEditor(vstHandle : DWORD; ParentWindow :{$IFDEF MSWINDOWS}HWND {$ELSE}Pointer{$ENDIF}) : BOOL; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassvstdll;

Thank you all for your help. :)

Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #23 on: 27 Sep '24 - 14:14 »
Another problem.
Now the editor works.
The problem is on this REMIX plugin.
When the program is released on OSX it crashes.
Calling
dsp := BASS_VST_ChannelSetDSP(0, pChar(Filename), BASS_UNICODE, 0);

even if at the close of the program I put:
          BASS_VST_ChannelRemoveDSP(0,dsp);
          BASS_VST_ChannelFree(DSP);
crashes on OSX.
It's as if the plugin isn't fully released because there's a timer inside the VST.
This is the OSX report:

Crashed Thread:        26  JUCE Timer

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000

External Modification Warnings:
Debugger attached to process.

…….
Thread 26 Crashed:: JUCE Timer
0   libsystem_kernel.dylib                  0x195bba600 __pthread_kill + 8
1   libsystem_pthread.dylib                 0x195bf2f70 pthread_kill + 288
2   libsystem_c.dylib                       0x195aff908 abort + 128
3   libc++abi.dylib                         0x195ba944c abort_message + 132
4   libc++abi.dylib                         0x195b97968 demangling_terminate_handler() + 132
5   libc++abi.dylib                         0x195ba8710 std::__terminate(void (*)()) + 16
6   libc++abi.dylib                         0x195ba866c std::terminate() + 36
7   Remix                                   0x13a0e1118 juce::Timer::TimerThread::run() + 712
8   Remix                                   0x13a0b65d0 juce::Thread::createNativeThread(juce::Thread::Priority)::$_16::__invoke(void*) + 432
9   libsystem_pthread.dylib                 0x195bf32e4 _pthread_start + 136
10  libsystem_pthread.dylib                 0x195bee0fc thread_start + 8


Salvo

  • Posts: 162
Re: Help for Vst on OSX
« Reply #24 on: 27 Sep '24 - 14:36 »
Sorry maybe it's a problem with the delphi debugger on OSX.
I will do further tests.
Thank you