• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: LPCM Downmix Algorithm problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: LPCM Downmix Algorithm problem


  • Subject: Re: LPCM Downmix Algorithm problem
  • From: Bob Ingraham <email@hidden>
  • Date: Sat, 14 Aug 2010 19:55:21 -0600

Thanks for the reply.
 
I implemented this algorithm but it resulted in generating what sounded like all static with discernible audio from the original source.
 
I also tried looking at the downmix source from Audacity, but it just seem to add samples (with a gain multiplier.) So, not much help there.
 
Surely, LPCM down-mixing isn't that complicated, is it?
 
Bob
On Fri, Aug 13, 2010 at 12:20 AM, uɐıʇəqɐz pnoqɥɒɯ <email@hidden> wrote:
After lots of Googling and such, I've put together something like: SampleDM = (Sample1 + Sample2 + ... + SampleN) / N, for each channel.

Where that fails is in the case of a sample being zero, which causes the SampleDM to needlessly get attenuated.  Also, if all samples are low amplitude, and don't overflow, then why attenuate?

You might want to try:

finalSample = sample1;
for (sampleIndex = 2; sampleIndex <= N; sampleIndex ++)
finalSample = (finalSample + sample[sampleIndex]) - (finalSample * sample[sampleIndex]);

or something like that....


On Aug 12, 2010, at 6:31 AM, Bob Ingraham wrote:

Hi,
 
I'm writing an app that reads multiple LPCM channels from a multi-channel device, monitoring each channel for the presence of audio (voice-activated recording, I guess you'd call it.)
 
I've got the silence-detection working pretty well, but the other requirement is to take all of the channels that are currently "active" (i.e., non-silent,) and downmix them to a simple stereo output stream, which will be compressed and written to file.
 
I can have up to 24 channels to downmix to 2 channels at a given instant (usually 16-bit-signed, 44.1KHz).
 
I know I can use the "channel mapping" feature of CoreAudio, but I have to port this to other OS' when I'm done, so I'm trying to impelment the downmixing algorithm myself.
 
After lots of Googling and such, I've put together something like: SampleDM = (Sample1 + Sample2 + ... + SampleN) / N, for each channel.
 
So, adding all the samples does the trick, but getting the resultant "super-sample" back within legal 16-bit range requires something better than dividing by the number of contributing samples, since this apparently messes with the volume, among other things.
 
There's probably more to it than that. I've "tweaked" my algorithm in various ways, and can now barely distinguish individual contributing source channels, but there's too much crackling, popping static in the downmixed sample stream to consider it usable.
 
I thought this would be simple, but I guess I'm the one who's simple. :-(
 
Any pointers from you gurus on what a real downmixing algorithm entails would be much appreciated.
 
Thanks,
Bob
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)

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

  • Follow-Ups:
    • Re: LPCM Downmix Algorithm problem
      • From: Paul Davis <email@hidden>
References: 
 >LPCM Downmix Algorithm problem (From: Bob Ingraham <email@hidden>)
 >Re: LPCM Downmix Algorithm problem (From: uɐıʇəqɐz pnoqɥɒɯ <email@hidden>)

  • Prev by Date: RE: Almost there with ExtAudioFile
  • Next by Date: Re: LPCM Downmix Algorithm problem
  • Previous by thread: Re: LPCM Downmix Algorithm problem
  • Next by thread: Re: LPCM Downmix Algorithm problem
  • Index(es):
    • Date
    • Thread