Recent

Author Topic: Linux bass hell  (Read 959 times)

pcurtis

  • Full Member
  • ***
  • Posts: 118
Linux bass hell
« on: July 09, 2020, 09:06:43 am »
Hi All,
I thought I would give Linux (Linux Mint 20 Cinamon) and BASS a try.

I thought it would be simple. I was wrong.
I installed FPC, FPC_SRC and LAZARUS, and updated missing dependencies apt-get install -f. No problem.

I downloaded bass24 for linux.

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

I start Laz -> New project, and saved it.

Put bass in the uses clause.

So far, so good.

Copied bass.pas to the directory
Put the following code in the Form oncreate event.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. var
  3.   strs : THandle;
  4. begin
  5.   if not BASS_Init(-1, 44100, 0, @Handle, nil) then showMessage ('Error');
  6.  
  7.   BASS_SetVolume(1);
  8.  
  9.   strs := BASS_StreamCreateFile(False, pwidechar('a.mp3'), 0, 0, BASS_UNICODE);
  10.  
  11.   ShowMessage(inttostr(BASS_ErrorGetCode));
  12.  
  13.   BASS_ChannelPlay(strs, False);
  14.  
  15.   BASS_Free;
  16. end;              
  17.  

The problem is with BASS_Init. I get the following error when I  compile :-

unit1.pas(35,35) Error: Variable identifier expected

Any ideas whats wrong?
« Last Edit: July 09, 2020, 09:20:44 am by pcurtis »
Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

dbannon

  • Hero Member
  • *****
  • Posts: 1100
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Linux bass hell
« Reply #1 on: July 09, 2020, 11:41:49 am »
My guess is that there is something wrong on line 35, char 35 of Unit1.pas.

Unfortunately, you have not shown us whats on that line so its fairly hard to comment.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

pcurtis

  • Full Member
  • ***
  • Posts: 118
Re: Linux bass hell
« Reply #2 on: July 09, 2020, 11:54:38 am »
Line 35 is BASS_init

  if not BASS_Init(-1, 44100, 0, @Handle, nil) then showMessage ('Error');

The line numbers above do not correspond to  the linux source
Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 1567
Re: Linux bass hell
« Reply #3 on: July 09, 2020, 12:09:31 pm »
Hi!

The line with Bass_Init is correct.

But the creation of the stream contains some errors:

* The result of BASS_StreamCreateFile is a DWord, not a handle
* PWideChar is wong, use PChar instead
* The parameter BASS_UNICODE is wrong.


Code: Pascal  [Select][+][-]
  1. var B_Stream : DWord;
  2. ....
  3. B _Stream := BASS_StreamCreateFile(False, PChar(Filename), 0, 0, BASS_STREAM_PRESCAN or BASS_Sample_Float);


There is no BASS hell. Neither in Linux nor in Windows.
 You just have to read the documentation.
Look for the BASS.chm file in the BASS package.

Winni
« Last Edit: July 09, 2020, 12:21:17 pm by winni »

dbannon

  • Hero Member
  • *****
  • Posts: 1100
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Linux bass hell
« Reply #4 on: July 09, 2020, 12:16:59 pm »
OK, char 35 might be start of 'Handle' ? 

If so, then it seems 'Handle' is not defined.   That might be because you have not included a necessary file (although BASS_init does sound pretty early in the process ?).  Anyway, you need to tell the compiler just what Handle is.

I think its a case of reading the BASS docs again, failing that, maybe take it to to what ever support BASS provided.  BASS does seem to be used here, so, perhaps trawl through previous messages in this section looking for an example ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

winni

  • Hero Member
  • *****
  • Posts: 1567
Re: Linux bass hell
« Reply #5 on: July 09, 2020, 12:26:18 pm »
@pcurtis

If you were not so lazy you have could seaarched in this forum.

10 days ago I made a simple example for BASS, here:

https://forum.lazarus.freepascal.org/index.php/topic,50374.msg367536.html#msg367536

And the BASS.chm gives you nearly all answers.

Winni

pcurtis

  • Full Member
  • ***
  • Posts: 118
Re: Linux bass hell
« Reply #6 on: July 09, 2020, 12:36:49 pm »
I took the example from one of your comments to a post -

Hi!

How to install and initialize  BASS on Linux:

a) copy the libbass.so from the download to /usr/local/lib/
b) inform your system about the new library: sudo ldconfig
c) use this code to initialize the BASS system:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);  
  2. begin
  3. if BASS_Init(-1, 44100, 0, @Handle, nil) then showmessage ('OK') else
  4.     showMessage ('Error');
  5. end;
  6.  


Keep on rockin with BASS!

Winni


but it won't compile.
Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 1567
Re: Linux bass hell
« Reply #7 on: July 09, 2020, 01:08:16 pm »
"But it won't compile"

No electricity? PC broken?

Hej - my crystal ball has just a malfunction!

Without your error message nobody can help you!

Winni

pcurtis

  • Full Member
  • ***
  • Posts: 118
Re: Linux bass hell
« Reply #8 on: July 09, 2020, 01:12:08 pm »
Error was in opening post

unit1.pas(35,35) Error: Variable identifier expected

Line 35 is

if BASS_Init(-1, 44100, 0, @Handle, nil) then showmessage ('OK') else
    showMessage ('Error');
Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

winni

  • Hero Member
  • *****
  • Posts: 1567
Re: Linux bass hell
« Reply #9 on: July 09, 2020, 01:38:45 pm »
Hi

The line BASS_Init (..... works for me since years without problems.
And the documentation for the latest versions has not changed.

I assume that in this line there is a typo.
Check it!

Winni

pcurtis

  • Full Member
  • ***
  • Posts: 118
Re: Linux bass hell
« Reply #10 on: July 09, 2020, 02:04:29 pm »
The line is identical as shown above - No typo.

I read from bass.chm that -
Quote
BOOL BASS_Init(
    int device,
    DWORD freq,
    DWORD flags,
    HWND win,
    GUID *clsid
);

Where :

win The application's main window... 0 = the desktop window (use this for console applications). This is only needed when using DirectSound output.

It fails at @Handle which I believe means a pointer to the applications main window.

Is it something to do with my Lazarus installation or Linux OS?

If I declare a variable
var Handle1 : pointer;

and try

if BASS_Init(-1, 44100, 0, @Handle1, nil) then showmessage ('OK') else
    showMessage ('Error');

Then it compiles, but I get no sound after

 B _Stream := BASS_StreamCreateFile(False, PChar(Filename), 0, 0, BASS_STREAM_PRESCAN or BASS_Sample_Float);
BASS_ChannelPlay(B_Stream, false);

I assume this is because Handle1 is not the main windows handle.

So how do I do Handle1 := Form1.Handle?

Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

Cyrax

  • Hero Member
  • *****
  • Posts: 829
Re: Linux bass hell
« Reply #11 on: July 09, 2020, 02:38:47 pm »
Code: Pascal  [Select][+][-]
  1. BASS_Init(-1, 44100, 0, @Handle1, nil)

Remove @Handle1 altogether and replace it with 0.

winni

  • Hero Member
  • *****
  • Posts: 1567
Re: Linux bass hell
« Reply #12 on: July 09, 2020, 02:39:01 pm »
Hi!

if BASS_Init(-1, 44100, 0, @Handle1, nil) then ....

The -1 means:  automatic search for the audio interface. If you take another value you must have tested where your audio-system resides. For that you can use BASS_GetDeviceInfo. But that is not necessary if you use -1.

The @Handle must be the Handle of your main Form.
If you call it from a procedure from the class TForm1 just call it Handle.
Otherwise call it with Form1.handle

This is all in detail in the BASS.chm in the Bass package. Read it!

Winni



pcurtis

  • Full Member
  • ***
  • Posts: 118
Re: Linux bass hell
« Reply #13 on: July 09, 2020, 03:33:11 pm »
I give in. I will try on un4seen.
Windows 10 / Linux Mint 20
Laz 2.0.8
FPC 3.0.4

MarkMLl

  • Hero Member
  • *****
  • Posts: 1050
Re: Linux bass hell
« Reply #14 on: July 09, 2020, 04:43:33 pm »
Error was in opening post

unit1.pas(35,35) Error: Variable identifier expected

Opening post did not have unit1.pas appended or quoted in its entirety.

MarkMLl

Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.

 

TinyPortal © 2005-2018