Re: AudioConverter gives non normalized samples?!
Re: AudioConverter gives non normalized samples?!
- Subject: Re: AudioConverter gives non normalized samples?!
- From: Brian Willoughby <email@hidden>
- Date: Wed, 28 Jan 2009 12:07:29 -0800
(I've trimmed this down to keep the message small, with the goal of
reviewing the basics)
On Jan 28, 2009, at 08:42, Doug Wyatt wrote:
More seriously, you could think of the range of floating point
samples that will not clip when converted to integer as [-1, 1).
You don't know how close to 1 you can get on the positive side
because you don't know whether the eventual integer has 12, 16, 20
or 64 bits.
If someone absolutely wants to avoid distortion, then they need to
adjust gain so that samples fall within (-1, 1) assuming that the
waveforms are symmetrical, as in a softsynth. This sacrifices one
sample value - the most negative - in exchange for not clipping the
positive wave excursion. To be safe pick 12 bits or even 8 bits for
your calculation of the "maximum" and you won't go into clipping for
the higher bit depths (but you will lose a few more codes at the
extreme). Don't be too anal about milking every last possible code
out of the range, because some DAC circuits cannot handle the
extremes without clipping in the analog realm anyway.
If you're implementing a limiter or other automatic gain, then you
can deal with arbitrary waveforms by using different limits for the
negative and positive wave halves. There should only be one gain
factor, but you can compare samples against different limits on each
end, since the actual limit is different.
That is incorrectly; it should always be multiplying and dividing
by 32768. I've submitted feedback to that effect.
Yes. I deleted Mike's asymmetrical conversion range, but I wanted to
reinforce the fact that the mul/div factor should always be the same
for both positive and negative, and it should be a nice power of 2.
Anything else creates distortion, especially in pass-through
situations. Many programmers obsess about reaching that last sample
value for certain waveforms, but the truth is that twos-complement
integers are asymmetrical by design, and you cannot fix this by using
an asymmetrical conversion - it just turns out worse.
Brian Willoughby
Sound Consulting
_______________________________________________
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