DSPRelated.com
Forums

Change Sample Rate

Started by Chris Barrett July 11, 2007
How do I use the sinc function to change the sample rate of a signal?

I've been told that to change the sample rate of a signal I'm suppose to 
convolve it with the sinc function.  The problem with this is that the 
sinc function is not bounded in either direction.  It also appears that 
if I took a section of the sinc function, say from -3.14 to +3.14, and 
convolved it with a signal, that this would simply have the effect of 
filtering the signal.  In other words, it would not change the sample 
rate.
On Jul 11, 10:50 am, Chris Barrett
<"chrisbarret"@0123456789abcdefghijk113322.none> wrote:
> How do I use the sinc function to change the sample rate of a signal?
Use the sinc function as part of either a filtering process (for downsampling) or an interpolation process (for upsampling).
> I've been told that to change the sample rate of a signal I'm suppose to > convolve it with the sinc function. The problem with this is that the > sinc function is not bounded in either direction.
To create a finite length interpolation kernel, one traditional method is to window the sinc function.
> It also appears that > if I took a section of the sinc function, say from -3.14 to +3.14, and > convolved it with a signal, that this would simply have the effect of > filtering the signal.
A section produced by a rectangular window may not provide you with the quality of interpolation desired. Other possible windows you might want to examine are Hamming, von Hann, Kaiser or Gaussian windows.
> In other words, it would not change the sample > rate.
To change the sample rate, you have to pick points other than the original ones (either more densely or less densely spaced) from your interpolated result waveform or function. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Chris Barrett wrote:
> How do I use the sinc function to change the sample rate of a signal? > > I've been told that to change the sample rate of a signal I'm suppose to > convolve it with the sinc function. The problem with this is that the > sinc function is not bounded in either direction. It also appears that > if I took a section of the sinc function, say from -3.14 to +3.14, and > convolved it with a signal, that this would simply have the effect of > filtering the signal. In other words, it would not change the sample rate.
Convolving doesn't change the sample rate, but filtering the signal is a step in that process. If lowering the rate, you must first remove from the signal all components higher than half the new rate. If increasing the sample rate, you must afterward remove all components of the new signal not contained in the original. Both filtering operations are low-pass. Convolving with a truncated and windowed sinc is one way to do that. Jerry -- Engineering is the art of making what you want from things you can get. &macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
"Ron N." <rhnlogic@yahoo.com> wrote in news:1184179118.827676.8880
@g12g2000prg.googlegroups.com:

> or an interpolation process > (for upsampling). >
But there are much better interpolation algorithms -- Scott Reverse name to reply
On 11 Jul., 21:51, Scott Seidman wrote:
> Ron N.:
> > or an interpolation process > > (for upsampling). > > But there are much better interpolation algorithms
That depends on your metric for "better". Regards, Andor
Andor <andor.bariska@gmail.com> wrote in news:1184184374.241059.290760
@k79g2000hse.googlegroups.com:

> On 11 Jul., 21:51, Scott Seidman wrote: >> Ron N.: > >> > or an interpolation process >> > (for upsampling). >> >> But there are much better interpolation algorithms > > That depends on your metric for "better". > > Regards, > Andor > >
True enough-- all these things are relative, but sinc interpolation tends to ring much more than other interpolators. -- Scott Reverse name to reply
On 11 Jul., 22:12, Scott Seidman <namdiestt...@mindspring.com> wrote:
> Andor <andor.bari...@gmail.com> wrote in news:1184184374.241059.290760 > @k79g2000hse.googlegroups.com: > > > On 11 Jul., 21:51, Scott Seidman wrote: > >> Ron N.: > > >> > or an interpolation process > >> > (for upsampling). > > >> But there are much better interpolation algorithms > > > That depends on your metric for "better". > > > Regards, > > Andor > > True enough-- all these things are relative, but sinc interpolation tends > to ring much more than other interpolators.
What do you mean by "ring"?
Andor <andor.bariska@gmail.com> wrote in
news:1184185235.143443.128360@22g2000hsm.googlegroups.com: 

> On 11 Jul., 22:12, Scott Seidman <namdiestt...@mindspring.com> wrote: >> Andor <andor.bari...@gmail.com> wrote in >> news:1184184374.241059.290760 @k79g2000hse.googlegroups.com: >> >> > On 11 Jul., 21:51, Scott Seidman wrote: >> >> Ron N.: >> >> >> > or an interpolation process >> >> > (for upsampling). >> >> >> But there are much better interpolation algorithms >> >> > That depends on your metric for "better". >> >> > Regards, >> > Andor >> >> True enough-- all these things are relative, but sinc interpolation >> tends to ring much more than other interpolators. > > What do you mean by "ring"? > >
Using sincresample from the Matlab File Exchange:
>> x=[1:64]/64; >> x2=[4:259]/256; >> y=sin(2*pi*3*x); >> y2=sin(2*pi*3*x2); >> outsinc=sincresample(y',4*length(y)); >> outinterp=interp(y,4); >> plot(x2,[outsinc(:)-y2' outinterp(:)-y2'])
I'm less concerned about the monster ringing at the endpoints than the mid-record stuff that's about 4 times bigger than "interp" -- Scott Reverse name to reply
On Jul 11, 2:04 pm, Scott Seidman <namdiestt...@mindspring.com> wrote:
> Andor <andor.bari...@gmail.com> wrote innews:1184185235.143443.128360@22g2000hsm.googlegroups.com: > > > > > On 11 Jul., 22:12, Scott Seidman <namdiestt...@mindspring.com> wrote: > >> Andor <andor.bari...@gmail.com> wrote in > >> news:1184184374.241059.290760 @k79g2000hse.googlegroups.com: > > >> > On 11 Jul., 21:51, Scott Seidman wrote: > >> >> Ron N.: > > >> >> > or an interpolation process > >> >> > (for upsampling). > > >> >> But there are much better interpolation algorithms > > >> > That depends on your metric for "better". > > >> > Regards, > >> > Andor > > >> True enough-- all these things are relative, but sinc interpolation > >> tends to ring much more than other interpolators. > > > What do you mean by "ring"? > > Using sincresample from the Matlab File Exchange: > > >> x=[1:64]/64; > >> x2=[4:259]/256; > >> y=sin(2*pi*3*x); > >> y2=sin(2*pi*3*x2); > >> outsinc=sincresample(y',4*length(y)); > >> outinterp=interp(y,4); > >> plot(x2,[outsinc(:)-y2' outinterp(:)-y2']) > > I'm less concerned about the monster ringing at the endpoints than the > mid-record stuff that's about 4 times bigger than "interp"
What you are seeing is the result of your sharp rectangular window from 1:64. The full ft of your rect chopped interp result will actually have more high frequency alias content then the "ringy" looking sincresample result. Try your same experiment with a Gaussian windowed and bandlimited square wave source (instead of a rectangular windowed sin wave source) and see which interpolation method produces the "closer" result. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M
Scott Seidman wrote:

> "Ron N." <rhnlogic@yahoo.com> wrote in news:1184179118.827676.8880 > @g12g2000prg.googlegroups.com: > >> or an interpolation process >> (for upsampling). >> > > But there are much better interpolation algorithms
Sorry, you didn't leave enough context. Better than what? And which algorithms? Erik -- ----------------------------------------------------------------- Erik de Castro Lopo ----------------------------------------------------------------- Diana West for President of the United States http://www.washtimes.com/op-ed/20060817-091447-7758r.htm http://www.washtimes.com/op-ed/20060824-084015-5082r.htm