Forums

Sampling rate conversion

Started by Praveen November 7, 2005
Hello,

I am designing a sample rate converter from 8khz to 8.4 khz, which
gives an upsampling rate of 21 and downsampling rate of 20.  I am
implementing it using polyphase filters.  I have got a filter with
cut-off frequency of 21.  This means I have 21 filters each of them
shifted and upsampled by 21.  And finally I cascade the output and
downsample by 20.  is this the right way of doing it?

Rgds,
Praveen

in article 1131404946.150489.69130@g49g2000cwa.googlegroups.com, Praveen at
praveen.gk@gmail.com wrote on 11/07/2005 18:09:

> I am designing a sample rate converter from 8khz to 8.4 khz, which > gives an upsampling rate of 21 and downsampling rate of 20.
that's what you are *hypothetically* doing.
> I am implementing it using polyphase filters. I have got a filter with > cut-off frequency of 21.
perhaps you mean a cutoff frequency of pi/21 or Nyquist/21, no?
> This means I have 21 filters each of them shifted and upsampled by 21. And > finally I cascade the output and downsample by 20. is this the right way of > doing it?
no sure, but what you are doing for each output sample is advancing time (relative to the original sample rate) by 20/21 samples for each output sample. to get the 21 intermediate samples, you have 21 slightly different polyphase filters (FIR) and you select one of them, compute your output, and then skip 20/21 of a sample ahead. that fractional expression of time has an integer part that you use to select which samples are going into your polyphase FIR filter and the fractional part is used to combine those samples to give you the correct sub-sample delay. i periodically repost a little treatise of exactly how this is done in the context of the original Sampling (and reconstruction) Theorem. http://groups.google.com/group/comp.dsp/msg/f9e0ad7b430bc653?fwc=1 it might be more anal than you would like. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Praveen wrote:
> Hello, > > I am designing a sample rate converter from 8khz to 8.4 khz, which > gives an upsampling rate of 21 and downsampling rate of 20. I am > implementing it using polyphase filters. I have got a filter with > cut-off frequency of 21. This means I have 21 filters each of them > shifted and upsampled by 21.
21 what?
> And finally I cascade the output and > downsample by 20. is this the right way of doing it?
Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Oops...That was pi/21.....slip of the keyboard:-)
Is the method that I am doing right?

I am not sure whether we have to upsample the filter co-efficients by a
factor of 21.  Please help me out in this!!!

in article 1131419382.866958.263800@g14g2000cwa.googlegroups.com, Praveen at
praveen.gk@gmail.com wrote on 11/07/2005 22:09:

> Oops...That was pi/21.....slip of the keyboard:-) > Is the method that I am doing right? > > I am not sure whether we have to upsample the filter co-efficients by a > factor of 21. Please help me out in this!!!
no, if the normalized angular frequency of the cutoff is pi/21, then it is already a filter with cutoff at pi that is upsampled by a factor of 21. now you have to rearrange or resort the coefficients into 21 different FIR filters, all with a slightly different delay. that's simple. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
"robert bristow-johnson" <rbj@audioimagination.com> wrote in message 
news:BF95A765.BFCB%rbj@audioimagination.com...
> in article 1131419382.866958.263800@g14g2000cwa.googlegroups.com, Praveen at > praveen.gk@gmail.com wrote on 11/07/2005 22:09: > >> Oops...That was pi/21.....slip of the keyboard:-) >> Is the method that I am doing right? >> >> I am not sure whether we have to upsample the filter co-efficients by a >> factor of 21. Please help me out in this!!! > > no, if the normalized angular frequency of the cutoff is pi/21, then it is > already a filter with cutoff at pi that is upsampled by a factor of 21. now > you have to rearrange or resort the coefficients into 21 different FIR > filters, all with a slightly different delay. that's simple.
You can look at it two ways. For me, I like to think of it as a LP filter with cut-off of pi (or slightly less), upsampled by the number of phases, 21 in this case. That is of course equivalent to a LP filter with a cut-off of pi/21, but the former way makes more sense to me since it allows for different numbers of phases without changing the filter's cut-off frequency. But rb-j is definitely correct in that if your filter is already set to pi/21, then you don't need to additionally upsample by 21. -- Jon Harris SPAM blocker in place: Remove 99 (but leave 7) to reply
Thanks a lot....What you said is right...I dont have to upsample the
co-efficients again by 21....Ok What do I have to do if i have to do
the reverse...If i am downsampling first and then upsampling...How does
this work now?

in article 1131590826.735158.149860@g44g2000cwa.googlegroups.com, Praveen at
praveen.gk@gmail.com wrote on 11/09/2005 21:47:

> Thanks a lot....What you said is right...I dont have to upsample the > co-efficients again by 21....Ok What do I have to do if i have to do > the reverse...If i am downsampling first and then upsampling...How does > this work now?
you don't want to destroy information before expanding it. you do not want to down sample (say by a factor of 20) before upsampling (by 21). please read what i posted in http://groups.google.com/group/comp.dsp/msg/f9e0ad7b430bc653?fwc=1 you *conceptually* or *hypothetically* upsample by 21, then by pick one upsampled sample and skipping over 19 of the upsampled samples (which you actually don't have to waste MIPs computing them, since you're skipping over them and not using them), you effective downsample by a factor of 20. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
"Praveen" <praveen.gk@gmail.com> wrote in message
news:1131590826.735158.149860@g44g2000cwa.googlegroups.com...
> Thanks a lot....What you said is right...I dont have to upsample the > co-efficients again by 21....Ok What do I have to do if i have to do > the reverse...If i am downsampling first and then upsampling...How does > this work now?
When you consider the upsampling and downsampling as discrete blocks, you'll always want to follow the upsample-filter-downsample order. Reversing this isn't going to work - you'll have all kinds of images aliasing into your band of interest. In a polyphase implementation, the upsample and downsample steps are rolled together - can't really separate them (well the whole point of a polphase implementation is to bring them together). So your question wouldn't make sense in this case. Cheers Bhaskar
Thats a lot of help...Thanks