Re: [Audacity-devel] Where does LPCM down-mixing code live?
A free multi-track audio editor and recorder
Brought to you by:
aosiniao
From: Martyn S. <mar...@gm...> - 2010-08-16 23:50:00
|
On 16/08/2010 02:44, Bob Ingraham wrote: > > On Sun, Aug 15, 2010 at 5:54 PM, Martyn Shaw <mar...@gm... > <mailto:mar...@gm...>> wrote: > > Convert to float/double before all other operations? Then you won't > get the clipping of adding 16-bit floats together. Just a thought. > > That makes sense, and that is what I am doing. Good. > However, after all of the sample addition has been completed, I still > have to export the resultant downmixed stream back to a 16-but signed > format, at which point, it will 'may' clip unless I apply some sort of > constant scaling factor to scale the waveform back into the 16-bit domain. True. We allow that to happen and don't do anything automatically. We keep the 'real' values as floats internally but limit to +-1 for export / 'View->Show Clipping'. What should that 'constant scaling factor' be? You could search for the peak and then divide out, taking away user control. Or use '/2' or some other magic number. We have Effect->Amplify... and are happy with that. You may have a different situation where you want to do that automatically. Dividing by the number of streams will typically give you an over-quiet result if the sources are uncorrelated, which most real-world sources are. Apologies if I misled you before. HTH Martyn PS Never multiply the samples together. > We do it (eventually) in Mix.cpp MixBuffers li317. > > I read through Mix.cpp and saw that sample were simply added as floats > (with what looked like an optional per-channel gain multiplier.) > But I assume that the export function must take care of the scaling > because that is where it is going to have to write-out the resultant > file as 16-bit signed, 44.1KHz, etc (assuming that is what I tell it to > export to.) > > HTH > Martyn > > Thanks! > > On 12/08/2010 03:58, Bob Ingraham wrote: > > Hello, > I have been attempting to implement a software-only Linear PCM > down-mixing algorithm (i.e., combining multiple LPCM streams > (16-bit-signed, 44.1KHz, 2-channel) into a LPCM single stream,) > in Java > but am having limited success with finding a good algorithm. > Lots of Googling and experimentation but mediocre down-mixed > results. > Apparently, adding LPCM samples together and dividing by the total > number of samples added, doesn't cut it... That's where I > started and > then went on tweaking from there, but the best result I get is > that I > can distinguish the individual source streams, but there's so much > "static" noise introduced by my algorithm that it renders the result > unuseable. > So, I've downloaded the Beta source from SVN and am starting to go > through it to see if I can find out how the experts do it. > Which brings me to my question: Would someone be kind enough to > point me > to the part of the source tree that deals with down-mixing LPCM > streams? > Thanks, > Bob > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by > > Make an app they can't live without > Enter the BlackBerry Developer Challenge > http://p.sf.net/sfu/RIM-dev2dev > > > > _______________________________________________ > audacity-devel mailing list > aud...@li... > <mailto:aud...@li...> > https://lists.sourceforge.net/lists/listinfo/audacity-devel > > |