Re: Peak and averagePowerForChannel are nice, but what about the actual current power?
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: William Stewart <email@hidden>
- Date: Fri, 15 May 2009 11:45:32 -0700
AVAudioPlayer uses the metering code from AudioQueue - so in this
instance, the differences between SpeakHere and AVPlay is one of
simplicity of coding.
The metering is performed on the data that you see as a client of
audio queue (or AVAudioPlayer) - if the data you see/provide is
compressed, then the metering is done before/after conversions to/from
linear pcm. If your client data format is linear pcm, then the
metering is basically done on that data.
If this is not what you want or need, then you will have to go through
the linear pcm data yourself.
Bill
On May 15, 2009, at 9:47 AM, Hamish Allan wrote:
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
_______________________________________________
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