Recent

Author Topic: help trying to use Bass on ubuntu  (Read 8492 times)

ron77

  • New Member
  • *
  • Posts: 22
help trying to use Bass on ubuntu
« on: September 04, 2021, 11:29:43 am »
hello i'm on ubuntu 20.04 with lazarus...

i've downloaded Bass to try and play music or just to test if it's working:

Copied libbass.so to /usr/lib and ran sudo ldconfig. No errors.

now I am trying to compile this code but I get errors

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, bass;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormCreate(Sender: TObject);
  16.   private
  17.  
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32. begin
  33.  
  34.   if not BASS_Init(-1, 44100, 0, Pointer(Handle), nil) then showMessage ('Error');
  35.  
  36. end;
  37.  
  38. end.
  39.  

the errors I get are these:

Code: Pascal  [Select][+][-]
  1. Compile Project, Target: project1: Exit code 1, Errors: 1
  2. linker: /usr/bin/ld: skipping incompatible /lib//libbass.so when searching for -lbass
  3. linker: /usr/bin/ld: skipping incompatible /usr/lib//libbass.so when searching for -lbass
  4. linker: /usr/bin/ld: skipping incompatible /lib/libbass.so when searching for -lbass
  5. linker: /usr/bin/ld: skipping incompatible /usr/lib/libbass.so when searching for -lbass
  6. linker: /usr/bin/ld: cannot find -lbass
  7. project1.lpr(21,1) Error: Error while linking
  8.  

so is libbass.io library compatible with ubuntu linux?
what am I doing wrong?
thank you any help will be appreciated...

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #1 on: September 04, 2021, 11:36:53 am »
i seem to forgot that this thread belong to sound more then graphics

[Edit - moved - Trev]
« Last Edit: September 04, 2021, 11:40:02 am by trev »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #2 on: September 04, 2021, 02:04:12 pm »
Hi!

Do you try to link the libbass.so static?

Don't do that.

It is a dynamic link library.

To call Bass_init is enough to inform the project about the library.

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #3 on: September 04, 2021, 02:23:29 pm »
Hello.
How do I dynamically link the library?  :o

I downloaded the bass24-linux version and library.so was there in the unzipped  folder I just copied it to usr/lib/ and sudo idconfig and in project option I added the bass.pas file

How do I dynamically link a library compare to static?

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: help trying to use Bass on ubuntu
« Reply #4 on: September 04, 2021, 02:28:53 pm »
Hello.
How do I dynamically link the library?  :o

I downloaded the bass24-linux version and library.so was there in the unzipped  folder I ju)st copied it to usr/lib/ and sudo idconfig and in project option I added the bass.pas file

How do I dynamically link a library compare to static?

There is this one:
https://forum.lazarus.freepascal.org/index.php/topic,9859.msg48712.html#msg48712

(But I am not sure it is still up-to-date, it dates from 2010.)
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #5 on: September 04, 2021, 02:28:57 pm »
Hi!

There are more files called libbass.so in the zip file.

Did you take the one from the directory x64  ??

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #6 on: September 04, 2021, 02:50:12 pm »
hello...

yes you were correct there is another under x64 folder and when I copied it to the project folder it compiled and run :)...

now I'm trying to run this code to plat a wave file but no sound and it gives an warning too...

here is the code:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, bass;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormCreate(Sender: TObject);
  16.   private
  17.  
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32.  
  33.  
  34.   //if not BASS_Init(-1, 44100, 0, Pointer(Handle), nil) then showMessage ('Error');
  35.   var
  36.     B_Stream: DWord;
  37.     err: Integer;
  38.     B_Volume,B_Pan : single;
  39. begin
  40.  
  41. BASS_Init(-1, 44100, 0, Pointer(Handle), nil);
  42.  
  43. B_Stream := BASS_StreamCreateFile(False, PChar('d1.wav'), 0, 0, BASS_STREAM_PRESCAN OR BASS_SAMPLE_FLOAT );
  44.  
  45. BASS_ChannelStop(B_Stream);
  46. BASS_StreamFree(B_Stream);
  47.  
  48.  
  49.  
  50. // OR:
  51. // B_Stream := BASS_StreamCreateURL(Pchar(URL),0,BASS_Sample_Float,NIL,Nil);
  52.  
  53. err := BASS_ErrorGetCode;
  54. if err <>  0 then begin showMessage ('ERROR '+IntToStr(err)); exit; end;
  55.  
  56. B_Volume := 0.5;
  57. B_Pan := 0;
  58. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_VOL, B_Volume);
  59. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_PAN, B_PAN);
  60. BASS_ChannelPlay(B_Stream , false);
  61. end;
  62.  
  63.  
  64.  
  65.  
  66. end.
  67.  

here is the warning:

Code: Pascal  [Select][+][-]
  1. Compile Project, Target: project1: Success, Hints: 1
  2. unit1.pas(41,25) Hint: Conversion between ordinals and pointers is not portable
  3.  

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #7 on: September 04, 2021, 03:25:23 pm »
Hi!

*  Did you do another sudo ldconfig   ??

* Do a

Code: Pascal  [Select][+][-]
  1. BASS_Init(-1, 44100, 0, @Handle, nil);

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #8 on: September 04, 2021, 03:40:39 pm »
hi :)

no i did not i just added the bass.pas and libbass.so lib to project folder

I tried your suggestion but got an error:
Code: Pascal  [Select][+][-]
  1. Compile Project, Target: project1: Exit code 1, Errors: 1
  2. unit1.pas(41,26) Error: Variable identifier expected
  3.  

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #9 on: September 04, 2021, 03:48:28 pm »
hi :)

no i did not i just added the bass.pas and libbass.so lib to project folder

I tried your suggestion but got an error:
Code: Pascal  [Select][+][-]
  1. Compile Project, Target: project1: Exit code 1, Errors: 1
  2. unit1.pas(41,26) Error: Variable identifier expected
  3.  

Hi!

You are on Linux! Don't use old Windows habbits!

The libbass.so has to reside in one of the dedicated library folders  - not in your project folder!!!!
Grrrr!

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #10 on: September 04, 2021, 03:54:49 pm »
okay i copied libbass.so to usr/lib/ and did sudo idconfig

now here is the code :

Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, bass;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     procedure FormCreate(Sender: TObject);
  16.   private
  17.  
  18.   public
  19.  
  20.   end;
  21.  
  22. var
  23.   Form1: TForm1;
  24.  
  25. implementation
  26.  
  27. {$R *.lfm}
  28.  
  29. { TForm1 }
  30.  
  31. procedure TForm1.FormCreate(Sender: TObject);
  32.  
  33.  
  34.   //if not BASS_Init(-1, 44100, 0, Pointer(Handle), nil) then showMessage ('Error');
  35.   var
  36.     B_Stream: DWord;
  37.     err: Integer;
  38.     B_Volume,B_Pan : single;
  39. begin
  40.  
  41. BASS_Init(-1, 44100, 0, @Handle, nil); // <------- line of the error!!!!
  42.  
  43. B_Stream := BASS_StreamCreateFile(False, PChar('d1.wav'), 0, 0, BASS_STREAM_PRESCAN OR BASS_SAMPLE_FLOAT );
  44.  
  45. BASS_ChannelStop(B_Stream);
  46. BASS_StreamFree(B_Stream);
  47.  
  48.  
  49.  
  50. // OR:
  51. // B_Stream := BASS_StreamCreateURL(Pchar(URL),0,BASS_Sample_Float,NIL,Nil);
  52.  
  53. err := BASS_ErrorGetCode;
  54. if err <>  0 then begin showMessage ('ERROR '+IntToStr(err)); exit; end;
  55.  
  56. B_Volume := 0.5;
  57. B_Pan := 0;
  58. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_VOL, B_Volume);
  59. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_PAN, B_PAN);
  60. BASS_ChannelPlay(B_Stream , false);
  61. end;
  62.  
  63.  
  64.  
  65.  
  66. end.
  67.  

i still get error

Code: Pascal  [Select][+][-]
  1. Compile Project, Target: project1: Exit code 1, Errors: 1
  2. unit1.pas(41,26) Error: Variable identifier expected
  3.  

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #11 on: September 04, 2021, 04:53:12 pm »
Hi!

I got no compiler error on this line:

Code: Pascal  [Select][+][-]
  1. BASS_Init(-1, 44100, 0, @Handle, nil);


As a workaround you can use

Code: Pascal  [Select][+][-]
  1. BASS_Init(-1, 44100, 0, nil, nil);

And:

In your FormCreate you only should do the BASS_init.

The rest of you could should be in an ButtonClick.

While Formcreate is executed there is a lot of stuff initialized. Though you cannot rely on that everythind is ready .

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #12 on: September 04, 2021, 05:11:59 pm »
hi :)

okay i did as follow with my code:
Code: Pascal  [Select][+][-]
  1. unit Unit1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, bass;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     procedure Button1Click(Sender: TObject);
  17.     procedure FormCreate(Sender: TObject);
  18.   private
  19.  
  20.   public
  21.  
  22.   end;
  23.  
  24. var
  25.   Form1: TForm1;
  26.     B_Stream: DWord;
  27.     err: Integer;
  28.     B_Volume,B_Pan : single;
  29.  
  30. implementation
  31.  
  32. {$R *.lfm}
  33.  
  34. { TForm1 }
  35.  
  36. procedure TForm1.FormCreate(Sender: TObject);
  37.  
  38.  
  39.   //if not BASS_Init(-1, 44100, 0, Pointer(Handle), nil) then showMessage ('Error');
  40.  
  41. begin
  42.  
  43. BASS_Init(-1, 44100, 0, nil, nil);
  44. //BASS_Init(-1, 44100, 0, Pointer(Handle), nil);
  45.  
  46.  
  47. end;
  48.  
  49. procedure TForm1.Button1Click(Sender: TObject);
  50. begin
  51.      B_Stream := BASS_StreamCreateFile(False, PChar('./d1.wav'), 0, 0, BASS_STREAM_PRESCAN OR BASS_SAMPLE_FLOAT );
  52.  
  53. BASS_ChannelStop(B_Stream);
  54. BASS_StreamFree(B_Stream);
  55.  
  56.  
  57.  
  58. // OR:
  59. // B_Stream := BASS_StreamCreateURL(Pchar(URL),0,BASS_Sample_Float,NIL,Nil);
  60.  
  61. err := BASS_ErrorGetCode;
  62. if err <>  0 then begin showMessage ('ERROR '+IntToStr(err)); exit; end;
  63.  
  64. B_Volume := 0.5;
  65. B_Pan := 0;
  66. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_VOL, B_Volume);
  67. BASS_ChannelSetAttribute(B_Stream, BASS_ATTRIB_PAN, B_PAN);
  68. BASS_ChannelPlay(B_Stream , false);
  69. end;
  70.  
  71.  
  72.  
  73.  
  74. end.
  75.  

and when I press the button a messagebox pop with "ERROR 5"

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: help trying to use Bass on ubuntu
« Reply #13 on: September 04, 2021, 05:29:49 pm »
Hi!

Is './d1.wav' in your project directory?

Winni

ron77

  • New Member
  • *
  • Posts: 22
Re: help trying to use Bass on ubuntu
« Reply #14 on: September 04, 2021, 05:34:25 pm »
yes it is i checked

 

TinyPortal © 2005-2018