The dirty little secret of Windows volume
Here's a dirty little secret about volume in Windows.
If you look at the documentation for waveOutSetVolume it very clearly says:
Volume settings are interpreted logarithmically. This means the perceived increase in volume is the same when increasing the volume level from 0x5000 to 0x6000 as it is from 0x4000 to 0x5000. |
The implication of this is that you can implement a linear slider for volume control and use the position of the slider to represent the volume. This is pretty cool.
But if you've ever written an application that uses the waveform volume (say an app that plays content with a volume slider attached to it), you'll notice that your volume control is far more responsive when it's on the low end of the slider and less responsive on the high end of the slider.
That's weird. The volume settings are supposed to be logarithmic, but a slider that's more responsive at the low end of the scale than the high end of the scale is an indicator that the slider's controlling LINEAR volume.
And that's the dirty little secret. Even though the wave volume is supposed to be logarithmic, the wave volume is actually linear.
What's worse is that we didn't notice this until we shipped Media Center Edition. The PM for my group was playing with his MCE machine and noticed that the volume was linear. To confirm it, he whipped out his sound pressure meter (he's a recording artist so he has stuff like that in his house). And yup, the volume control was linear.
When he came back to work the next day, panic ensued. I can't explain WHY nobody had noticed this, but they hadn't.
In response, we added support (for XP SP2) for customized volume tapers for the audio APIs. The results of that are discussed in this article.
Interestingly enough, it appears that this problem is well known. The article from which I stole this image discusses the problem of linear vs. logarithmic tapers and discusses how to find the optimal volume taper.
Edit: Cleared up some ambiguities in the language.
Comments
- Anonymous
June 16, 2005
Ah, HUGE pet peeve of mine.
Not enough granularity at the lower end of the scale. It's either inaudible, or loud enough to wake up the kids. No middle ground.
Especially annoying with laptops that have an "up volume" and "down volume" hotkey--these tend to exagerate the problem. - Anonymous
June 16, 2005
Winamp has a logarithmic volume setting, but it seems the curve is too steep and it comes out with the opposite problem: Half the slider is too soft to hear, and then it gets very loud very fast. Linear is the lesser of two evils.
Is this the same waveout volume control from the dark ages of 3.x? And was logarithmic volume an original design goal from way back then, or was it an XP upgrade that someone forgot to check for? - Anonymous
June 16, 2005
foxishadis, yes, the waveform APIs came in with Win3.1.
I'm not sure what the volume taper story is for waveform back that far ago.. - Anonymous
June 16, 2005
The comment has been removed - Anonymous
June 16, 2005
Oh, now I know what's wrong with my parents TV... - Anonymous
June 19, 2005
The comment has been removed - Anonymous
June 20, 2005
Peter, the zipper noise shouldn't happen with Windows because the volume that's being manipulated is an analog volume control (it's after the DAC). On the other hand, if your audio adapter doesn't have a hardware volume, then kmixer will create a software volume for it, it's possible that has a zipper problem.
For Longhorn, it won't :) I know. - Anonymous
June 21, 2005
You can still get zipper noise even with an analog control depending on the design (although you'd hope that wasn't the case)
I must have a play with the multimedia stuff again, I haven't looked at Windows in that area since NT4 so my knowledge is exceedingly out of date. (although probably less than I would expect) Time for some experimenting with sine waves perhaps...