Author Topic: GetVolume issue  (Read 268 times)

aaronegger

  • Posts: 26
GetVolume issue
« on: 21 Dec '21 - 18:00 »
Hi there,

i am currently struggling with the BASS_GetVolume function.
I have two different issues. One that affects Windows systems and the other a linux arm system (Raspbian Buster on a Rpi Model 3b).

On Raspbian retrieving the volume works one time and it returns the expected value, but afterwards it doesn't change if the volume is changed outside the program. Only after calling Bass_SetVolume the value is updated to the new value.
But changing the systemvolume with amixer (amixer set Master xx%) or setting it from the volume control at the taskbar it doesn't get updated. Only after restarting the app it works for one time.
Is there any trick i can do to force it getting the master volume of the system?

Running this on windows seems fine. It updates the volume if i change it from the taskbar or with the keyboard volume control.
But the result is not matching the value that can be seen at the volume control.
I know that there is a thread where it is mentioned that the visible volume control does some magic calculation before displaying them.

Does anybody know how this value is calculated?
I created a function (c#) that result usable values:
(float)Math.Round(Math.Pow((((Bass.BASS_GetVolume() * 100) - 0.008) / 0.0320827), (1 / 1.746994))) / 100f
But this feels like a dirty hack and if you set the round function to use 2 more digits the result will be up to 0.001f from the expected result. This issue is not that critical for me. It is more a nice to have.

I would be happy about any idea.

Ian @ un4seen

  • Administrator
  • Posts: 24330
Re: GetVolume issue
« Reply #1 on: 22 Dec '21 - 16:17 »
On Raspbian retrieving the volume works one time and it returns the expected value, but afterwards it doesn't change if the volume is changed outside the program. Only after calling Bass_SetVolume the value is updated to the new value.
But changing the systemvolume with amixer (amixer set Master xx%) or setting it from the volume control at the taskbar it doesn't get updated. Only after restarting the app it works for one time.

Oh yes, there is indeed an issue preventing BASS from seeing changes made externally. Here's an update that should fix it:

   www.un4seen.com/stuff/bass-linux-arm.zip

Let me know if you still see the problem happening with that.

Running this on windows seems fine. It updates the volume if i change it from the taskbar or with the keyboard volume control.
But the result is not matching the value that can be seen at the volume control.
I know that there is a thread where it is mentioned that the visible volume control does some magic calculation before displaying them.

Does anybody know how this value is calculated?
I created a function (c#) that result usable values:
(float)Math.Round(Math.Pow((((Bass.BASS_GetVolume() * 100) - 0.008) / 0.0320827), (1 / 1.746994))) / 100f
But this feels like a dirty hack and if you set the round function to use 2 more digits the result will be up to 0.001f from the expected result. This issue is not that critical for me. It is more a nice to have.

This is because Windows volume controls use a hybrid curve, not linear or logarithmic, ie. it isn't a percentage or decibel value. Information on that can be found here:

   https://docs.microsoft.com/en-us/windows/win32/coreaudio/audio-tapered-volume-controls

BASS doesn't provide the option of using Windows hybrid curve, but BASSWASAPI does (see BASS_WASAPI_SetVolume), so you could use that just for volume control if needed.

aaronegger

  • Posts: 26
Re: GetVolume issue
« Reply #2 on: 11 Jan '22 - 08:16 »
Yes the update fixed this issue. It now works fine. Thank you very much for that!

I also will take a look at BASSWASAPI and the Microsoft documentation.
Thank for this.

And of course..
I wish you a happy new year!