[wdmaudiodev] Re: Peak Meter in Core Audio APIs

  • From: Larry Osterman <Larry.Osterman@xxxxxxxxxxxxx>
  • To: "wdmaudiodev@xxxxxxxxxxxxx" <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Tue, 22 Jun 2010 15:45:06 +0000

First off: This answer only applies to output controls - the information in 
here is somewhat incorrect for input controls and I'm not going to adjust the 
answer (because it gets too complicated).

The answer is actually relatively straightforward. When the slider's at 0, the 
output volume is set to the minimum volume supported by the volume controls on 
the audio device (this has caused some problems on audio solutions who report 
their minimum volume as being something other than silence).  

It was very important that the slider be a linear volume control and that 
movement in every part of the sliders range cause a change in the output 
volume.  If we set the bottom of the slider to -infinity, there would be a part 
of the scale that did nothing (the part that represents the range from -96dB to 
-infinity).  So the volume slider runs from min volume to max volume (this has 
also caused problems since that means that when the slider's at the top of the 
volume range, audio solutions which do amplification in the digital domain 
sometimes cause distortion).

The peak meter value is much simpler than the volume control (there's a 
surprising amount of logic behind that simple volume slider).  It's simply the 
peak value of the audio samples that passed through the audio engine since the 
last time that someone retrieved the peak meter value (there's an artificial 
ramp to 0 when a client streams silence).  Since it's just a sample volume, it 
ranges from 0.0f to 1.0f where 0.0f is full attenuation and 1.0f is no 
attenuation.

The peak meter control isn't intended to be a precision measuring instrument, 
instead it's intended as a diagnostic tool - the meter values move when you 
play audio.

It turns out that when you overlay both the volume slider and the peak meter 
values, they correspond "well enough" to provide the visual feedback that's 
needed.  As an added bonus, there are actually two peak meter values displayed 
in the volume UI - the green line in the front is the signal strength after the 
volume control has been applied, there's also a gray line behind the green line 
which is the pre-volume control peak meter value.  This allows the user to 
visually determine that the reason they're not hearing something is because the 
volume control's too low.


Note that if you use the APIs, you CAN retrieve precise information - the dB 
version of the endpoint volume APIs provide untapered values - if you set the 
dB version of the endpoint volume to -25dB, you can be assured that the 
driver's volume control will receive a property set for -25dB.  Similarly, if 
you retrieve a peak meter value of .75, you can be assured that the loudest 
sample played since you last retrieved the volume had a floating point 
magnitude of 0.75f.

It's just the UI that's imprecise, that's because the UI is about 
troubleshooting and diagnostics, and not about precision.



Larry


-----Original Message-----
From: wdmaudiodev-bounce@xxxxxxxxxxxxx 
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Andrew Mindrin
Sent: Tuesday, June 22, 2010 6:10 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: Peak Meter in Core Audio APIs

Clemens Ladisch wrote:

> I'd guess that having different scales for the slider and for the peak
> display would be too confusing, and that converting the linear peak
> value to dB or to perceived loudness wasn't deemed worth the effort.
>
> But why are you asking me and not Larry Osterman?

As you may know that volume value in MS mixer (in Vista/7) is displayed
in logarithmic scale and in the same scale - peaks...

Of course, the answer from Larry Osterman is very welcome! :)

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

******************

WDMAUDIODEV addresses:
Post message: mailto:wdmaudiodev@xxxxxxxxxxxxx
Subscribe:    mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=subscribe
Unsubscribe:  mailto:wdmaudiodev-request@xxxxxxxxxxxxx?subject=unsubscribe
Moderator:    mailto:wdmaudiodev-moderators@xxxxxxxxxxxxx

URL to WDMAUDIODEV page:
http://www.wdmaudiodev.com/

Other related posts: