SignalProcessing.Compute.Filter.Filter

This node filters a signal using the given numerator and denominator coefficients of a rational transfer function. These coefficients can be provided manually or can be created using the Filter.Coefficients node.
The in slot must be connected to an input signal $x[n]$ to which the filter will be applied. The nominator input slot requires a signal $a[n]$ containing numerator coefficients and the denominator input slot a signal $b[n]$ containing denominator coefficients. The node computes the filtered signal $y[n]$ at the out slot by:
$\mathrm{y}[n] = \sum\limits_{k=0}^{M-1} a[k] \,x[n-k] + \sum\limits_{k=1}^{N-1} b[k] \, y[n-k]$
where $M$ is the length of $a[n]$ and $N$ is the length of $b[n]$. The coefficient $b[0]$ is not used and can be set to an arbitrary value.
As illustrated in the figure below, the denominator coefficients $b[n]$ allow to implement a recursive filter by creating a feedback loop:
iir_block
$\mathrm{x}[n]$
$\mathrm{y}[n]$
$a[M-1]$
$a[M-2]$
$a[2]$
$a[1]$
$a[0]$
$b[N-1]$
$b[N-2]$
$b[2]$
$b[1]$

FIR and IIR filter

If denominator coefficients $b[n]$ are used, the resulting filter is a recursive IIR (infinite impulse response) filter. Otherwise, if the length of the denominator signal $b[n]$ is zero (or all its coefficients are zero) and only the nominator coefficients $a[n]$ are used, the resulting filter is a non-recursive FIR (finite impulse response) filter. In this case, the output is the same as the output of a convolution of $a[n]$ and $x[n]$ (compare Filter.Convolution node). The only difference is that the implementation of the filter node described here ensures that the length of the output is clipped off and is always the same as the length of the input:
$\text{length}(\mathrm{y}) = \text{length}(\mathrm{x})$.

Filter delay

Executing a filter might introduce a delay. In the example shown below, an FIR filter with nominator coefficients $a[n]$ causes a delay of 32 samples. The filter delay input slot can be used to compensate the delay. In the example, the filter delay is set to 32 and the output signal is shifted by 32 samples to the left such that the delay is removed.
iir_block
Input $\mathrm{x}[n]$
Filter coefficients $\mathrm{a}[n]$
Output $\mathrm{y}[n]$
Shifted output $\mathrm{y}[n]$

Zero phase filtering

IIR filters are typically producing not only a delay but also non-linear phase effects as shown in the example below. These effects can be removed if the zero phase input slot is set to true. In this case, the filter node executes zero-phase filtering by first filtering forwards in time and then filtering the resulting signal backwards in time to produce the final output. As a consequence, the filter transfer function magnitude is the squared original magnitude and the phase is zero. The downside is that the execution time will be approximately twice as long. Because zero-phase filtering removes any filter delay, the input to the filter delay slot is ignored.
zero_phase
$\mathrm{x}[n]$
$\mathrm{y}[n]$
$\mathrm{y}[n]$
Input
Non-linear phase output
Zero-phase filtering

SignalProcessing.Compute.Filter.Coefficients

This node generates coefficients for different types of filters and is designed to work together with the filter node described above. The outputs are numerator and denominator coefficients of a rational transfer function as well as a filter delay that can be used as inputs to a filter node.
The length input slot selects the length of the numerator and denominator signal. Longer signals with more coefficients typically produce a filter with higher sharpness in the frequency domain but the downside is an increase in execution time.
The filter type can be selected via the type input slot:

  • Type = 0: Low-pass
  • Type = 1: High-pass
  • Type = 2: Band-pass
  • Type = 3: Band-reject
Currently, there are three different filter approaches implemented that can be selected via the approach slot:

  • Approach = 0: Hamming windowed-sinc filter
  • Approach = 1: Blackman windowed-sinc filter
  • Approach = 2: Butterworth filter
It is likely that more approaches will be implemented in future. The differences of the filter approaches are discussed below.

Low-pass filter

A low-pass filter passes signal components with a frequency below a given cut-off frequency and rejects the ones above the cut-off. The cut-off input slot expects a cut-off frequency as a fraction of $\pi$. Therefore, it must be in the range $[0.0, 1.0[$. For example, if the cut-off is set to 0.25, only the lower quarter of all possible frequency components passes the filter.
In the diagrams below the frequency responses of low-pass filters with a cut-off frequency of 0.25 are shown. On the left the magnitude of the frequency response is shown for a Hamming and Blackman filter of length 51 and a Butterworth filter of length 9. In the middle, the same curves are shown in log-scale. On the right the filter length is increased to 512 for Hamming and Blackman and to 15 for Butterworth.
filter_compare
Frequency response magnitude
Freq. response in dB
Freq. response in dB (long filter)
As can be seen in the diagrams, the Hamming window approach has the sharpest roll-off but Blackman has a better rejection band attenuation. The Butterworth filter performs worst but is an order of magnitude faster to execute because of its shorter length. If the length of the filters is increased, the performance of the FIR filters (Hamming and Blackman) can be further improved. Same is true for the Butterworth filter but it is an IIR filter and has problems with stability if the length is increased beyond 15 in this example.

High-pass filter

A high-pass filter passes signal components with a frequency above a given cut-off frequency and rejects the ones below the cut-off. The example below shows the frequency response of a Hamming windowed-sinc high-pass and low-pass of same length. Both have a cut-off frequency of 0.25.
high_low
Freq. response in dB (Hamming)

Band-pass and band-reject filter

A band-pass filter only passes the frequency in between the cut-off frequency and a second cut-off frequency, which can be set via the cut-off2 input slot. A band-reject filter reverses this behavior as shown in the example below. Here the cut-off was set to 0.25 and cut-off2 to 0.5.
high_low
Freq. response in dB (Hamming)

Stability of the Butterworth filter

The Butterworth filter is an IIR filter with a feedback loop that can be instable because of round-off errors. In contrast, the Hamming and Blackman FIR filters do not have a feedback loop and are always stable (but have a much longer execution time). The Butterworth filter is most stable if the length is set to a very small value. A good starting point is a length of 3.
Unfortunately, the recommended maximum filter length depends on the cut-off frequency of the filter. For cut-off frequencies around 0.5, the recommended maximum length is 15. For cut-off frequencies that are off-center the recommended maximum length is much less. For example, if the cut-off is 0.1, the recommended maximum is 7. If the cut-off is 0.01, the maximum length is 3.
The order (or number of poles) of an IIR Butterworth filter is related to the selected length by:
$\mbox{order} = \mbox{length} - 1 \quad$ for a low-pass or high-pass and
$\mbox{order} = \mbox{floor}((\mbox{length} - 1)/2) \quad $ for a band-pass or band-reject filter.
Because the order is an important criteria for stability, the length of a band-pass or band-reject filter can be selected slightly higher before stability problems occur.
The example Custom Filter demonstrates the basic usage of the filter node.