DSPRelated.com
Forums

What if the downsampling factor is not an integer?

Started by DigitalGeek January 23, 2015
I have developed a function which down samples an input signal.Say I have
an input signal with a sampling rate of 512 samples/sec and would like to
down sample it 128 samples/sec, then the down sampling factor is discrete
and it is 4. In this case, I believe that the input signal will
successfully be down sampled to 128 samples/sec without any loss of
information.But, what if we have to down sample a signal from a sampling
rate of 511 samples/sec to 127 samples/sec,then the down sampling factor
4.0236. When I run my code for a down sampling non integer factor, I still
get the output down sampled signal,but I am sure that, since I down sampled
the signal by an non-integer factor, the output may not be correct and
would have lost information.Any methods to overcome this issue or Is there
a way to approximate it without damaging the quality of the down sampled
signal? 

	 

_____________________________		
Posted through www.DSPRelated.com
>I have developed a function which down samples an input signal.Say I have >an input signal with a sampling rate of 512 samples/sec and would like to >down sample it 128 samples/sec, then the down sampling factor is discrete >and it is 4. In this case, I believe that the input signal will >successfully be down sampled to 128 samples/sec without any loss of >information.But, what if we have to down sample a signal from a sampling >rate of 511 samples/sec to 127 samples/sec,then the down sampling factor >4.0236. When I run my code for a down sampling non integer factor, I
still
>get the output down sampled signal,but I am sure that, since I down
sampled
>the signal by an non-integer factor, the output may not be correct and >would have lost information.Any methods to overcome this issue or Is
there
>a way to approximate it without damaging the quality of the down sampled >signal? > > > >_____________________________ >Posted through www.DSPRelated.com >
See chapter 7, section 7.5 of Fred Harris' "Multirate Signal Processing for Communications Systems". All of the answers to your questions will be there. -Doug _____________________________ Posted through www.DSPRelated.com
On Fri, 23 Jan 2015 09:15:20 -0600, "DigitalGeek" <103355@dsprelated>
wrote:

>I have developed a function which down samples an input signal.Say I have >an input signal with a sampling rate of 512 samples/sec and would like to >down sample it 128 samples/sec, then the down sampling factor is discrete >and it is 4. In this case, I believe that the input signal will >successfully be down sampled to 128 samples/sec without any loss of >information.But, what if we have to down sample a signal from a sampling >rate of 511 samples/sec to 127 samples/sec,then the down sampling factor >4.0236. When I run my code for a down sampling non integer factor, I still >get the output down sampled signal,but I am sure that, since I down sampled >the signal by an non-integer factor, the output may not be correct and >would have lost information.Any methods to overcome this issue or Is there >a way to approximate it without damaging the quality of the down sampled >signal?
Are you okay with the idea that you can upsampled a signal without distorting it? I.e., samples between existing samples can be interpolated "correctly" without adding distortion? If so, then decimating at a non-integer rate just involved interpolating sample points in between existing samples just like in the upsampling case. If done properly there is no loss of information and no distortion added. Search on multirate filtering, polyphase filtering, etc. Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
>On Fri, 23 Jan 2015 09:15:20 -0600, "DigitalGeek" <103355@dsprelated> >wrote: > >>I have developed a function which down samples an input signal.Say I
have
>>an input signal with a sampling rate of 512 samples/sec and would like
to
>>down sample it 128 samples/sec, then the down sampling factor is
discrete
>>and it is 4. In this case, I believe that the input signal will >>successfully be down sampled to 128 samples/sec without any loss of >>information.But, what if we have to down sample a signal from a sampling >>rate of 511 samples/sec to 127 samples/sec,then the down sampling factor >>4.0236. When I run my code for a down sampling non integer factor, I
still
>>get the output down sampled signal,but I am sure that, since I down
sampled
>>the signal by an non-integer factor, the output may not be correct and >>would have lost information.Any methods to overcome this issue or Is
there
>>a way to approximate it without damaging the quality of the down sampled >>signal? > >Are you okay with the idea that you can upsampled a signal without >distorting it? I.e., samples between existing samples can be >interpolated "correctly" without adding distortion? > >If so, then decimating at a non-integer rate just involved >interpolating sample points in between existing samples just like in >the upsampling case. If done properly there is no loss of >information and no distortion added. > >Search on multirate filtering, polyphase filtering, etc. > > >Eric Jacobsen >Anchor Hill Communications >http://www.anchorhill.com >
My Understanding after doing some reading based on your repelies - I found a method after a while of researching. In this case we have to initially up sample the input sampling rate followed by down sampling, known as "Multirate conversion". So here is my understanding, Input Sampling rate = 511 b/s and Desired output sampling rate = 127 b/s. So, 127*5 = 635 and 635 -511 = 124. Therefore, i need to up sample 511 b/s by a factor of L = 5 to get 635 and then down sample this 635 by a factor M = 124 to get the desired down sampled output of 127 b/s. What do you have to say?. Please correct me if its wrong or illogical.
>
_____________________________ Posted through www.DSPRelated.com
>>On Fri, 23 Jan 2015 09:15:20 -0600, "DigitalGeek" <103355@dsprelated> >>wrote: >> >>>I have developed a function which down samples an input signal.Say I >have >>>an input signal with a sampling rate of 512 samples/sec and would like >to >>>down sample it 128 samples/sec, then the down sampling factor is >discrete >>>and it is 4. In this case, I believe that the input signal will >>>successfully be down sampled to 128 samples/sec without any loss of >>>information.But, what if we have to down sample a signal from a
sampling
>>>rate of 511 samples/sec to 127 samples/sec,then the down sampling
factor
>>>4.0236. When I run my code for a down sampling non integer factor, I >still >>>get the output down sampled signal,but I am sure that, since I down >sampled >>>the signal by an non-integer factor, the output may not be correct and >>>would have lost information.Any methods to overcome this issue or Is >there >>>a way to approximate it without damaging the quality of the down
sampled
>>>signal? >> >>Are you okay with the idea that you can upsampled a signal without >>distorting it? I.e., samples between existing samples can be >>interpolated "correctly" without adding distortion? >> >>If so, then decimating at a non-integer rate just involved >>interpolating sample points in between existing samples just like in >>the upsampling case. If done properly there is no loss of >>information and no distortion added. >> >>Search on multirate filtering, polyphase filtering, etc. >> >> >>Eric Jacobsen >>Anchor Hill Communications >>http://www.anchorhill.com >> >My Understanding after doing some reading based on your repelies - I
found
>a method after a while of researching. In this case we have to initially
up
>sample the input sampling rate followed by down sampling, known as >"Multirate conversion". So here is my understanding, Input Sampling rate
=
>511 b/s and Desired output sampling rate = 127 b/s. So, 127*5 = 635 and
635
>-511 = 124. Therefore, i need to up sample 511 b/s by a factor of L = 5
to
>get 635 and then down sample this 635 by a factor M = 124 to get the >desired down sampled output of 127 b/s. What do you have to say?. Please >correct me if its wrong or illogical. >> > >_____________________________ >Posted through www.DSPRelated.com >
You could upsample by 127 and downsample by 511 and that gives you the precise ratio, but that is not the only source of distortion. The design of the filter also comes into play. Those figures - 127 and 511 will lead to a really awkward design, so is that really necessary? In most cases choosing an upsampling factor that is some power of 2 leads to a clean design - just choose a factor that brings distortion below your requirements as shown in Harris' book. -Doug _____________________________ Posted through www.DSPRelated.com
On Fri, 23 Jan 2015 13:06:22 -0600, DigitalGeek wrote:

>>On Fri, 23 Jan 2015 09:15:20 -0600, "DigitalGeek" <103355@dsprelated> >>wrote: >> >>>I have developed a function which down samples an input signal.Say I > have >>>an input signal with a sampling rate of 512 samples/sec and would like > to >>>down sample it 128 samples/sec, then the down sampling factor is > discrete >>>and it is 4. In this case, I believe that the input signal will >>>successfully be down sampled to 128 samples/sec without any loss of >>>information.But, what if we have to down sample a signal from a >>>sampling rate of 511 samples/sec to 127 samples/sec,then the down >>>sampling factor 4.0236. When I run my code for a down sampling non >>>integer factor, I > still >>>get the output down sampled signal,but I am sure that, since I down > sampled >>>the signal by an non-integer factor, the output may not be correct and >>>would have lost information.Any methods to overcome this issue or Is > there >>>a way to approximate it without damaging the quality of the down >>>sampled signal? >> >>Are you okay with the idea that you can upsampled a signal without >>distorting it? I.e., samples between existing samples can be >>interpolated "correctly" without adding distortion? >> >>If so, then decimating at a non-integer rate just involved interpolating >>sample points in between existing samples just like in the upsampling >>case. If done properly there is no loss of information and no >>distortion added. >> >>Search on multirate filtering, polyphase filtering, etc. >> >> >>Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com >> > My Understanding after doing some reading based on your repelies - I > found a method after a while of researching. In this case we have to > initially up sample the input sampling rate followed by down sampling, > known as "Multirate conversion". So here is my understanding, Input > Sampling rate = 511 b/s and Desired output sampling rate = 127 b/s. So, > 127*5 = 635 and 635 -511 = 124. Therefore, i need to up sample 511 b/s > by a factor of L = 5 to get 635 and then down sample this 635 by a > factor M = 124 to get the desired down sampled output of 127 b/s. What > do you have to say?. Please correct me if its wrong or illogical.
Well, it's wrong in an appalling way, and then wrong in a way that makes things not so bad. If you just naively upsample, filter, and downsample, then you have to upsample by your target frequency divided by the greatest common factor of your target and source frequencies. In this case, the greatest common factor of 511 and 127 is 1, so you need to upsample by a factor of 127, filter at that rate, then downsample by a factor of 511. That's the appalling part. The far-less-appalling part comes about when you think about what's actually happening in the downsampling. (Or if you read further). So, you upsample to an appalling rate of 64897 samples/second by inserting 126 zeros in between every actual sample, then you filter with a FIR filter that's some small integer (up to ten, maybe) times 127. Egad -- not only is your sampling rate huge, but so is your filter. But think -- then you _throw away_ 510 out of 511 samples. And many of your input samples were zero to start with, and didn't contribute to the answers. If you re-do the math to take into account all those inserted zeros, and to take into account (or maybe take out of the accounting) all of those discarded samples, then you find that you can compute each output sample using just a few of your input samples (it's that "some small integer" I mentioned a few paragraphs above). There's still a downside -- if you want to be perfectly accurate about it, you need 64897 different filters, and a whole lot of book-keeping to account for where you are in the sequence. But you're not storing more filter points than you would have in the appalling case, you're just using them in a way that saves a lot of calculation. You can do better than that, which is what DougB was alluding to. Instead of storing 64897 different filters, to exactly account for every possible phase difference between a Fs = 511 and a Fs = 127 signal, you can choose your worst-case phase difference, store that many filters, and always use the closest one. For example, if you are willing to allow a 1 degree phase difference for any given output sample, you can use just 180 filters, spaced two degrees apart. Then at each output sample, calculate the phase difference between output and input, and use the corresponding filter. HTH. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
Hi,

a Farrow resampler is one technical implementation for arbitrary
resampling.

Cutting some corners, I'd recommend you have a look at the Catmul-Rom
spline. It does a fairly good job at alias rejection. Often it "just
works".
Now that's not a very precise statement, but it'll turn into a 10 page
report if we look into details.

An alternative is Lagrange-based, mostly interesting if you need the
flattest possible passband response.

Code example for Catmull-Rom: 
http://www.dsprelated.com/showcode/3.php

For Lagrange:
http://www.dsprelated.com/showcode/208.php

Generally, this is worth reading.
http://yehar.com/blog/wp-content/uploads/2009/08/deip.pdf
Don't mind the pink elephant.
	 

_____________________________		
Posted through www.DSPRelated.com
On Fri, 23 Jan 2015 10:42:01 -0600, "DougB" <60916@dsprelated> wrote:
> >See chapter 7, section 7.5 of Fred Harris' "Multirate Signal Processing for >Communications Systems". All of the answers to your questions will be >there. > >-Doug
I have also been interested in this, so thanks for the recommendation. That's an expensive book though! Any idea how it differs from other books with "Multirate" in the title? Any reason why you mentioned this specific book, Doug? (BTW, I'm only interested in getting a general idea of what's going on, so more 'accessible' is better)
On 09.02.2015 12:14, Max wrote:
> I have also been interested in this, so thanks for the recommendation. > That's an expensive book though! Any idea how it differs from other > books with "Multirate" in the title? Any reason why you mentioned > this specific book, Doug? (BTW, I'm only interested in getting a > general idea of what's going on, so more 'accessible' is better)
I've purchased my copy from Lindabook, http://www.abebooks.co.uk/servlet/BookDetailsPL?bi=5192722935&tab=1 and although I'm in no way connected to that seller, I have really enjoyed the service. Evgeny.
On Mon, 09 Feb 2015 04:14:47 -0500, Max wrote:

> On Fri, 23 Jan 2015 10:42:01 -0600, "DougB" <60916@dsprelated> wrote: >> >>See chapter 7, section 7.5 of Fred Harris' "Multirate Signal Processing >>for Communications Systems". All of the answers to your questions will >>be there. >> >>-Doug > > I have also been interested in this, so thanks for the recommendation. > That's an expensive book though! Any idea how it differs from other > books with "Multirate" in the title? Any reason why you mentioned this > specific book, Doug? (BTW, I'm only interested in getting a general > idea of what's going on, so more 'accessible' is better)
As someone who just purchased a copy a month ago for a similar question (arbitrary rate upsampling), one differentiator is that it's quite good; I'd probably say better even than the out-of-print Crochiere and Rabiner book. Given that most textbooks of any kind are complete rubbish, any time you can get one that comes with recommendations it immediately jumps to the head of the queue. A guy with my limited set of math chops can make it through with a good understanding of multirate filter design and a distinct lack of having been mauled to death by wild dogs. Some of the choices in the order the material was presented in were interesting, but it's all presented well. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.