понедельник, 27 мая 2024 г.

Dynamic loading of the libbass_fx.so library into the Lazarus project.

 I'm building an audio player for Linux. I'm writing it on freepascal in the Delphi-like Lazarus IDE using the BASS audio library. 

But there are libraries for Linux, but it is extremely difficult to find documentation on their use in Linux.   And even on the support forum for these libraries, I did not find a decent solution. 

Therefore, I want to share my work with interested people.

With the dynamic library lazdynamic_bass, I seem to have succeeded, but when I tried to add another processing effect to the 'Compressor' channel, it turned out that it was missing from this library. So I decided to include the libbass_fx.so library. If downloading the codec libraries did not cause any problems, connecting this library turned out to be not so simple.

Dynamic loading using the DynLibs library is the first thing that allowed this library to be loaded somehow.

lib:=LoadLibrary(Pchar(Path+'libbass_fx.so'));

It worked with the path to the library '.../lib/libbass_fx.so', but if you add an additional folder to the path of this library, for example '.../lib/fx/libbass_fx.so', the library was not loaded. Of course, the library file was in this subfolder.

But this is not the worst thing either. I was able to add the Compressor2 effect from this library to the project this way and it even worked as it should, but I was concerned that calling the BASS_FX_GetVersion function threw an exception. 

And it turned out that my worries were not in vain. When I tried to add another BASS_ATTRIB_TEMPO effect to the effects it also threw an exception and I had to look for answers to my questions in the text of Dynamic_BassFX.pas

It turned out that this library has a similar function for loading the library as in lazdynamic_bass.pas

In lazdynamic_bass.pas, this function Load_BASSDLL(PChar(fname)) loads the BASS library.

In Dynamic_BassFX.pas, this function Load_BASSFXDLL(PChar(fname)) loads the BASS_FX library.

Now all functions of this library work correctly!

Комментариев нет:

Отправить комментарий

AdSen

Популярные сообщения