Recent

Author Topic: [SOLVED] BASS - No Volume Control  (Read 1980 times)

QEnnay

  • Full Member
  • ***
  • Posts: 117
[SOLVED] BASS - No Volume Control
« on: May 20, 2020, 07:53:06 pm »
Hi I am using BASS to play MP3 and it does it very nicely. But the Volume Up/Down does not work.

I am using Lazarus 2.0.8 on Linux Mnt 19.3+Cinnamon. There is only a single standard option in the Mint-Sound Output dialog.

Code: Pascal  [Select][+][-]
  1. function BASS_SetVolume: Single; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassdll;
  2.  
  3. procedure TfrmMain.btnVolUpClick(Sender: TObject);
  4. begin
  5.   if trackVol < 100 then  // Got the 100 from Bass unit {0..100}
  6.     Inc(trackVol,5);
  7.   BASS_SetVolume(trackVol);
  8.   lblVol.Caption:=IntToStr(trackVol);
  9. end;
  10.  

The numbers roll around OK, but the sound does not change. Do I need to initialize the Sound somewhere for BASS?

Thanks
« Last Edit: May 21, 2020, 09:38:44 pm by QEnnay »
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

varianus

  • New Member
  • *
  • Posts: 22
Re: BASS - No Volume Control
« Reply #1 on: May 21, 2020, 08:20:45 am »
BASS volume goes from  0.0 (silent) to 1.0 (max). , see documentation at http://www.un4seen.com/doc/#bass/BASS_SetVolume.html

so your code should become (untested)
Code: Pascal  [Select][+][-]
  1. procedure TfrmMain.btnVolUpClick(Sender: TObject);
  2. begin
  3.   if trackVol < 100 then  // Got the 100 from Bass unit {0..100}
  4.     Inc(trackVol,5);
  5.   BASS_SetVolume(trackVol * (1.0 /100));
  6.   lblVol.Caption:=IntToStr(trackVol);
  7. end;

Cyrax

  • Hero Member
  • *****
  • Posts: 836
Re: BASS - No Volume Control
« Reply #2 on: May 21, 2020, 12:51:37 pm »
Correct definition for this function should be this according to the documentation.
Code: Pascal  [Select][+][-]
  1. function BASS_SetVolume(AValue: Single):boolean; {$IFDEF MSWINDOWS}stdcall{$ELSE}cdecl{$ENDIF}; external bassdll;

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: BASS - No Volume Control
« Reply #3 on: May 21, 2020, 03:24:23 pm »
Hi!

Nearly all values for set and get in BASS have a range from 0.0 .. 1.0
The stereo balance (B_PAN) has a range from -1.0 .. +1.0

Winni

QEnnay

  • Full Member
  • ***
  • Posts: 117
Re: BASS - No Volume Control
« Reply #4 on: May 21, 2020, 09:29:01 pm »
Ahhh, OK, thanks everyone. I got the 0..100 from BASS, line #577

Code: Pascal  [Select][+][-]
  1.   BASS_SAMPLE = record
  2.     freq: DWORD;        // default playback rate
  3.     volume: Single;     // default volume (0-100)
  4.  
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

QEnnay

  • Full Member
  • ***
  • Posts: 117
Re: BASS - No Volume Control
« Reply #5 on: May 21, 2020, 09:38:10 pm »
Code: Pascal  [Select][+][-]
  1.   BASS_SetVolume(trackVol * (1.0 /100));
  2.  

Tested! :)
Thanks, that works perfectly.
Linux-Mint 20.1 x64 + Cinnamon; Lenovo Flex 5 Ryzen 5 4500, 16GB memory
FPC: 3.2.0-1, Lazarus 2.0.12-0, all 64bit

 

TinyPortal © 2005-2018