DSPRelated.com
Forums

Windowed sinc

Started by Vladimir Vassilevsky September 2, 2010
On 09/02/2010 09:18 PM, Vladimir Vassilevsky wrote:
> > > dbd wrote: >> On Sep 2, 7: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 would align the center of the window with the center of the sinc >> then sample as necessary. >> >> Dale B. Dalrymple > > I.e. the option (2). That was my thought, too; however there is a > subtlety. Let's say we have signal sampled at the points -3, -2, -1, 0, > 1, 2, 3 and we need to get the interpolated value at the point 0.5. So > we calculate the coefficients as Window(x) sinc(x) centered at 0.5. We > have 3 filter coefficients at the right from 0.5, and 4 coefficients at > the left from 0.5. I can either make the window of the length = 6 and > drop the extra coefficient from the left, or make the window of the > length = 7, which is not going to be symmetric. When working with the > windows of the length ~ 10, the +/- one coefficient could make > substantial difference.
Perhaps in that case the smart thing to do would be to truncate the window by one sample on one side. No matter what you do, if the point at which you want to interpolate is anything other than an integer or 1/2 you can't make your window symmetric -- so start figuring out what's the best in general, and see what drops out for the shift = 0.5 and shift = 0 cases. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On Sep 3, 12:00&#4294967295;pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
> robert bristow-johnson wrote:
...
> > at least it *should* be. &#4294967295;if you want to have the property of "reverse > > time invariance". &#4294967295;Vlad, i asked you a question. &#4294967295;care to address it? > > > "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?" > > If the filter is symmetric, yes. Otherwise the filter has to be time > reversed also. What is the point?
the point is that the coefficients can't be reversed. yet, it surely seems to me, that if the input data is reversed, you should get exactly the same output, except reversed. that means, if your "breakpoints" are at the sample times, the number of samples to the left and to the right have to be equal and there are an even number of coefficients (and these coefficients depend solely on the fractional part of the interpolated time). it is possible to have an odd number of coefficients, but then the "breakpoint" occurs midway between the sample times. but in that case, let's say you're slowly increasing the fractional time from 0 to 1/2 sample, you have 4 coefficients to the left and 3 to the right. we'll call those coefficients {h[3], h[2], h[1], h[0], h[-1], h[-2], h[-3]}. as you get closer to the midway position between x[0] and x[1], the coefficient h[3] (which gets attached to x[-3]) goes to zero and becomes exactly zero when you get to x(1/2). then as the fractional time gets slightly beyond 1/2 the coefficient set becomes {h[2], h[1], h[0], h[-1], h[-2], h[-3], h[-4]} but they would be renamed {h[3] ... h[-3]} and the set of samples would go from x[-2] up to x[4]. but i wouldn't do it that way. i would always insist on an even number of coefficients and the breakpoints would be at the sample times. 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. for an even number of coefficients, that means an equal number on the left and right of the interpolated point. 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. r b-j
robert bristow-johnson  <rbj@audioimagination.com> wrote:

>but i wouldn't do it that way. i would always insist on an even >number of coefficients and the breakpoints would be at the sample >times. 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. for an >even number of coefficients, that means an equal number on the left >and right of the interpolated point. 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. If you're interpolating from an odd number of sample points, the result is defined for an abcsissa between -1 and +1; whereas if you're interpolating from an even number of sample points, the result is defined for an absissa between 0 and +1. Thus it both remains symmetrical, and you do not have sample points "falling off" when the abscissa goes through a fractional value. Steve
On Fri, 03 Sep 2010 11:00:33 -0500, Vladimir Vassilevsky
<nospam@nowhere.com> wrote:

> > >robert bristow-johnson wrote: > >> On Sep 3, 1:29 am, dbd <d...@ieee.org> wrote: >> >>>On Sep 2, 9:18 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: >>> >>> >>>>... >>>>there is a >>>>subtlety. Let's say we have signal sampled at the points -3, -2, -1, 0, >>>>1, 2, 3 and we need to get the interpolated value at the point 0.5. So >>>>we calculate the coefficients as Window(x) sinc(x) centered at 0.5. We >>>>have 3 filter coefficients at the right from 0.5, and 4 coefficients at >>>>the left from 0.5. I can either make the window of the length = 6 and >>>>drop the extra coefficient from the left, or make the window of the >>>>length = 7, which is not going to be symmetric. When working with the >>>>windows of the length ~ 10, the +/- one coefficient could make >>>>substantial difference. >>> >>>The continuous weighted sinc designed waveform is symmetric. > >Continuous has to be sampled to make a filter, hence the coefficients >are generally not going to be symmetric. > >> at least it *should* be. if you want to have the property of "reverse >> time invariance". Vlad, i asked you a question. care to address it? > >"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?" > >If the filter is symmetric, yes. Otherwise the filter has to be time >reversed also. What is the point? > >>>Your >>>interpolator samples can only be symmetric if you are calculating the >>>output value at the time of an input sample or at a time half way >>>between input sample times. >> >> not if you're exactly half way *and* you are using 4 coefficients on >> the left and 3 coefficients on the right. > >VLV > >
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. You can try this yourself and see. 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. 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. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.abineau.com
On Sep 3, 7:53&#4294967295;am, robert bristow-johnson <r...@audioimagination.com>
wrote:

> ... > not if you're exactly half way *and* you are using 4 coefficients on > the left and 3 coefficients on the right. > > r b-j
If you are generating an output at the point halfway between inputs and there are only three valid samples to the right in the window, there are only three valid samples in the window to the left and they are symmetric with those on the right. An implementation that calculates 4 points on one side is broken. If the implementation cannot be made more efficient by deleting the unneeded multiply/add then that coefficient should be set to zero so that it does no harm. This seems to be the case where the change from 7 coefficients to 6 is disturbing to VLV's intuition. I think this is a case where the theoretical/continuous/infinite based intuition of the mixed-signal designer needs to adapt to the nature of the discrete sampled versions of symmetry and finite impulse response. Dale B. Dalrymple

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. 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 can try this yourself and see.
Try this for yourself and see.
> 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.
> 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. VLV
On Sep 3, 3:24&#4294967295;pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote:
>... > > 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. > ...
> VLV
Are you still using Remez exchange equiripple designed prototype filters? The (unoptimized) subsets of the optimized prototype will not match the performance of the prototype and will not match each other. A degradation by N may be a good rule of thumb for the loss. I've never seen a reference to a hard limit. Do you have one? A conventional window design prototype filter such as Kaiser-Bessel will not perform as well as the equiripple prototype of the same length, but the subsets will have the same performance as the prototype. Dale B. Dalrymple
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.
>> You can try this yourself and see. > >Try this for yourself and see.
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. Been there, done that, have thousands of products in the field to prove it.
>> 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. You're extremely harsh on other people who do that. Should I call you a name?
>> 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. > >VLV
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. Eric Jacobsen Minister of Algorithms Abineau Communications http://www.abineau.com

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 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%.
> 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... VLV

dbd wrote:

> On Sep 3, 3:24 pm, Vladimir Vassilevsky <nos...@nowhere.com> wrote: > >>... >> >>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. >>... > > Are you still using Remez exchange equiripple designed prototype > filters? > > The (unoptimized) subsets of the optimized prototype will not match > the performance of the prototype and will not match each other. A > degradation by N may be a good rule of thumb for the loss. I've never > seen a reference to a hard limit. Do you have one?
I haven't seen any. This is just my observations.
> A conventional window design prototype filter such as Kaiser-Bessel > will not perform as well as the equiripple prototype of the same > length, but the subsets will have the same performance as the > prototype.
It depends. Window designs are affected by decimation also; how much they are affected wrt similar Parks-McClellan design - depends on the particulars. I think of sharpening a time domain interpolation filter by brute force optimization. VLV