oversampling iir-filter (pre/post filtering)
-
- KVRist
- Topic Starter
- 37 posts since 18 Sep, 2011
Hi there people,
i over-sample a IIR (minimal phase) filter to achieve more precision filter curves near the nyquist frequency.
input -> insert zeros -> (pre-filter) -> IIR-Filter -> (post-filter) -> remove zero places -> output
To my surprise there is no difference if i remove the pre/post-filtering (assuming ideal filters), also i don't detect any aliasing artifacts without pre/post-filtering.
Can't it be, through the nature of IIR-Filters, which not create any additional harmonic content, no pre/post-filtering is required in this case, or do i something wrong, just feeding my processing with the wrong test-signals?
i over-sample a IIR (minimal phase) filter to achieve more precision filter curves near the nyquist frequency.
input -> insert zeros -> (pre-filter) -> IIR-Filter -> (post-filter) -> remove zero places -> output
To my surprise there is no difference if i remove the pre/post-filtering (assuming ideal filters), also i don't detect any aliasing artifacts without pre/post-filtering.
Can't it be, through the nature of IIR-Filters, which not create any additional harmonic content, no pre/post-filtering is required in this case, or do i something wrong, just feeding my processing with the wrong test-signals?
-
- KVRian
- 563 posts since 23 Nov, 2010
If you're only doing linear processing then aliases from upsampling will fold back onto the original signal when you downsample. In some cases (EG lowpass) the aliasing will often be well hidden. If you have a sine at 5khz, upsample 2x with zero stuffing, lowpass it, then downsample again, the alias image caused by zero stuffing will fold back onto the 5khz original. If your lowpass was a 24db type, then the alias will be maybe 60dbs down, so it'll just cause a tiny gain change in the original 5khz sine when it's folded back.
Try doing it with a highpass, that'll leave all the aliases to fold back, you'll see some weirdness then.
Try doing it with a highpass, that'll leave all the aliases to fold back, you'll see some weirdness then.
Chris Jones
www.sonigen.com
www.sonigen.com
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
With linear processing, it's sufficient to just filter once.. if you up-sample with a proper filter, then down-sampling filter is redundant, because a linear process doesn't create harmonics and the up-sampling filter already removed everything (and similarly if you're down-sampling with a filter, then the images from just zero-stuffing naively for up-sampling don't really matter, because they get removed anyway). But if you don't do any filtering at all (neither up or down sampling), then there will be images created by up-sampling which will alias when down-sampling.
The aliasing frequencies here will be the same as the original frequencies, so it's not like you can actually see it in the normal ways.. your EQ just ends up with (sometimes very) distorted curves.
The aliasing frequencies here will be the same as the original frequencies, so it's not like you can actually see it in the normal ways.. your EQ just ends up with (sometimes very) distorted curves.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
The thing is to use a proper up sampling filter. Padding with zeros definitely is not the proper way to avoid aliasing. BTW, this is only needed if you are working at 44.1 or 48kHz, otherwise you can remove this additional step.
-
- KVRist
- 327 posts since 13 Nov, 2002 from Germany, Darmstadt
Padding with zeros will mirror the spectrum into the new range without altering the existing spectrum at all. Then you can filter out everything above the old Nyquist. Why would that not be a proper way to avoid aliasing?Miles1981 wrote:The thing is to use a proper up sampling filter. Padding with zeros definitely is not the proper way to avoid aliasing.
-
- KVRian
- 1379 posts since 26 Apr, 2004 from UK
Because it is additional work, when you can do everything in one pass. And a low-pass filter has additional issues.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Well, you normally fold the zero-stuffing into your poly-phase implementation, so you don't actually need build a signal with the extra zeroes at any point, you just need your up-sampling filter to work "as-if" those zeroes were there (producing more output samples compared to input) but conceptually it isn't just "proper way" since it's actually pretty much the ONLY way to up-sample (with or without anti-aliasing).Miles1981 wrote:Because it is additional work, when you can do everything in one pass. And a low-pass filter has additional issues.
For example, if you simply duplicated every sample (for 2x) then this is in fact equivalent to zero-stuffing followed by box-car filter. Or if you used linear interpolation, then the filter would be triangular. Unlike high quality anti-alias filters, both of these will significantly distort the original spectrum, but in terms of math, you can still break down the process into zero-stuffing and filtering.
-
- KVRAF
- 1607 posts since 12 Apr, 2002
Talking of zero-stuffing, I actually think this is an unnecessary overcompilcation of the subject with a few unnecessary "arcane" points (as mystran put it recently )
IMHO, a much more intuitive view of resampling is by having an intermediate step in the continuous-time domain. You basically just convolve the initial PCM signal (continuous-time impulse train with varying impulse amplitude) with your preferred lowpass impulse response (windowed sinc being the most obvious example) and then sample it again at the new rate. This results in pretty much the same resampling filter, except that you don't need any "artificial" zero-stuffing.
IMHO, a much more intuitive view of resampling is by having an intermediate step in the continuous-time domain. You basically just convolve the initial PCM signal (continuous-time impulse train with varying impulse amplitude) with your preferred lowpass impulse response (windowed sinc being the most obvious example) and then sample it again at the new rate. This results in pretty much the same resampling filter, except that you don't need any "artificial" zero-stuffing.
- KVRAF
- 7890 posts since 12 Feb, 2006 from Helsinki, Finland
Well, except.. mathematically you'd then be treating each sample as a dirac delta, essentially zero-stuffing to a sample-rate limit at infinity.. sort of anyway.Z1202 wrote: IMHO, a much more intuitive view of resampling is by having an intermediate step in the continuous-time domain. You basically just convolve the initial PCM signal (continuous-time impulse train with varying impulse amplitude) with your preferred lowpass impulse response (windowed sinc being the most obvious example) and then sample it again at the new rate. This results in pretty much the same resampling filter, except that you don't need any "artificial" zero-stuffing.