Polyphase resampler jitter?

Started by gct October 21, 2008
I've got a polyphase resampler that I've built, and I'm noticing a lot of
jitter in the output power spectrum that I'm having a hard time tracking
down.  First a little about the resampler:  It's designed so that the user
provides an input signal, up/down values and a filter response, the program
than generates 'up' number of polyphase legs and strides through,
calculating every 'down' output sample.  Now, since the filter structure is
made to match the up/down ratio, there's no interpolation going on here, so
there SHOULDN'T be any jitter at all.  But, as you can see from this
picture:

http://img355.imageshack.us/img355/3817/jittertj3.jpg

There is (green is the input signal, read is my output and blue is the
output of a straight interpolating resampler).  Note the skirts between and
around the two tones.

However...when I specify an up/down ratio that comes out to be an integer
(something whacky like 380/95), the output looks great:

http://img401.imageshack.us/img401/8489/nojitterwm1.jpg

Now, is this jitter just a property of the polyphase architecture? 
>I've got a polyphase resampler that I've built, and I'm noticing a lot of >jitter in the output power spectrum that I'm having a hard time tracking >down. First a little about the resampler: It's designed so that the
user
>provides an input signal, up/down values and a filter response, the
program
>than generates 'up' number of polyphase legs and strides through, >calculating every 'down' output sample. Now, since the filter structure
is
>made to match the up/down ratio, there's no interpolation going on here,
so
>there SHOULDN'T be any jitter at all. But, as you can see from this >picture: > >http://img355.imageshack.us/img355/3817/jittertj3.jpg > >There is (green is the input signal, read is my output and blue is the >output of a straight interpolating resampler). Note the skirts between
and
>around the two tones. > >However...when I specify an up/down ratio that comes out to be an
integer
>(something whacky like 380/95), the output looks great: > >http://img401.imageshack.us/img401/8489/nojitterwm1.jpg > >Now, is this jitter just a property of the polyphase architecture? >
I should note that my output signal looks higher than the others because I'm not removing my filter gain (yet).
>>I've got a polyphase resampler that I've built, and I'm noticing a lot
of
>>jitter in the output power spectrum that I'm having a hard time
tracking
>>down. First a little about the resampler: It's designed so that the >user >>provides an input signal, up/down values and a filter response, the >program >>than generates 'up' number of polyphase legs and strides through, >>calculating every 'down' output sample. Now, since the filter
structure
>is >>made to match the up/down ratio, there's no interpolation going on
here,
>so >>there SHOULDN'T be any jitter at all. But, as you can see from this >>picture: >> >>http://img355.imageshack.us/img355/3817/jittertj3.jpg >> >>There is (green is the input signal, read is my output and blue is the >>output of a straight interpolating resampler). Note the skirts between >and >>around the two tones. >> >>However...when I specify an up/down ratio that comes out to be an >integer >>(something whacky like 380/95), the output looks great: >> >>http://img401.imageshack.us/img401/8489/nojitterwm1.jpg >> >>Now, is this jitter just a property of the polyphase architecture? >> > >I should note that my output signal looks higher than the others because >I'm not removing my filter gain (yet). >
The polyphase filter structure should have nothing to do with what you are seeing. All the polyphase filter structure does is allow you to skip calculations on intermediate values that will merely be discarded (multiply by 0). I am speculating that it is your implementation of the filter that may be causing this. For comparison, try interpolating then decimating separately and compare the output. If your implementation is correct, they should be identical. Forgive me if I'm incorrect, this is my first post and I'm still learning dsp myself.
>The polyphase filter structure should have nothing to do with what you
are
>seeing. All the polyphase filter structure does is allow you to skip >calculations on intermediate values that will merely be discarded
(multiply
>by 0). I am speculating that it is your implementation of the filter
that
>may be causing this. For comparison, try interpolating then decimating >separately and compare the output. If your implementation is correct,
they
>should be identical. > >Forgive me if I'm incorrect, this is my first post and I'm still
learning
>dsp myself. > > >
That's the feeling that I had, but if it's my implementation that's a problem, I'd expect to see the same effect for integer resampling ratios. The only thing I changed between those two images is the downsampling ratio (went from 380/250 to 380/190) which affects only the stride on the output...
>>The polyphase filter structure should have nothing to do with what you >are >>seeing. All the polyphase filter structure does is allow you to skip >>calculations on intermediate values that will merely be discarded >(multiply >>by 0). I am speculating that it is your implementation of the filter >that >>may be causing this. For comparison, try interpolating then decimating >>separately and compare the output. If your implementation is correct, >they >>should be identical. >> >>Forgive me if I'm incorrect, this is my first post and I'm still >learning >>dsp myself. >> >> >> > >That's the feeling that I had, but if it's my implementation that's a >problem, I'd expect to see the same effect for integer resampling
ratios.
>The only thing I changed between those two images is the downsampling
ratio
>(went from 380/250 to 380/190) which affects only the stride on the >output... >
Aha, found the problem. I had a rounding error when calculating how many output samples to calculate from a given input buffer. So my program was putting out 1 too many samples every input buffer, causing the output to jitter =D
> >Aha, found the problem. I had a rounding error when calculating how
many
>output samples to calculate from a given input buffer. So my program
was
>putting out 1 too many samples every input buffer, causing the output to >jitter =D >
Last post on this to help future resampler-makers. The problem wasn't quite so simple as this. I was holding my input buffer size constant (at 64K). This almost always results in an output buffer size that had some dangling fraction of a sample: 38/25*64K = 99614.72 These dangling fractions would get rounded off, so that every buffer I processed I was either adding or missing a fraction of a sample, which manifested as distortion in the power spectrum. The change I made to fix it is I start at the desird input size (64K) and then search upwards for a number that's an even multiple of the downsampling rate. This ensures that the output buffer size is always exact, and the problem is resolved, nice tight lines in the power spectrum.