Getting Levels While Recording
Getting Levels While Recording
- Subject: Getting Levels While Recording
- From: Dan Messing <email@hidden>
- Date: Thu, 17 Aug 2006 11:09:52 -0500
Hi,
I'm trying to get levels while recording an audio sample - or rather
I'm trying to make it work on an intel machine based on existing code
that works on PPC.
The current code looks like this:
Float32 *samples = (Float32 *)buffer->mData;
Float32 *limit = (Float32*) (((UInt8*)samples) + buffer-
>mDataByteSize);
where buffer is of type AudioBuffer *
This is then passed to the function:
static void computeMaxLevels ( float* samples, Float32* limit,
Float32 levels[2] )
{
Float32 leftMin, leftMax, rightMin, rightMax;
leftMax = leftMin = rightMax = rightMin = 0.0;
// compute the maximum level in each channel (hardcoded Float32
samples, 2 interleaved channels).
while ( samples < limit )
{
Float32 left = samples[0];
if (left > leftMax)
leftMax = left;
else if (left < leftMin)
leftMin = left;
Float32 right = samples[1];
if (right > rightMax)
rightMax = right;
else if (right < rightMin)
rightMin = right;
samples += 2;
}
levels[0] = max ( leftMax, abs(leftMin) );
levels[1] = max ( rightMax, abs(rightMin) );
levels[0] = 20.0 * log10(levels[0] * levels[0]);
levels[1] = 20.0 * log10(levels[1] * levels[1]);
}
PPC - the levels come out fine, but on intel they are way out of
whack, making me think I'm dealing with a different data format on
that platform.
I've been looking through all the docs I can find to see what the
data in buffer->mData looks like, but I am really out of my depth
with this coreAudio stuff. If anyone can offer a helping hand, I
would greatly appreciate it, even if it's to tell me that I'm looking
in the wrong place to fix this problem.
Thanks,
Dan
_______________________________________________
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