On Tue, 18 May 2004, Dwayne Reid wrote: > At 08:53 PM 5/17/2004, M. Adam Davis wrote: > >I'm looking at adding two or more audio streams (for the sake of > >discussion let's say they are 8kHz, 8 bit standard voice grade). > > > >Further, I'd like to avoid 16 bit calculations if possible. > > This isn't what you want, but if you limited it to 2 channels of 8 bit > data, you could do the classic > > movfw inputA ;add inputs A&B, result in inputB > addwf inputB,F ;9 bit sum, inc C > rrf inputB,F ;/2 > > This, of course, is limited to 2 channels. I'm neither a DSP or Audio guru, but this can't be right. Suppose one of the streams is quiet. This combination will attenuate the other. Simple analog mixers work somewhat similar to this, however they have more dynamic range. So boosting the mixed (and attenuated) output has less degradation on the signal then chopping off one of the bits on an 8-bit digital signal. I would be more inclined to sum the streams together and clip the results. The chances two samples will sum to a value that clips will only happen when both are large at the same instant. I suspect (remember, I'm no audio guru) that clipping will be fairly infrequent unless both channels are 'loud' prior to being mixed. In this situation, the channels will already be clipping (because the chances for random noise [or voice] to have a large rms value and not clip is statistically unlikely). So a bad signal will sound a little worse with this approach, but a good signal will sound about the same. I think there are several factors to consider before settling on an approach. First, how should the digital data be represented? It seems more natural to work with signed 8-bit numbers. What's the mapping between the analog and digital representations? I'd imagine some sort of logarithmic transformation would be more practical. How are the streams coming in? Are all 16 presented at once or do they come one at a time? Is it possible to increase the mixed dynamic range by 4-bits (then this problem is easily solved for 16 channels)? Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body