• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Peak and averagePowerForChannel are nice, but what about the actual current power?


  • Subject: Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
  • From: email@hidden
  • Date: Fri, 15 May 2009 11:50:40 -0700

Thanks Hamish for the help.

I don't need sample-level granularity. 1/60th of a second is fine, but I need the true level, not an averaged level, and the falloff is longer than 1/60th of a second.

But I think I've figured out what's going on. CASound, part of the avTouch build, is what's actually driving the source of the meter data. It's an audioqueue hook into the audio, and includes a call to poll the "kAudioQueueProperty_CurrentLevelMeterDB" property which does seem to return the actual power.

At least that's how I understand it right now. If I'm wrong, please correct me. Otherwise, I'll try it out tonight and see if it's what I think it is.

Thanks again.



Quoting Hamish Allan <email@hidden>:

If you need to work at the sample level, I suspect you'll have to
examine PCM data, converting if necessary using lower-level APIs.

SpeakHere et al show a meter, but not with actual power levels.
Average is plenty good enough for their purposes.

Best wishes,
Hamish

On Fri, May 15, 2009 at 5:37 PM, <email@hidden> wrote:
Right, but the problem is the falloff period. If the first sample is -10db
and the second sample is 0db, the average called on sample one will be
-10db, but the average called on sample two will be something shy of -5db
(the average minus the falloff increment.) Unless the falloff period is less
than the frequency of the calls, the average will always be different than
the instantaneous, whatever the granularity is.

If there was a way to set the falloff period to 0, than average would
essentially be the same as instantaneous, but I don't see a way to set that.

Thanks for hanging in with me. I'm totally stumped on this one.



Quoting Hamish Allan <email@hidden>:

Hi,

-[CALevelMeter _refresh], which calls -[AVAudioPlayer updateMeters],
gets called 60 times a second, i.e., averages power over 1/60th of a
second. This granularity is fine for the purposes of a meter. What
kind of granularity do you need?

Best wishes,
Hamish

On Fri, May 15, 2009 at 5:12 PM,  <email@hidden> wrote:

Thanks Hamish, but I don't think this is correct, for two reasons.

First, Apple would have to have redefined and swapped established terms
for
audio reference. "Average power" is a very specific thing, which is very
different than instantaneous power. Take a look at this image:
http://en.wikipedia.org/wiki/File:Peak-power-average-power-tau-T.png

Peak power is P(0), average power is P(avg), and instantaneous power is
p(t). So Apple is calling instantaneous power average power?*

I don't think so, for the second reason, which is I've tested this. I've
played an audio sample graphing both average and peak powers in a 2d
graph.
If one of these was the instantaneous power, they should look like (half
of)
the waveform graph. They don't. They look exactly like what you'd expect
for
peak and average graphs. The peak graph tops out at the top of max power,
and average rises with peaks and slowly decreases until the next peak.

All that being said, you're right that it looks like average is being
used
in _refresh. That's where I'm stuck. That's as far as I got before
mailing
the list. Looking at avtouch, it seems like average is the answer. But
when
I graph it out, it's clearly not instantaneous power, but rather true
average power.

Any thoughts?

Thanks so much for the help.



(*- average power is a very useful thing. It's the closest thing we have
to
"perceived volume." I'm glad we have it, but it doesn't replace
instantaneous power.)




Quoting Hamish Allan <email@hidden>:

The "actual" power is available through -[AVAudioPlayer
 averagePowerForChannel:]

See -[CALevelMeter _refresh] in avTouch/Classes/CALevelMeter.mm

Best wishes,
Hamish

On Fri, May 15, 2009 at 3:50 PM, Ochen Kaylan <email@hidden> wrote:

You're right, of course. My mix up. I've actually been going through the code of avTouch, which does use AVAudioPlayer and has a meter that shows actual power and peak power. It uses peakPowerPerChannel to calculate the latter, but I can't figure out how it's calculating the actual power.

(I'm learning AudioQueue for one project while implementing
AVAudioPlayer
in
another, and occasionally make a mistake like above. Sorry for that.)

So back to AVAudioPlayer, how do I get the current sample power? Is it
even
possible?

Thanks much.


On May 15, 2009, at 9:20 AM, Hamish Allan wrote:

Hi,

The version of SpeakHere I have in my Developer Examples does not use
AVAudioPlayer.

Best wishes,
Hamish

On Fri, May 15, 2009 at 3:14 PM, Ochen Kaylan <email@hidden> wrote:

Am I missing something, or is there no direct way in AVAudioPlayer to get the actual power of an AVAudioPlayer object sample? There's clearly some way to get it, since the various metering apps (a la SpeakHere) show a meter with actual power levels along with (usually) the peak power levels. So how do I access the current level when the only properties available are for peak and average, neither of which return the actual current power?

Thanks.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

















_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
      • From: Brian Willoughby <email@hidden>
References: 
 >Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Ochen Kaylan <email@hidden>)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Hamish Allan <email@hidden>)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Ochen Kaylan <email@hidden>)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Hamish Allan <email@hidden>)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: email@hidden)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Hamish Allan <email@hidden>)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: email@hidden)
 >Re: Peak and averagePowerForChannel are nice, but what about the actual current power? (From: Hamish Allan <email@hidden>)

  • Prev by Date: Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
  • Next by Date: Re: AUGraph mixer callback on inputs
  • Previous by thread: Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
  • Next by thread: Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
  • Index(es):
    • Date
    • Thread