Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!valid!caber!lou From: lou@caber.valid.com (Louis K. Scheffer) Newsgroups: comp.dsp Subject: Re: 48k to 44.1k sample rate conversion Message-ID: <498@valid.valid.com> Date: 26 May 91 00:01:42 GMT References: <5826@media-lab.media.mit.edu.MEDIA.MIT.EDU> <457@valid.valid.com> <42200@ucbvax.BERKELEY.EDU> Sender: news@valid.com Lines: 96 parks@bennett.berkeley.edu (Tom Parks) writes: >In article <457@valid.valid.com>, lou@caber.valid.com (Louis K. Scheffer) writes: >|> The most straightforward way is as follows: You interpolate 146 zeros >|> between every sample to get a data rate of 7.056 MHz. You then >|> design a digital filter to low-pass this to 20 KHz. >This filter would have a cutoff frequency of approximately 0.003 times the >sampling rate, which is not a very easy filter to design. *MANY* filter >coefficients would be required for such a filter. True, but you only design it once (and it's done already, I've got the coefficients for those who want them). It takes about 10 CPU hours on a fast machine to design the filter (using Remez exchange, anyway). It takes 14000 coefficients to get +- 0.05 db passband, 104 db rejection stopband. >Instead, look at the prime factorization of the sampling rates: >44100 = 2^2 * 3^2 * 5^2 * 7^2 >48000 = 2^7 * 3 * 5^3 >To convert from 48000 to 44100, you can cascade several sample rate converting >filters with much smaller ratios. For example, increase the sampling rate by a >factor of 3, then decrease by a factor of 2, increase by a factor of 7, >decrease by a factor of 2, decrease by a factor of 5, increase by a factor of >7, then decrease by a factor of 2 three times. >Some of these filters can have *VERY* broad transition bands since previous >filters will have removed components which could cause aliasing. This means >that you will only have to design a set of very simple filters, instead of >having to design one filter with a huge number of coefficients. Agreed, but you only design it once, and the program source is published in "Theory and Application of Digital Signal Processing" by Rabiner and Gold. (Actually, you need to tune it up a little for such large filters, but that's only a few days work.) >You'll find >that the computational requirement to implement the cascaded filters is lower. >You can also play around with the order in which you raise and lower the >sampling rate. This appraoch will work, but it's not clear the computational requirement is any less. Direct convolution by the 14000 tap filter takes about 95 multiply adds per output point (since 146/147 of the input samples are 0). In your example, the very first filter does: increase by 3 decrease by 2 at 144 KHz (but 2/3 inputs are 0) throw away 1 of 2, rate now 72 KHz. This filter looks like a 3x oversampling filter, and will require about 130 coefficients, for a 130/3 = 43 multiplies per output sample (and output is at a 72 KHz rate, so this implies 43 * 72/44.1 = 70 multiplies per (44.1 KHz) output sample. You then need to: increase by 7 decrease by 5 at 504 KHz ( 6/7 non zero) throw away 4 of every 5 samples, rate now 100.8 KHz decrease by 2 at 100.8 KHz (all non-zero) throw away 1/2 to get 50.4 KHz increase by 7 to get 352.8 KHz. reduce by 2 at 352.8 KHz (6/7 non-zero) throw away 1/2 to get 176.4 KHz. reduce by two at 176.4 (all non-zero) throw away 1/2 reduce by two at 88.2 (all non-zero) throw away 1/2 to get 44.1 These remaining filters are simpler, as you pointed out, but I am sure you cannot do them all for less than 30 multiplies/output sample. Thus if you implement the filters by multiply/adds, this takes more operations, plus the book-keeping is *much* more complex. The direct approach is a one or two instruction loop on most DSP chips, for 100 or 200 cycles per output point. I doubt you can do the bookkeeping alone in less than 100 cycles per output point for the method above. However, maybe you can do some of the reduction filters with so few coefficients that you can do adds and shifts instead of multiply/adds. In this case the cascaded scheme might be an overall improvement if multiplies are expensive. These filters will not be very flat, but this can be compensated for by the first filter, which must be a multiply/add variety anyway, and can be tuned up to have an arbitrary frequency response at almost no additional cost. Another advantage is that you do not need to store 14000 coefficients. 200 will probably do. In short, the achilles heel of this scheme is the very first filter, which MUST have a sharp cutoff to prevent aliasing. This filter alone takes 0.7 of the work of the direct method, and the rest of the work/book-keeping will make the method worse in practice, except in special cases. -Lou Scheffer