Re: Canonical format max amp limits?
Re: Canonical format max amp limits?
- Subject: Re: Canonical format max amp limits?
- From: Stephen Davis <email@hidden>
- Date: Wed, 14 Jul 2004 10:47:19 -0700
You've just proven that you cannot convert to fixed-point by clipping
to +1.0f
because that exceeds the range of twos-complement numbers (when
normalized as
defined). One solution is to convert to a larger fixed-point number,
such as a
32-bit integer register, and then clip to the lower bit depth e.g. to
32767 if
your result is 16-bit. This is easier to handle in fixed-point,
because the
actual maximum possible float value is very close to, but less than
+1.0f, and
it is different for 16-bit vs. 24-bit (or 20-bit, if your interface
is working
with 20-bit D/A).
Clipping requires the use of an if statement does it not? Two if I'm
not mistaken. One to check if it's over and one to check if it's
under.
The PowerPC has an instruction that will convert to 32-bit integer with
clipping so, with proper pre-/post- scaling, you can convert to integer
with no branches. It's quite fast.
One really good reason for using the AudioConverter is that you won't
make
these kinds of mistakes.
Perhaps not, but then you pay the price of the function call overhead
for the callbacks.
Yes, but the highly optimized blitter will most likely more than make
up for that overhead.
The DIY method requires that you learn a lot about optimization, and
there's
no reason to believe that you'll do a better job than Apple. For
example, your
code uses the C language ?: operator, which is equivalent to an
if-else
construct, which really messes up the instruction cache. Your code
is already
slower than the AudioConverter for that reason alone, not to mention
that some
manual unrolling, or use of non-standard compiler options, is needed
for top
speed. Add to all the above the fact that AltiVec optimization is
not fully
automatic, and that takes performance to an entirely higher level if
you know
how to write AltiVec code.
The clipping requires more if statements than the one presented in my
sample code. How does that make mine slower? Does CoreAudio use
AltiVec?
Yes, and the AltiVec unit can do branchless clipping as well.
stephen
P.S. I am not on the CoreAudio team so I don't speak for them but I
talk to them a lot. :-)
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.