[wdmaudiodev] Re: Peak Meter in Core Audio APIs

  • From: Clemens Ladisch <clemens@xxxxxxxxxx>
  • To: wdmaudiodev@xxxxxxxxxxxxx
  • Date: Mon, 21 Jun 2010 14:49:43 +0200

Andrew Mindrin wrote:
> Clemens Ladisch wrote:
> > Can you give an example where it doesn't correspond?
> 
> For example, IAudioEndpointVolume::GetVolumeRange returns max=0dB
> and min=-96dB. According to your way we never compute -96dB at the
> lower range when Current Volume = -96db and Peak Value = 0.5 or
> any other.

current output level = -96 dB + 20 * log10( 0.5 )
                     = -96 dB - 6 dB
                     = -102 dB

And this is correct.  Current volume = -96 dB means that any output is
played 96 dB lower than it would be played at full volume.

If you have a sound file that uses the full range of samples (i.e,
peak = 1), its output level would be 0 dB at full volume and 96 dB at
minimum volume.

If you then play a sound file that is more silent by 6 dB (peak = 0.5),
it will always play at a lower level than the first file, i.e., -6 dB at
full volume and -96 dB + -6 dB at minimum volume.

> > So if the current volume is -12 dB, and the peak value is at 0.5,
> > the meter would show -6 dB?
> 
> If max=0dB and min=-96dB it will show:
> 
> min + (Current Volume - min) * Peak Value = -96 + (-12 + 96) * 0.5 = -54 dB

(I was asking about your "1.  Current Volume (in dB) * Peak Value"
formula.)

So your proposed formula is now "min + (current_dB - min) * peak"?

This would imply that for silence (peak = 0), the current output level
is the same as the current volume setting (-96 dB).  However, the output
level of silence is actually -infinity dB.

The maximum output level cannot go higher than the current volume.
The minimum output level is always -infinity dB.


Well, I see this doesn't answer your original question; you want to
display the current output level in the _same_ space where you display
the volume slider.  This is not possible when the current overall output
level is less than the minimum possible volume setting.

You could just ignore any values that happen to be lower.

(You would not have this problem if the volume could go down to "muted".)

Please note that perceived loudness is not proportional to the dB value
(or to the linear sample value).  You should use a cubic mapping between
sample value and screen position; see
<http://www.robotplanet.dk/audio/audio_gui_design/>.


Regards,
Clemens
******************

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: