Re: LPCM Downmix Algorithm problem
Re: LPCM Downmix Algorithm problem
- Subject: Re: LPCM Downmix Algorithm problem
- From: Brian Willoughby <email@hidden>
- Date: Sun, 15 Aug 2010 12:13:54 -0700
On Aug 14, 2010, at 21:01, Ryan Walklin wrote:
On 15/08/2010, at 3:47 PM, Bob Ingraham wrote:
So, here;s the issues: I have signed 16-bit integers (-32768 to
32767) representing a quantized wave form (below / above x-axis)
and I want to add these "waves" together.
So, I started out with (assuming 2:1 down-mix):
Mixed-Sample = Sample1 + Sample2
But this produces overflow/underflow and I assumed that just
allowing an overflow/underflow to "wrap" according to the rules of
signed 16-bit integer arithmetic doesn't produce a correct result.
Quite right, your waveform will clip and you'll hear static.
Wrapping will give you aliasing, which won't sound very nice either.
Clipping will also produce aliasing because it adds odd harmonics
without stopping at the Nyquist frequency.
Scaling seems to make the most sense. I'd hoped my research would
have turned-up some well-known way to down-mix LPCM samples, but I
haven't found anything definitive.
This was much easier in analog days :).
There is no magic way to avoid clipping, even in analog. Listen to a
classic track like Led Zeppelin's Black Dog. The song opens with
loud solo guitar, but as each new instrument is added the volume of
the guitar is noticeably reduced. The mix engineer automatically
handled the gain reduction while adding instruments to the mix by
watching the meters.
Your choices are either to apply the easy-to-calculate maximum gain
reduction - which would guarantee that nothing will clip - or you can
use dynamic gain processing to simulate the engineer (poorly) - which
assumes float, or at least some headroom in fixed like the way Pro
Tools leaves 96 dB of fixed-point headroom in their DSP.
If you're on the iPhone's iOS flavor of CoreAudio, then you're not
working in float, so you'll have to use different techniques than
with CoreAudio on OSX.
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