Author Topic: BASS_GetVolume() doesn't return the same value as Windows11 shows.  (Read 167 times)

Ferry

  • Posts: 6
Code: [Select]
BASS_Init(-1, 44100, 0, 0, NULL);
BASS_SetVolume(vol);
BASS_GetVolume()

I'm using newest BASS release.
I tested a number of values and looked at the volume of Windows that corresponded to them.

BASS   Windows
0.001   0.01
0.002   0.02
0.003   0.02
0.004   0.03
0.005   0.04
0.005   0.04
0.007   0.05
0.008   0.05
0.009   0.05
0.02     0.09
0.03     0.12
0.04     0.15
0.05     0.17
0.1       0.26
0.2       0.39
0.3       0.5
0.4       0.59
0.5       0.67
0.6       0.74
0.7       0.81
0.8       0.88
0.9       0.94
1          1

Why BASS_GetVolume() doesn't return the same value as Windows11 shows?
How to make the BASS volume map to Windows volume?

Now, I use a fitting func Windows_Volume=1.2119*BASS_Volume^0.6607

The reason I use BASS_SetVolume is: When switching output devices, the volume of the device switched to may be zero, so I need to adjust the volume of the device (ChannelSetAttribute(BASS_ATTRIB_VOL) only affect the channel, not the device).

Ian @ un4seen

  • Administrator
  • Posts: 26172
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 and BASS_WASAPI_CURVE_WINDOWS), so you could use that just for volume control if needed.

Ferry

  • Posts: 6
Thanks!

According to the document, BASS_WASAPI_SetVolume has no effect on exclusive mode output. The meaning is It has no effect on both session volume and device volume when exclusive mode is enabled, right?

Seems to have effect on device volume.

However, I will test it later.

Ian @ un4seen

  • Administrator
  • Posts: 26172
Setting the device volume via BASS_WASAPI_SetVolume does also affect exclusive mode. It's only the per-app session volume option (BASS_WASAPI_VOL_SESSION) that doesn't apply to exclusive mode.

Ferry

  • Posts: 6
Thank you very much. For newcomers in the audio field, this forum is really friendly.