Help for Vst on OSX

Started by Salvo,

Salvo

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

#1
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 ?

Salvo

Delphi Header translation bass_vst.dll v2.4.0.3 (21/01/2008) by AxelLang

Chris


Ian @ un4seen

Just to be sure, are you using a VST that's intended for macOS, not Windows? And it's VST2, not VST3?

Salvo

Quote from: ChrisJust 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

Quote from: Ian @ un4seenJust 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

Quote from: Christry this one .
There are several errors on the file and correcting errors and compiling is always the same thing
Bass_ErrorGetCode---->41


Salvo

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

#9
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 ?

Ian @ un4seen

Quote from: Salvoi:=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

Different plugins all with the same problem, don't work.
Can you attach a VST FREE PLUGIN for OSX ?

Salvo

Quote from: Ian @ un4seen
Quote from: Salvoi:=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

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

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

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

#16
Quote from: Ian @ un4seenRegarding 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

Salvo

Quote from: Ian @ un4seenRegarding 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

Quote from: SalvoInsert 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

Quote from: Ian @ un4seen
Quote from: SalvoInsert 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

can you try the following :
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

Quote from: Chriscan you try the following :
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

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

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

Sorry maybe it's a problem with the delphi debugger on OSX.
I will do further tests.
Thank you