Recent

Author Topic: How to integrate Bass library to Lazarus?  (Read 9693 times)

fbenites

  • Newbie
  • Posts: 4
How to integrate Bass library to Lazarus?
« on: June 28, 2018, 07:39:35 pm »
Guys, i'm kinda beginner herein  and using Lazarus, but particular interested in dealing with audio data, specially reading from microphone... Seems that Bass library can support it but I still have no clue how to put things together, having downloaded Bass and installed a default Lazarus.
Can anyone help me out? It is just a matter of unzip files and folders in the right place or Do i have to create something FROM the original library pack?

Thanx in advance.

Benites

Lulu

  • Full Member
  • ***
  • Posts: 229
Re: How to integrate Bass library to Lazarus?
« Reply #1 on: June 28, 2018, 09:43:15 pm »
Hello Benites,
1 ) dezip bass24.zip.
2 ) Copy bass.dll (if you are on Windows) in your application folder, this is the binary library
3 ) In the folder 'delphi' you will found 'bass.pas': copy this file to your application folder, this is the pascal header for the library.
4 ) Of course, add 'bass' in the uses clause in your application:
Code: Pascal  [Select][+][-]
  1. uses classes,...
  2.      bass,...

You can also convert the delphi demo to Lazarus project.
wishing you a nice life

fbenites

  • Newbie
  • Posts: 4
Re: How to integrate Bass library to Lazarus?
« Reply #2 on: June 29, 2018, 03:56:33 pm »
Worked fine!
Thanx so much!
No need to apologize for the english

Lulu

  • Full Member
  • ***
  • Posts: 229
Re: How to integrate Bass library to Lazarus?
« Reply #3 on: June 29, 2018, 04:41:31 pm »
Good !
It took me at least 10 minutes to write my answer with the help of a translator !  :D
wishing you a nice life

fbenites

  • Newbie
  • Posts: 4
Re: How to integrate Bass library to Lazarus?
« Reply #4 on: July 03, 2018, 12:01:51 am »
Lulu,

I'm having a really hard time in what I imagine could be quite simple: I'm just a noobie and all that I need is to use microphone level to trigger any event ?
(i.e."if mic > 40db then something")

Can you give me any advice to start from?
Reading a bunch of doc material of several different library/technologies (Bass?ACS?...) I feel dragged by an avalanche.

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: How to integrate Bass library to Lazarus?
« Reply #5 on: July 04, 2018, 04:19:53 pm »
Hello.

You may try uos: https://github.com/fredvs/uos.

Take a look at /examples/simplerecorder.lpi

Fre;D
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

fbenites

  • Newbie
  • Posts: 4
Re: How to integrate Bass library to Lazarus?
« Reply #6 on: July 04, 2018, 09:03:06 pm »
Fact is I'm going back and forth thru documentation trying to avoid specific issues of this or that audio technology... Nevertheless, I'll insist in Bass. I borrowed the following code below and it's quite simple, but Lazarus failed me claimming the statement of the RecordingCallback call:
project1.lpr(15,51) Error: Incompatible type for arg no. 4: Got "<address of function(LongWord;Pointer;LongWord;LongWord):Boolean;StdCall>", expected "<procedure variable type of function(LongWord;Pointer;LongWord;Pointer):LongBool;StdCall>"

program rec;
uses Windows, Bass;

(* This function called while recording audio *)
function RecordingCallback(h:HRECORD; b:Pointer; l,u: DWord): boolean; stdcall;
 var level:dword;
 begin
  level:=BASS_ChannelGetLevel(h);
  write(''#13,LoWord(level),'-',HiWord(level),'         ');
  Result := True;
 end;

begin
  BASS_RecordInit(-1);
  BASS_RecordStart(44100, 2, 0, @RecordingCallback, nil);
  Readln;
  BASS_RecordFree;
end.

Lulu

  • Full Member
  • ***
  • Posts: 229
Re: How to integrate Bass library to Lazarus?
« Reply #7 on: July 04, 2018, 11:36:11 pm »
Hi,
sorry, not enough time available to really look into the problem ...
As compiler say, the fourth parameter is a pointer.
Try:
Code: Pascal  [Select][+][-]
  1. function RecordingCallback(h: HRECORD; b: Pointer; l: DWord; u: Pointer): boolean; stdcall;
wishing you a nice life

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: How to integrate Bass library to Lazarus?
« Reply #8 on: July 06, 2018, 01:53:16 am »
hello,
I'm having a really hard time in what I imagine could be quite simple: I'm just a noobie and all that I need is to use microphone level to trigger any event ?
(i.e."if mic > 40db then something")
Reading a bunch of doc material of several different library/technologies (Bass?ACS?...) I feel dragged by an avalanche.
With ACS, you can do what you can see in attachment.
1 - Choose an audio source.
2 - Choose what part of spectrum you want filter.
3 - Choose a threshold level to trigger an event.
4 - Show the spectrum of the input source in real time.
5 - Show the max level value in real time.

Friendly, J.P
« Last Edit: July 06, 2018, 01:56:11 am by Jurassic Pork »
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to integrate Bass library to Lazarus?
« Reply #9 on: July 06, 2018, 04:48:13 am »
any links to a working vresion of acs? last time I checked it wasn't working (or updated?) at all.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Jurassic Pork

  • Hero Member
  • *****
  • Posts: 1228
Re: How to integrate Bass library to Lazarus?
« Reply #10 on: July 06, 2018, 06:40:15 am »
on windows 10 with Lazarus 1.8.2 32 bits, i use ACS version 3.0.0.0 installed from Package On Line manager.
in attachment, my project to monitor input audio source. 
Friendly, J.P
Jurassic computer : Sinclair ZX81 - Zilog Z80A à 3,25 MHz - RAM 1 Ko - ROM 8 Ko

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: How to integrate Bass library to Lazarus?
« Reply #11 on: July 06, 2018, 07:07:29 am »
on windows 10 with Lazarus 1.8.2 32 bits, i use ACS version 3.0.0.0 installed from Package On Line manager.
in attachment, my project to monitor input audio source. 
Friendly, J.P
Oh OPM. Ok thanks for the input.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Fred vS

  • Hero Member
  • *****
  • Posts: 3168
    • StrumPract is the musicians best friend
Re: How to integrate Bass library to Lazarus?
« Reply #12 on: July 06, 2018, 11:18:15 am »
Re-hello.

With uos, it will work also for Windows, Linux, FreeBSD, Mac OSX, ARM rpi...

See video in attachment ---> the VU meters and the frequencies spectrum...
(source using uos is here: https://github.com/fredvs/strumpract)

Fre;D

« Last Edit: July 06, 2018, 09:10:16 pm by Fred vS »
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

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: How to integrate Bass library to Lazarus?
« Reply #13 on: July 06, 2018, 03:06:52 pm »
I also made a unit for BASS https://github.com/Zaflis/nxpascal/blob/master/src/nxBass.pas
Using the class will be far easier when just wanting basic sort of audio working. Only dependency is nxTypes unit because bass can integrate with 3D gaming.

 

TinyPortal © 2005-2018