Trying to understand oversampling

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

earlevel wrote: Sorry, I don't mean to cherry-pick criticism of someone's help, and certainly there are places that linear interpolation for up sampling works fine (especially stuff that's already oversampled, such as audio without a lot of high frequency content). But I don't think the linear interpolation buys you much in the way of filtering if you are going to follow it with a better filter, and it hurts passband response near the cutoff that windowed sync won't get back.
You would sample the linear interpolator due to the fact that it does fall off significantly within the pass-band. In fact it has a zero amplitude notch with "infinite slope". This property can be taken advantage of when constructing a complex hybrid filter in that the linear interpolator is very easy to compute via integration. (Replace multiplies with adds.)

That though is nothing at all like applying the interpolator directly to the input signal at the target rate. In that case yes, there is absolutely no reason to do so.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote:Zero padding does modify the content within the pass-band and so does "fall off". It creates both pass-band and stop-band ripple.

Only an infinitely thin pulse would not create any ripple, while at the same time it would be of zero amplitude.
Zero padding implies we're in the digital domain. Therein, samples represent the energy of ideal impulses.

If you don't believe it, upsample a digital impulse (1,0,0,0...). The resulting impulse response will be the same as that of your anti-aliasing filter (e.g., windowed sinc), not your anti-aliasing filter with additional droop from the zero-padding "fall off".

(And why do you think an infinitely thin impulse has zero amplitude? If it did, it wouldn't be anything and we wouldn't be discussing an impulse.)
My audio DSP blog: earlevel.com

Post

An infinitesimal impulse has zero amplitude because time and amplitude are the same thing.

Get a life and stop reading posts hoping to disagree about something so you can start a pointless argument. Go outside. Go to the park. Make some friends or something. Play baseball. I don't care.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote:An infinitesimal impulse has zero amplitude because time and amplitude are the same thing.

Get a life and stop reading posts hoping to disagree about something so you can start a pointless argument. Go outside. Go to the park. Make some friends or something. Play baseball. I don't care.
"Get a life"—sheesh, coming from someone as their 10814th post on kvr.

But no, you're still wrong about ideal impulses, so go play baseball. "An ideal impulse function is a function that is zero everywhere but at the origin, where it is infinitely high." That's a unit impulse. (How could you expect a unit impulse to have no amplitude??)
My audio DSP blog: earlevel.com

Post

What is its amplitude? Infinity. What is its integral? Zero. What is zero times infinity? Zero. (Or, unknown. Doesn't matter.)

My point is that it does not exist. While you're correct that "in theory" zero padding does not have any "fall-off", in reality it does because as you point out you must use some form of interpolation which does have fall-off.

Now stop wasting everyone's time by pointing out the obvious. I admit you may have not bothered to read the post and therefore you thought that you were arguing something worthwhile or otherwise at all valid, unfortunately if that is the case again please stop wasting everyone's time.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote: Only an infinitely thin pulse would not create any ripple, while at the same time it would be of zero amplitude.
Maybe amplitude is directly proportional to the integral, a reduction in one should appear in the other. If amplitude is held constant while the integral is reduced, then it makes sense to also reduce the amplitude... otherwise there would have to be increasing energy input.
Blah blah, Very abstract, might not make sense, but numbers are nothing without purpose.

Post

As far as interpolating filters used in oversampling it is important to note that zero-padding is possible, but like linear or other simple methods it is of very limited use.

Yes the amplitude of the integral of the pulse depends upon its width of course. With an infinitely thin pulse it has a zero amplitude integral even if the pulse is scaled to infinity. It is entirely abstract. The integral of the unit impulse is the step function which is another wholly abstract thing.

While we're talking about discrete processing it is important to note that when we integrate a "sample" if we take the amplitude of the sample without computing the integral of an interpolating filter (sinc or so on) what we've actually done is integrate a zero-order hold step.

This is interesting but I think way beyond what the OP is interested in. They want to make their oversampling work correctly even if they don't understand such abstract concepts. I do not think it is worthwhile to anyone involved here whether already well aware of the advanced and abstract subject matter or not for any discussion of it to take place in this thread.

If anyone has reason to complain about the working (I hope?) filters I posted I'd love to hear about it. Especially if it isn't merely complaint but rather a better filter and more efficient too.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

(Useless post removed.)

Actually was the OP's post edited? It may be that the filters they're using are just awful.

Not all filters are designed to be applied to a zero-padded signal. If the filter implementation is broken you would get bad results. The signal should be sampled and output at all five points:

1) Original
2) Interpolating filter "up-sample"
3) Processed signal at over-sampled rate
4) interpolating filter "down-sample" before decimation!
5) Output
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

aciddose wrote:Now stop wasting everyone's time by pointing out the obvious.
Why get insulting? Yeah, I know, because you can't defend points like "zero padding falls off similarly to zero-order while linear is first-order". But if it were true you could defend it easily by plotting both and showing the board (and explaining how you got the zero-padding "fall-off"). Meanwhile, it's easy enough to show that the frequency response of a zero-padded, then windowed-sine'd impulse is exactly that of the windowed-sinc—because there is no "fall-off" due to zero padding.

I'm not going to respond to you, directly, on this thread again—it's no mystery how you've accumulated 10817 posts. You like to drag people down the rabbit hole.
My audio DSP blog: earlevel.com

Post

aciddose wrote:Linear isn't much better than zero padding. The difference is zero padding falls off similarly to zero-order while linear is first-order. Both have "holes" or "notches" while 1st order gives 1/N amplitude for each image.

That isn't a very good slope!
Sorry, zero padding doesn't have notches or even a slope. Zero padding retains the original frequencies plus spectral mirroring above nyquist. Yes there's a lot of noise created, but it's above original nyquist and thus can be filtered. Anyway a picture speaks a thousand words. Here's the frequency response of a signal zero padded, filtered and downsampled:

Image

and here's the spectra with linear interpolation of the mid points followed with the same brick wall filter and downsampling:

Image

Both methods have a decent THD+N ~-120 dB. But the choice looking at the frequency responses should be obvious which is superior, plus zero padding lends itself to optimisations.

Should add with zero padding final signal is half amplitude (actually amplitude is divided by upsampling factor in this case it's 2) so is corrected by doubling the value of the output.

Post

matt42 wrote: Here's the frequency response of a signal zero padded, filtered and downsampled:
If you use a linear-phase windowed sinc with the cutoff set exactly at Nyquist then this kind of test should normally always show you a completely flat line [edit: at least in the 2x case], because the aliasing left over in the stop-band folds over to "fill in" the damage in the pass-band, no matter how terrible the actual filter performance ... but only if the whole thing is linear-phase.

To evaluate oversampling filter performance, I highly recommend the "reverse test" where you first down-sample the signal to half the sampling rate and then up-sample it back to the original rate. This way you should have a brick-wall transition at 1/4th of the sampling rate (eg. 11025Hz for 44.1kHz sampling) and any imperfections of the process remain visible to your spectrum plot (or you could just plot at the oversampled rate directly, but you can't really get an external analyzer to do this for you).

Post

Matt42; What I said in my post needs to be taken in context with the whole post. If you take it out of context and fill in a bunch of "between the lines" stuff I didn't say, you can then draw the conclusion that what I meant according to your subjective interpretation must have been that a theoretically perfect zero-padding modifies the resulting frequency spectrum.

You need to have a wild imagination for that though.

If this had never been brought up, do you think it might have been possible that the discussion could have focused on practical issues that anyone actually cares about?

Perhaps I could have phrased what I said differently. Regardless of any misunderstanding it was not incorrect in whole or in part.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.

Post

mystran wrote:
matt42 wrote: Here's the frequency response of a signal zero padded, filtered and downsampled:
If you use a linear-phase windowed sinc with the cutoff set exactly at Nyquist then this kind of test should normally always show you a completely flat line [edit: at least in the 2x case], because the aliasing left over in the stop-band folds over to "fill in" the damage in the pass-band, no matter how terrible the actual filter performance ... but only if the whole thing is linear-phase.
Thanks, Mystran.

Actually I didn't have time to spend on this test, so I just grabbed an off the shelf high order polyphase IIR filter with very steep pass band attenuation (musicdsp.org). So in the test shown it isn't linear phase. And though the filtering is close to brick wall the cutoff is exactly nyquist, so I'd guess there will be some aliasing near nyquist that won't show in that graph.
mystran wrote:To evaluate oversampling filter performance, I highly recommend the "reverse test" where you first down-sample the signal to half the sampling rate and then up-sample it back to the original rate. This way you should have a brick-wall transition at 1/4th of the sampling rate (eg. 11025Hz for 44.1kHz sampling) and any imperfections of the process remain visible to your spectrum plot (or you could just plot at the oversampled rate directly, but you can't really get an external analyzer to do this for you).
Yes, that's good advice. I was thinking of doing something like this to get around the restrictions of using VST Analyser, but really I'm not so interested in spending more time on this

Post

OK, for completeness here's Mystran's test: So 44100 to 22050 then back up to 44100.

With zero padding:

Image


Edit, I'll have to double check my implementation of linear interpolation as the results are so terrible I wouldn't post them up without being first sure that it's not due to an implementation error.

Post

I got the possibly erroneous impression that plusfer was asking about using linear interpolation to "fill the gaps" as a preamble to a better anti-alias upsample filter. As an alternative to zero-stuffing. IOW, not just to use linear interpolation as a substitute for the entire upsample process.

I tried such things in the past, hoping that filling the gaps with something a little smoother than zeros might allow good performance with a quicker cheaper main brickwall filter. IOW, getting a good result using fewer cpu cycles. Dunno, maybe the entire idea is silly.

One thing I tried as alternative to zero-stuffing was a half-sample allpass delay. But thinking back, it probably wasn't a good idea for signals with significant high frequency content, because the simple half-sample allpass delays don't really do any such thing in the top octave or so. The phase shift collapses to hardly any delay at all at high frequencies, so would probably be just as bad as filling the gaps with repeat-sample, so far as high frequencies go.

Also tried "filling the gaps" with hermite interpolation before filtering.

It was attempt at getting a bargain in cpu cost. For instance, maybe if zero-stuffing followed by a 12th order polyphase halfband filter gives X amount of aliasing reduction-- Maybe "just the right alternative" of cheaply filling the gaps could give the same X amount of aliasing reduction with a lower-order, cheaper polyphase halfband filter? But maybe there is no cheating mother nature and it is 6 of one or a half-dozen of the other. Dunno.

That's what I'm curious about with short lanczos. Rather than 4X zero stuff, 4X interpolate with a low-order lanczos before a "better filter". Maybe one way to test, would be to feed a sine sweep thru a 4X low-order lanczos, and output at the same sample rate, but for instance output the quarter-position interpolated samples and measure what kind of mess that makes. Then make another test run outputing the half-position lanczos-interpolated samples, etc. Analyzing the outputs to find out what kind of aliasing or distortion or frequency anomalies get introduced merely by substituting the original signal at the same sample rate, with one of the delayed interpolated taps at the same sample rate?

If by some miracle the individual lanczos-delayed signals don't get butchered too badly, then maybe it would make a decent cheap pre-processing before a steeper but cheaper halfband filter. It would be linear phase anyway.

Post Reply

Return to “DSP and Plugin Development”