How to calculate the speaker's volume scale based on the decibel volume value?

Ivy Huang 0 Reputation points
2023-04-23T15:23:26.3266667+00:00

With one of my speaker (16bit, 48khz) attached to windows 11 system. I get can get the channel volume level using IAudioEndpointVolumeEx->GetVolumeRangeChannel as below: Min Volume: -63.50 dB, Max Volume: 0.00 dB, incremental: 0.03 dB

And when I set the volume scale as 0.5 (50% showing on the slide bar of volume control), I can get the volume level in decibels(dB) and in scale with IAudioEndpointVolume->GetChannelVolumeLevel() and IAudioEndpointVolume->GetChannelVolumeLevelScalar()

In my case of the given speaker, the value is -10.304707 dB and 0.5000.

Now I am trying to calculate the scale value by the given decibel value, with the given formula A = 10^(dB/20) (based on the doc https://learn.microsoft.com/en-us/windows/win32/coreaudio/audio-tapered-volume-controls), I can only get the scale value at around 0.305 instead of 0.5.

So it looks like the formula is not correct for my case. My question is, what is the formula I can use to do such conversion from the dB value to scale value? I need this as in my project I can only sent the decibel value remotely and then do the conversion there. Please let me know if the information I have provided here is not enough and I will provide more as suggested. Thanks.

Windows development | Windows API - Win32
{count} votes

1 answer

Sort by: Most helpful
  1. Xiaopo Yang - MSFT 12,731 Reputation points Microsoft External Staff
    2023-04-24T05:50:37.2333333+00:00

    As Audio-Tapered Volume Controls implied, the IAudioEndpointVolume interface uses a curve. You are free to use your own curve.

    In Windows Vista, these methods use a curve that is intermediate between the audio-tapered curve shown in the preceding diagram and a linear-tapered curve. Note that the shape of the curve might change in future versions of Windows.

    While

    The following interfaces use linear-tapered curves for their volume settings:


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.