DSPRelated.com
Forums

Windowed sinc

Started by Vladimir Vassilevsky September 2, 2010
On Sep 3, 1:21�pm, spop...@speedymail.org (Steve Pope) wrote:
> robert bristow-johnson &#4294967295;<r...@audioimagination.com> wrote: > > >but i wouldn't do it that way. &#4294967295;i would always insist on an even > >number of coefficients and the breakpoints would be at the sample > >times. &#4294967295;then it is also conceptually simple; for the continuous-time > >index, the integer part solely determines what set of samples are to > >be used for the interpolation, and the fractional part solely > >determines how that set of samples shall be combined (what the > >coefficients are) to yield an interpolated result. > >and i would always insist upon time-reverse invariability. &#4294967295;for an > >even number of coefficients, that means an equal number on the left > >and right of the interpolated point. &#4294967295;for an odd number, that means > >one more sample to the left if the fractional part of the time index > >is between 0 and 1/2 or one more sample to the right if the fractional > >part of the time index is between 1/2 and 1. > > The mathematical convention is a little different. &#4294967295;If you're > interpolating from an odd number of sample points, the result is > defined for an abscissa between -1 and +1;
i think it's between -1/2 and +1/2. we don't need overlapping segments. with this odd number of coefficients (let's call that number "N"), you might have to add 1/2 before conceptually applying the floor() function, but it's the same thing, the integer part of the precision time (or abscissa) defines which N samples to use and the fractional part defines the set of coefficients used to combine them. it should be well defined which precludes overlapping segments.
> whereas if you're interpolating > from an even number of sample points, the result is defined for an abscissa > between 0 and +1.
agreed.
> &#4294967295;Thus it both remains symmetrical, and you do > not have sample points "falling off" when the abscissa goes > through a fractional value.
well, sorta you do. let's say that N=7 (an odd number). if you're interpolating at some precision time between n-1/2 and n+1/2, then the samples x[n-3], x[n-2], ... x[n+3] are used. when t crosses from just below n+1/2 to just above it, then x[n-3] falls off the edge on the left and x[n+4] slides into the picture from the right. but then, instead of saying that you're just above n+1/2, you should increment n by 1 and say you're just above n-1/2 and it's the same thing as before. in both the N even or N odd cases, the interpolation kernel (the windowed sinc function) goes to zero at +/- N/2. the difference between N=even and N=odd cases is that the latter is midway between samples, which makes one sample "disappear" (have coefficient that goes to zero) while other samples do not. in the N=even case, all samples (other than the obvious one) have coefficients approaching zero only as you approach an integer sample time.
robert bristow-johnson  <rbj@audioimagination.com> wrote:

>On Sep 3, 1:21&#4294967295;pm, spop...@speedymail.org (Steve Pope) wrote:
>> robert bristow-johnson &#4294967295;<r...@audioimagination.com> wrote:
>> >but i wouldn't do it that way. &#4294967295;i would always insist on an even >> >number of coefficients and the breakpoints would be at the sample >> >times. &#4294967295;then it is also conceptually simple; for the continuous-time >> >index, the integer part solely determines what set of samples are to >> >be used for the interpolation, and the fractional part solely >> >determines how that set of samples shall be combined (what the >> >coefficients are) to yield an interpolated result. >> >and i would always insist upon time-reverse invariability. &#4294967295;for an >> >even number of coefficients, that means an equal number on the left >> >and right of the interpolated point. &#4294967295;for an odd number, that means >> >one more sample to the left if the fractional part of the time index >> >is between 0 and 1/2 or one more sample to the right if the fractional >> >part of the time index is between 1/2 and 1.
>> The mathematical convention is a little different. &#4294967295;If you're >> interpolating from an odd number of sample points, the result is >> defined for an abscissa between -1 and +1;
>i think it's between -1/2 and +1/2. we don't need overlapping >segments.
I agree that is more logical. Since I wrote the above, I look up the section on Lagrange interpolators in my copy of Abramowitz and Stegun, and it's even stranger than I thought -- they actually define interpolators for almost any abscissa. e.g. if the sample points are at -2, -1, 0, 1 and 2, you can still compute an interpolation value for an abscissa of -1.8 -- why you would want to, not sure, but the formula is there.
>with this odd number of coefficients (let's call that number "N"), you >might have to add 1/2 before conceptually applying the floor() >function, but it's the same thing, the integer part of the precision >time (or abscissa) defines which N samples to use and the fractional >part defines the set of coefficients used to combine them. it should >be well defined which precludes overlapping segments.
I was thinking that an odd interpolator could give you values for the interval from -1 to +1, and then you'd hop forward by two, so there is no overlap.
>> whereas if you're interpolating >> from an even number of sample points, the result is defined for an abscissa >> between 0 and +1. > >agreed. > >> &#4294967295;Thus it both remains symmetrical, and you do >> not have sample points "falling off" when the abscissa goes >> through a fractional value.
>well, sorta you do.
>let's say that N=7 (an odd number). if you're interpolating at some >precision time between n-1/2 and n+1/2, then the samples x[n-3], >x[n-2], ... x[n+3] are used. when t crosses from just below n+1/2 to >just above it, then x[n-3] falls off the edge on the left and x[n+4] >slides into the picture from the right. but then, instead of saying >that you're just above n+1/2, you should increment n by 1 and say >you're just above n-1/2 and it's the same thing as before.
>in both the N even or N odd cases, the interpolation kernel (the >windowed sinc function) goes to zero at +/- N/2. the difference >between N=even and N=odd cases is that the latter is midway between >samples, which makes one sample "disappear" (have coefficient that >goes to zero) while other samples do not. in the N=even case, all >samples (other than the obvious one) have coefficients approaching >zero only as you approach an integer sample time.
Yes, thanks. The behavior you just described is there in the Lagrange formulae in Abramowitz and Stegun. (Which I just checked on Alibris, there are plenty of copies of this tome available for not too much.) Steve
On Sep 3, 10:08&#4294967295;pm, spop...@speedymail.org (Steve Pope) wrote:
> ... > > Yes, thanks. &#4294967295;The behavior you just described is there in the > Lagrange formulae in Abramowitz and Stegun. &#4294967295;(Which I just checked > on Alibris, there are plenty of copies of this tome available > for not too much.) > > Steve
You can download A&S for free. Dale B. Dalrymple
On Fri, 03 Sep 2010 23:30:26 -0500, Vladimir Vassilevsky
<nospam@nowhere.com> wrote:

> > >Eric Jacobsen wrote: >> On Fri, 03 Sep 2010 17:24:08 -0500, Vladimir Vassilevsky >> <nospam@nowhere.com> wrote: >> >> >>> >>>Eric Jacobsen wrote: >>> >>> >>> >>>>A highly oversampled polyphase FIR filter that potentially >>>>interpolates N phases between input samples works just fine as long as >>>>the aggregate FIR impulse response is constructed properly. In other >>>>words, if the aggregate Nx oversamples coefficient set is symmetric >>>>and well behaved, then all of the asymmetric subfilters will have the >>>>same response. >>> >>>This is not so. >> >> >> It is, for a fixed decimation rate and only shifting of the phases. >> i.e., don't compare across decimation rates, which is not something >> you mentioned before. >> >> Try it and see. >> >>>The responses of the subfilters are going to be quite different from >>>each other and much worse then that of the original filter. Several >>>people from this NG run into exactly this problem. The rule of thumb is >>>if you are designing a prototype filter which is going to be decimated >>>by a factor of N, the passband flatness and stopband attenuation >>>requirements to this filter should be increased by N times. >> >> >> You've added a new constraint of constancy over decimation rate, when >> you hand't even said it was a decimating filter previously. As I >> mentioned, for the case of only changing the sampling phase, which is >> what your original question was about, it doesn't matter. > >I just corrected your assertions. > >>>>You can try this yourself and see. >>>Try this for yourself and see. > >http://www.abvolt.com/misc/filters_comparison.xls
I've no way to tell what the columns and comparisons are in that spreadsheet. They seem to show the same passband response for all cases, though.
>Surprisingly, Kaiser-Bessel windowed sinc showed more variation between >subfilters then Parks-Mcclellan design. > >> I have many times, and as I've mentioned before in other threads, for >> a comm system where you can quantifiably measure performance within >> about 0.1dB or so, it does not matter. > >The O.1dB could be terrible for some other cases, as this corresponds to >the mismatch error of ~ 1%.
I don't know about every application, but in systems I've worked on 0.1dB difference in performance qualifies as essentially indistinguishable.
>> Been there, done that, have thousands of products in the field to >> prove it. > >Sure. That's a solid argument revealing the confidence. > >>>>So I don't think >>>>it matters much and it makes the argument that the window be centered >>>>over the center of the IPR peak for a symmetric sinc. >>> >>>It does matter, especially for the small filter lengths. >> >> It'd be much easier to help you if you stated your pertinent >> constraints up front rather than change the target later. > >Design is done already. I just corrected your assertions. > >> You're extremely harsh on other people who do that. Should I call >> you a name? > >Yes, please, call a name and tell me what to do. > >>>>Arbitrarily lopping off a sample on either end of the window to make >>>>it fit takes the original window function and multiplies it by a >>>>length N-1 rectangular window. The IPR main lobe will spread and the >>>>sidelobes will come up as a result. >>>> >>>>As previously mentioned, this sort of thing is easily demonstrated in >>>>simulation without a ton of effort. >>> >>>The actual problem is a bit more involved: I need to minimize the >>>difference between interpolator responses computed to the arbitrary time >>>shift. > >> Which is exactly the case I'm describing, i.e., a polyphase FIR >> resampling filter that can adjust output sample timing phase by >> selecting a coefficient subset on the fly. If the decimation rate >> is constant, the filter response across the possible filter subsets is >> not distinguishable (in BER) down to about 0.1dB (or more, I've just >> not been able to measure more finely) in the many systems I've built >> and verified this way. > >The 0.1 dB not very close to Nyqust is simple...
If you need the stopbands to be identical, I'll assert that's an unusual application. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.abineau.com
On 9/2/2010 9:08 PM, robert bristow-johnson wrote:
> On Sep 2, 10:55 pm, Vladimir Vassilevsky<nos...@nowhere.com> wrote: >> When making a filter for a time domain interpolation of a signal using >> a windowed sinc kernel, what should be the right way of aligning the >> window towards sinc? >> >> I can think of three possibilities: >> >> 1) The center of the window could be set at 0. >> 2) The center of the window could be set to the value of the time >> domain shift of the interpolator. >> 3) The center if the window could be aligned to the "center of mass" >> of the set of sinc coefficients. >> >> What is the best option ? > > i'm sorta with Fred. > > Vlad, is it reasonable to expect that interpolating the time-reversed > signal should result in the same as what you get when interpolating > the original signal, except time reversed? > > i don't get why any interpolation wouldn't be symmetrical and constant > delay (w.r.t. frequency), unless maybe you wanted less delay for some > frequencies. but i don't really get the unsymmetrical interpolater > response. > > r b-j
I'm still confused. So, I read Vlad's post of 9/2/9:18pm. It appears that this isn't a matter of interpolating in a streaming sense. OK - that helps. So, we have a fixed sequence and we want to interpolate it, right? It seems still that a lot of confusion has to do with the actual operations needed and what a "windowed sinc" really means. It could mean: - a tapered sinc or, as the usual context: - a gate function (whose FT is s sinc) that is *windowed* .. resulting in a generally faster-decaying and slightly fatter main lobe sinc-like function. It's the sinc-like function that is the kernel for the interpolating convolution step. Do we agree? Now, what if one does this: Start with a continuous sinc centered at zero but with finite length. [The FT of this is a gate convolved with a sinc because of the finite temporal length.] So, we can say that there's a rectangular window in time and that there is a semi-rectangular window in frequency plus the effects of convolving in freq with that short sinc. The idea is that this sinc is going to be used to convolve in time in order to interpolate (in this case "reconstruct" but we can sample the sinc later...). Interpolation is a matter of increasing the sample rate if we're going to keep things discrete. So, we want to start out by adding zero-valued samples where we want the interpolated samples to appear. This takes care of increasing the sample rate. Next, we want to remove all the frequency content around the *new* fs/2. So that looks like a lowpass filter. The lowpass filter looks something like a sinc in time. So, multiply in freq or convolve in time is just a choice we make. If we want to avoid things like Gibbs phenomenon in time then we change the shape of the lowpass filter in frequency with a "window function" which, in turn, changes the nature of the sinc in time that we'll use for interpolating. There are bunches of decent discrete interpolators: [0.5 1.0 0.5] which is sampled at 2fs, keeps the original samples intact and puts an interpolated sample which is the mean of the two adjacent samples (i.e. straight line interpolation). Anyway, are you raising the question: "What happens if you take a finite sinc and multipy it by a window function?" In that case, the lowpass filter is convolved with the FT of the window function. And, doing that seems a bit unusual to me and I've not pondered that question - at least not knowingly.... I believe the original question was about where/how to apply the "window". But, as you can see, I'm unclear as to which domain the window would be applied. In any case I don't see that it matters because, in the end, one is going to do the equivalent of a time domain convolution and the kernel of that convolution applies for all values of time - it isn't "centered" anywhere in that context. Well, unless one is determined to maintain temporal registration. In that case, an in all the things I've mentioned above, then it's best to use a symmetrical kernel and the temporal registration is with the center of it. That is, if the window is in time (unusual case) then it should be centered at the center of the underlying sinc. If the window function is in frequency then it should begin and end at the band edges of the LPF (-fc to +fc). And it has nothing to do with the data except for matching up sample rates. I hope this helps.... ? Fred
On Sep 4, 1:08&#4294967295;am, spop...@speedymail.org (Steve Pope) wrote:
> robert bristow-johnson &#4294967295;<r...@audioimagination.com> wrote: > > > > > > >On Sep 3, 1:21&#4294967295;pm, spop...@speedymail.org (Steve Pope) wrote: > >> robert bristow-johnson &#4294967295;<r...@audioimagination.com> wrote: > >> >but i wouldn't do it that way. &#4294967295;i would always insist on an even > >> >number of coefficients and the breakpoints would be at the sample > >> >times. &#4294967295;then it is also conceptually simple; for the continuous-time > >> >index, the integer part solely determines what set of samples are to > >> >be used for the interpolation, and the fractional part solely > >> >determines how that set of samples shall be combined (what the > >> >coefficients are) to yield an interpolated result. > >> >and i would always insist upon time-reverse invariability. &#4294967295;for an > >> >even number of coefficients, that means an equal number on the left > >> >and right of the interpolated point. &#4294967295;for an odd number, that means > >> >one more sample to the left if the fractional part of the time index > >> >is between 0 and 1/2 or one more sample to the right if the fractional > >> >part of the time index is between 1/2 and 1. > >> The mathematical convention is a little different. &#4294967295;If you're > >> interpolating from an odd number of sample points, the result is > >> defined for an abscissa between -1 and +1; > >i think it's between -1/2 and +1/2. &#4294967295;we don't need overlapping > >segments. > > I agree that is more logical. > > Since I wrote the above, I look up the section on Lagrange > interpolators in my copy of Abramowitz and Stegun, and it's > even stranger than I thought -- they actually define interpolators > for almost any abscissa. &#4294967295;e.g. if the sample points are at > -2, -1, 0, 1 and 2, you can still compute an interpolation value > for an abscissa of -1.8 -- why you would want to, not sure, but > the formula is there. > > >with this odd number of coefficients (let's call that number "N"), you > >might have to add 1/2 before conceptually applying the floor() > >function, but it's the same thing, the integer part of the precision > >time (or abscissa) defines which N samples to use and the fractional > >part defines the set of coefficients used to combine them. &#4294967295;it should > >be well defined which precludes overlapping segments. > > I was thinking that an odd interpolator could give you values > for the interval from -1 to +1, and then you'd hop forward by > two, so there is no overlap. > > > > > > >> whereas if you're interpolating > >> from an even number of sample points, the result is defined for an abscissa > >> between 0 and +1. > > >agreed. > > >> &#4294967295;Thus it both remains symmetrical, and you do > >> not have sample points "falling off" when the abscissa goes > >> through a fractional value. > >well, sorta you do. > >let's say that N=7 (an odd number). &#4294967295;if you're interpolating at some > >precision time between n-1/2 and n+1/2, then the samples x[n-3], > >x[n-2], ... x[n+3] &#4294967295;are used. &#4294967295;when t crosses from just below n+1/2 to > >just above it, then x[n-3] falls off the edge on the left and x[n+4] > >slides into the picture from the right. &#4294967295;but then, instead of saying > >that you're just above n+1/2, you should increment n by 1 and say > >you're just above n-1/2 and it's the same thing as before. > >in both the N even or N odd cases, the interpolation kernel (the > >windowed sinc function) goes to zero at +/- N/2. &#4294967295;the difference > >between N=even and N=odd cases is that the latter is midway between > >samples, which makes one sample "disappear" (have coefficient that > >goes to zero) while other samples do not. &#4294967295;in the N=even case, all > >samples (other than the obvious one) have coefficients approaching > >zero only as you approach an integer sample time. > > Yes, thanks. &#4294967295;The behavior you just described is there in the > Lagrange formulae in Abramowitz and Stegun. &#4294967295;(Which I just checked > on Alibris, there are plenty of copies of this tome available > for not too much.) > > Steve- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text -
In fact if you take the Lagrange formula and look at it in the limit of a very high order polynomial and equally spaced samples, then each of the cononical products in the Lagrange formula becomes a form of sin(x)/x. Being able to let your abscissa be any value such as 1/8 allows you resample the signal at a different phase. Imagine doing delay equalization and you need to delay a signal by 0,03 samples. You wil need some sort of interpolator to do this. Commonly done is desig a polyphase filter and then decimate the resulting impulse response. But there are lot's of ways to do this. You may even apply a simple Taylor's or MacLauren series to do the trick. E.g., y(x+dx) = y(x) + dx*y'(x) + (dx^2)*y''(x)/2 +... Clay

Clay wrote:

> In fact if you take the Lagrange formula and look at it in the limit > of a very high order polynomial and equally spaced samples, then each > of the cononical products in the Lagrange formula becomes a form of > sin(x)/x. Being able to let your abscissa be any value such as 1/8 > allows you resample the signal at a different phase. Imagine doing > delay equalization and you need to delay a signal by 0,03 samples. You > wil need some sort of interpolator to do this. Commonly done is desig > a polyphase filter and then decimate the resulting impulse response.
This requires care as the practical decimated sets of the original filter of finite length are somewhat different in the amplitude and the phase response.
> But there are lot's of ways to do this. You may even apply a simple > Taylor's or MacLauren series to do the trick. E.g., > > y(x+dx) = y(x) + dx*y'(x) + (dx^2)*y''(x)/2 +...
The derivatives for the Taylor formula could be calculated directly, by means of FIR differentiators. This approach is commonly referred as Farrow interpolation. It would be interesting to see the comparison of accuracy vs computing needs for the optimized implementations of direct interpolation vs Farrow's. Vladimir Vassilevsky DSP and Mixed Signal Design Consultant http://www.abvolt.com
On Sep 3, 9:30 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> ...
> > I just corrected your assertions.
> >>>You can try this yourself and see. > >>Try this for yourself and see. >
.> http://www.abvolt.com/misc/filters_comparison.xls
> > Surprisingly, Kaiser-Bessel windowed sinc showed more variation between > subfilters then Parks-Mcclellan design. > ...
> VLV
Looking at some examples from your spreadsheet: Remez line:73, level:1dB, range:0.33dB line:122, level:2dB, range:0.07dB line:268, level:-6dB, range:0.06dB K-B line:73, level:0.00xdB, range:0.0038dB line:122, level:-.02dB, range:0.0011dB line:268, level:-.37dB, range:0.01dB The K-B have greater relative range (they twiddle more least significant digits in the floating point format), but smaller values that lead to smaller absolute range. Your spreadsheet data shows less variation in K-B than in Remez by a factor of 5 or more. Your example is an interesting one. The filter transition band is so wide and the passband tolerance so great that even the prototype response has no region with multiple equal ripples. The individual phases have enough coefficients to define the extrema in the response. They perform quite well. In the cases I usually encounter, the application involves decimation and the filter has large regions with equal ripple behavior and it can be difficult to find any phase from a Remez prototype that meets the filter spec. Dale B. Dalrymple
On Sun, 5 Sep 2010 11:04:20 -0700 (PDT), dbd <dbd@ieee.org> wrote:

>On Sep 3, 9:30 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >> ... > >> >> I just corrected your assertions. > >> >>>You can try this yourself and see. >> >>Try this for yourself and see. >> >.> http://www.abvolt.com/misc/filters_comparison.xls >> >> Surprisingly, Kaiser-Bessel windowed sinc showed more variation between >> subfilters then Parks-Mcclellan design. >> ... > >> VLV > >Looking at some examples from your spreadsheet: >Remez >line:73, level:1dB, range:0.33dB >line:122, level:2dB, range:0.07dB >line:268, level:-6dB, range:0.06dB >K-B >line:73, level:0.00xdB, range:0.0038dB >line:122, level:-.02dB, range:0.0011dB >line:268, level:-.37dB, range:0.01dB > >The K-B have greater relative range (they twiddle more least >significant digits in the floating point format), but smaller values >that lead to smaller absolute range. Your spreadsheet data shows less >variation in K-B than in Remez by a factor of 5 or more. > >Your example is an interesting one. The filter transition band is so >wide and the passband tolerance so great that even the prototype >response has no region with multiple equal ripples. The individual >phases have enough coefficients to define the extrema in the response. >They perform quite well. In the cases I usually encounter, the >application involves decimation and the filter has large regions with >equal ripple behavior and it can be difficult to find any phase from a >Remez prototype that meets the filter spec. > >Dale B. Dalrymple
How tight of a spec are you trying to meet? As mentioned, in my case the main metric is BER for a matched filter in a receiver, which is easily quantifiable and a good measure (in AWGN) of how well the filters match at the sample points. I've always used P-M (with Remez) to design these filters, and haven't found a case yet where the subfilters had difference performance than the aggregate prototype filter. And, like your case, sometimes the decimation rate is high. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.abineau.com
On Sep 5, 11:42 am, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> Clay wrote: > > In fact if you take the Lagrange formula and look at it in the limit > > of a very high order polynomial and equally spaced samples, then each > > of the cononical products in the Lagrange formula becomes a form of > > sin(x)/x. Being able to let your abscissa be any value such as 1/8 > > allows you resample the signal at a different phase. Imagine doing > > delay equalization and you need to delay a signal by 0,03 samples. You > > wil need some sort of interpolator to do this. Commonly done is desig > > a polyphase filter and then decimate the resulting impulse response. > > This requires care as the practical decimated sets of the original > filter of finite length are somewhat different in the amplitude and the > phase response. > > > But there are lot's of ways to do this. You may even apply a simple > > Taylor's or MacLauren series to do the trick. E.g., > > > y(x+dx) = y(x) + dx*y'(x) + (dx^2)*y''(x)/2 +... > > The derivatives for the Taylor formula could be calculated directly, by > means of FIR differentiators. This approach is commonly referred as > Farrow interpolation. It would be interesting to see the comparison of > accuracy vs computing needs for the optimized implementations of direct > interpolation vs Farrow's.
can someone explain to me essentially what good is the Farrow structure? as best as i can tell, it appears pretty expensive. you need to maintain N FIR filters simultaneously and "mix" the outputs of those filters according to the fractional delay parameter. what happens if the fractional delay advances past a sample boundary (goes from 0.99 to 1.02 sample)? then, it seems that all of the FIR filters must be offset by one sample and 1 is subtracted from that fractional delay so that it stays in between 0 and 1. but, whatever the number of taps on the polyphase FIR, if you have a time-varying delay, why not just use the integer part to select which N adjacent samples and the fractional part to select the N coefficients for combining those N samples. that's it. you have to increment the precision time to whatever its value is, separate the integer and fractional part, use the integer part to point to your N samples and use the fractional part (scaled to be an offest) to point to the N coefficients. then do N MAC instructions. how is Farrow better or more efficient than that? r b-j