Recent

Author Topic: using bass to play sounds  (Read 4280 times)

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
using bass to play sounds
« on: June 12, 2020, 06:06:42 pm »
hi i am trying to use Bass from https://www.un4seen.com/ and downloaded 2.4.15 version
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, StdCtrls, BASS;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     procedure Button1Click(Sender: TObject);
  18.    
  19.   private
  20.  
  21.   public
  22.    channel:HSTREAM;
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.lfm}
  31.  
  32. { TForm1 }
  33.  
  34. procedure TForm1.Button1Click(Sender: TObject);
  35. begin
  36.   if channel>0 then
  37.   begin
  38.     BASS_StreamFree(channel);
  39.     channel:=0;
  40.   end;
  41. channel:= BASS_StreamCreateFile(False,pchar('C:\Users\alaa-laptop\Desktop\nasheed\CarmenSoliman.mp3'), 0, 0,BASS_UNICODE);
  42. BASS_ChannelPlay(channel,false);
  43. end;
  44. end.
  45.  
i added bass.dll to the location of application , but i am getting this error as in photos attached

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: using bass to play sounds
« Reply #1 on: June 12, 2020, 07:17:05 pm »
Hi!

You have to initialize the BASS subsystem:

Code: Pascal  [Select][+][-]
  1. procedure BassInit(H: HWND);
  2. begin
  3. {$IFDEF LINUX}
  4. BASS_Init(-1, 44100, 0, @H, nil);
  5. {$ELSE}
  6. BASS_Init(-1, 44100, 0, H, nil); /// !!! Bei Windows ohne Pointer, nur Handle
  7. {$ENDIF}
  8. end;
  9.  
  10. procedure TForm1.FormCreate(Sender: TObject);
  11. begin
  12. BassInit(Handle);
  13. end;
  14.  


Winni

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: using bass to play sounds
« Reply #2 on: June 12, 2020, 10:36:53 pm »
thanks
 everybody is invited to enjoy this free code

https://youtu.be/g98_SbLnBAw

thanks

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: using bass to play sounds
« Reply #3 on: June 13, 2020, 09:44:00 pm »
trying to play file from internet
Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   if channel>0 then
  4.   begin
  5.     BASS_StreamFree(channel);
  6.     channel:=0;
  7.   end;
  8.   //filename:=;
  9. channel:= BASS_StreamCreateURL(PAnsiChar('https://server10.mp3quran.net/ajm/012.mp3'), 0,BASS_STREAM_STATUS,nil,0):DWORD;stdcall;
  10. BASS_ChannelPlay(channel,false);
  11.  
  12. end;

but i got this error
Quote
Compile Project, Target: soundplayer.exe: Exit code 1, Errors: 1, Warnings: 1, Hints: 1
unit1.pas(54,114) Error: Incompatible type for arg no. 5: Got "ShortInt", expected "Pointer"
bass.pas(901,10) Hint: Found declaration: BASS_StreamCreateURL(PChar;LongWord;LongWord;DOWNLOADPROC;Pointer):DWord; StdCall;
unit1.pas(93,21) Warning: Implicit string type conversion from "AnsiString" to "UnicodeString"

any one could help?
thanks

jamie

  • Hero Member
  • *****
  • Posts: 6090
Re: using bass to play sounds
« Reply #4 on: June 13, 2020, 10:25:45 pm »
its obvious the last parameter is a pointer requirement and you have a constant 0 to it..

I suppose you could use a NIL instead.

but what does that pointer really do for you?
The only true wisdom is knowing you know nothing

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: using bass to play sounds
« Reply #5 on: June 13, 2020, 10:43:13 pm »
Hi!

The calling conventions are done in the interface - so you don't have to repeat it while coding.

And for a lot a reasons put the StreamCreateURL in a loop:
* Internet may be slow
* Server  may be slow
* Server may be  many hops away (Australia! NewZealand!)
* Temporary loss of connection ....

So give it 3 to 6 retries before you give up.
Code: Pascal  [Select][+][-]
  1. procedure PlayURL (URL : String);
  2. var i : integer = 0;
  3.      B_Stream:  DWord;
  4. begin
  5. repeat
  6. B_Stream := BASS_StreamCreateURL(Pchar(URL),0,BASS_Sample_Float,NIL,Nil);    
  7. inc(i);
  8. until (B_Stream <> 0) or (i>3);
  9. if  B _Stream  <> 0 then BASS_ChannelPlay(B_Stream,false);
  10. end;
  11.  

Winni

PS.: In the BASS package is a very good description of all functions in a chm file!
« Last Edit: June 13, 2020, 10:45:32 pm by winni »

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: using bass to play sounds
« Reply #6 on: June 13, 2020, 11:05:47 pm »
There is a tutorial that shows how to create a MP3 Player in 14 steps.

Language is german but there are a lot of translators around.

It is for Delphi users but as you are using Windows there is no difference:

http://www.gausi.de/memp-1.html

Winni

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: using bass to play sounds
« Reply #7 on: June 18, 2020, 10:53:22 pm »

please see this sample

https://youtu.be/n1KdWPGLlQY

thanks  :)

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: using bass to play sounds
« Reply #8 on: July 06, 2020, 06:57:52 pm »
hey guys

please enjoy learning from this video (advanced sound player)

https://youtu.be/85kCaxS_Kig

thanks

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: using bass to play sounds
« Reply #9 on: July 06, 2020, 10:50:10 pm »
Hi!

Nice video.
Awful music.

Winni

alaa123456789

  • Sr. Member
  • ****
  • Posts: 260
  • Try your Best to learn & help others
    • youtube:
Re: using bass to play sounds
« Reply #10 on: July 07, 2020, 07:24:58 pm »
Hi!

Nice video.
Awful music.

Winni

what to do no one offer nice music as free so u can use it in your videos :D ;D

thanks

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: using bass to play sounds
« Reply #11 on: July 07, 2020, 08:52:03 pm »
Hi!

Google broken?

https://www.audioblocks.com/royalty-free-audio/rock+n+roll

Search for "royalty free music rock'n'roll" ...

Winni

 

TinyPortal © 2005-2018