RE: LPCM Downmix Algorithm problem
RE: LPCM Downmix Algorithm problem
- Subject: RE: LPCM Downmix Algorithm problem
- From: "Edwards, Waverly" <email@hidden>
- Date: Mon, 16 Aug 2010 08:17:30 -0500
- Acceptlanguage: en-US
- Thread-topic: LPCM Downmix Algorithm problem
This may work
mixedSample = SampleA + SampleB - SampleA * SampleB / 32768
You sample is normalized but no, it does not avoid clipping.
W.
-----Original Message-----
From: coreaudio-api-bounces+waverly.edwards=email@hidden [mailto:coreaudio-api-bounces+waverly.edwards=email@hidden] On Behalf Of Brian Willoughby
Sent: Sunday, August 15, 2010 3:14 PM
To: Ryan Walklin
Cc: coreaudio-api
Subject: Re: LPCM Downmix Algorithm problem
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
_______________________________________________
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