4

Is there a novel way to create a low-pass filter (Finite Impulse Response Filter) with varying cut off frequency over time?

For example, I have a white noise that is 10 seconds long sampled at 44.1 kHz. I want to create a low-pass filter that will have a varying cut-off frequency over time. At time 0 my cut-off frequency would be 100 Hz and will decrease linearly down to 1 Hz at time 10 seconds.

Chi
  • 107
  • 9
  • A system doesn't have to be time-invariant, so yes, you can build something like this. However, you must pay a bit of attention to the effects of a changing system. Can you explain what you need this for? I have several approaches in mind (from adjusting coefficients in a single-tap IIR over evolving a complete FIR through basically an adjustable IF with a fixed bandpass filter and a Hilbert transformator); whether any of these help you is unclear! – Marcus Müller Jun 08 '19 at 17:53
  • Hi Marcus, I will use this to obtain an impulse response. Here is the process that I want to implement to produce an impulse response that I need.
    1. Create 10 seconds white noise sampled at 44.1 kHz.
    2. Apply exponential decay on the white noise such that the amplitude at time 10 seconds is near zero.
    3. Apply a low-pass filter with varying cut-off frequency over time.

    I will convolve this derived impulse response in a human voice or a music. What do you think is best suited method in my case?

    – Joseph Roxas Jun 09 '19 at 09:27
  • Why do you want to do that, or to which end? What's the purpose of the convolution of voice or music with this? – Marcus Müller Jun 09 '19 at 21:53

1 Answers1

2

I wouldn't call this novel but... I'm going to give an example on how to do this for a specific filter with a specific discretization.

A 1st order butterworth low-pass filter is given by:

$H(s) = \frac{Y(s)}{X(s)} =\frac{\omega_c}{s + \omega_c}$

Where $\omega_c$ is the cut-off frequency of the filter.

The backward difference (aka backward euler) approximation is given by:

$s \approx \frac{1-z^{-1}}{T_s}$

Where $T_s$ is the sampling time. By substitution, the discrete transfer function becomes:

$H(z) = \frac{Y(z)}{X(z)} \frac{\omega_c}{\frac{1-z^{-1}}{T_s} + \omega_c} = \frac{\frac{\omega_c \cdot T_s}{1+\omega_c\cdot T_s}}{1 - \frac{1}{1+\omega_c\cdot T_s}\cdot z^{-1}}$

Let $a = \frac{\omega_c \cdot T_s}{1+\omega_c\cdot T_s}$, then:

$H(z) = \frac{a}{1 - (1-a)\cdot z^{-1}}$

Thus the difference equation is: $y[n] = a\cdot x[n] + (1-a)\cdot y[n-1]$

Why go through the tedious process of getting an equation for $a$ when I could have just used the above formula and try to guess some values for $a$? Well, now if you want to change the cut-off frequency $\omega_c$ in real time, you simply have to recalculate $a$ each time you compute the signal. This, of course, assumes you have a constant sampling period.

Note that this filter is an IIR filter, not FIR as you requested, but the logic is basically the same: as long as you know how your coefficients relate to the cut-off frequency, then you just simply have to recalculate them every time you want a different cut-off frequency. Nothing stops you from repeating the same steps for different discretization methods, different types of filters, etc...

You may even wish to work purely in the discrete-time domain, but the relevant part is always knowing how your coefficients relate to the cut-off frequency.

Chi
  • 107
  • 9
  • 2
    I hope I'm not too pedantic, but there's no 1st order Butterworth, or Chebyshev, or Cauer, 1st order is universal. – a concerned citizen Jun 09 '19 at 06:38
  • @aconcernedcitizen My knowledge of signal processing has always been kind of ad hoc so I never realized that, oops! – Chi Jun 09 '19 at 15:49
  • Please also see https://dsp.stackexchange.com/a/54088/41790 and related posts by @Matt L. – Ed V Jul 09 '19 at 12:42
  • On a second thought, is that really true? A 1st order butterworth would have a transfer function of 1/(1 + (s/w)) where w is the cutoff frequency. If I change any of those "1" values to be some other value, then it's still a 1st order low pass filter but it no longer fits Butterworth's formula for the gain of the filter. – Chi Sep 13 '19 at 00:22
  • How do you handle the transition when IIR filter changes? AFAIK, for FIR filters I can deal it with overlap-add, but I have no idea for IIR filters. – ZR Han Mar 01 '21 at 01:27
  • I don't think you need to do anything special for IIR filters when changing the coefficients, but if you really want to avoid a sudden transition, maybe you could apply a LPF to the coefficients themselves to make them change smoothly over time. If you want more control over it, you can implement something like a cubic hermite spline (with zero starting and ending tangent) to make them change smoothly in a given amount of time which can be set by you, depending on the needs of your particular use case. – Chi May 11 '21 at 10:24