[comp.dsp] Digital mixing using interleaved signals

d88-jwa@nada.kth.se (Jon W{tte) (10/04/89)

>>In article <9247@pyr.gatech.EDU> byron@pyr.UUCP (Byron A Jeff) writes:
>>>The only question is what's the sample rate of the mixed signal? It
>>>would seem to be 8x the original sample rate yes? So for 8 48Khz channels
>>>I'd need a 384 Khz DAC. Ouch! 

>In article <1845@draken.nada.kth.se> d88>jwa@nada.kth.se (Jon W{tte) writes:
>>No, not really. You apply a digital filter on the signal, and then use
>>each eigth sample. Yes, it'll work ! Someone said that you should apply
>>this BEFORE you fed the signal to the DSP, but then you would have no
>>channel separation (the channel separatio is in the time domain if you
>>interleave the samples, and the filter truly messes this up) and all the
>>channels would come out mixed equally.

In article <9264@pyr.gatech.EDU> byron@pyr.UUCP (Byron A Jeff) writes:
>'Wow!' he exclaims incredulously. Would you please go into a little more
>detail on how this black magic works? Also is it possible to scale
>the samples for individual channel volume control before using the filter?


Of course it would be possible to scale the individual samples before
filtering, that's what it's all about !

If you have a 8-interleaved signal (i.e. eight channels coming in at
eight times the speed in an interleaved stream) you'll just have to
keep track of the phase, and multiply each eighth + n (where n is
channel 0 - 7) byte with the scale factor for channel n.

Then, after scaling, you apply the filter. Note! This is the "magic"
since the filter works in the time domain and the interleave doesn't,
but quite obvious once you've seen it: (Just two channels for clarity)

Input channel 0:

        !   !   !   
        !   !   !   !
    !   !   !   !   !
    !   !   !   !   !
    !   !   !   !   !
    !   !   !   !   !
    !   !   !   !   !

Input channel 1:



      !       !      
      !       !     
      !       !   ! 
      !   !   !   ! 
      !   !   !   ! 

Output after interleave:

        !   !   !   
        !   !   !   !
    ! ! !   ! ! !   !
    ! ! !   ! ! !   !
    ! ! !   ! ! ! ! !
    ! ! ! ! ! ! ! ! !
    ! ! ! ! ! ! ! ! !

    0 1 0 1 0 1 0 1 0  (channel)


As you see, there are some transients where the signals are very different
in level, and the curve looks "smooth" where the signals "match". Now, for
the magic: A digital fiter, with, say, 100 dB/octave, cuts away (averages)
the transients, but leave the "matching" parts alone:

Output after filtering:


      !       ! 
    ! ! ! ! ! ! !
    ! ! ! ! ! ! ! ! !
    ! ! ! ! ! ! ! ! !
    ! ! ! ! ! ! ! ! !
    ! ! ! ! ! ! ! ! !

Taking each second sample, we get:


      !       ! 
      !   !   !  
      !   !   !   !  
      !   !   !   !  
      !   !   !   !  
      !   !   !   !  

Voila ! (Try adding the two inputs and then dividing by two - you'll
get a similar graph)

This method has a VERY BIG advantage: If you only have input on one
channel, that equals the "zero padding" used in oversampling, (which
I was corrected on in this group a week ago, thanx !) and you still
get output at the same level ! If you used the "scale and add" version
of mixing, you'd get double the output with two channels in as woth one,
but this is obviously not the case with interleave mixing !

Hope this clarifies for you !

							h+@nada.kth.se
-- 
Documentation is like sex: When it's good, it's fantastic, when it's bad...