Convolution: The Secret Behind Filtering

zhinit1 pts0 comments

Convolution: The secret behind filtering | WolfSound

All

Audio FX

C/C++

Digital Signal Processing

Podcast

Programming in General

Python

Sound in General

Sound Synthesis

Why does filtering work? What enables us to enhance the bass in our audio players?

Play Video: Convolution: The secret behind filtering

Please<br>accept marketing cookies<br>to access the video player.

There is one operation that stands behind it all: convolution .

In order to fully master filtering, be it finite impulse response (FIR) or infinite impulse response (IIR) filtering, one needs to understand the definition, derivation and the properties of the convolution operation very well. That will be the topic of this and a few following articles.

We are going to dig deep into the convolution and we will get to know it so well, that it won’t surprise us any more and we’ll be able to recognize it from afar.

This article outlines the mathematical definition of the convolution and gives you some intuition behind it. In the next article we will introduce some basic properties along with their proofs (told you it’s going to go deep).

Are you ready?

The Convolution Series

Definition of convolution and intuition behind it

Mathematical properties of convolution

Convolution property of Fourier, Laplace, and z-transforms

Identity element of the convolution

Star notation of the convolution

Circular vs. linear convolution

Fast convolution

Convolution vs. correlation

Convolution in MATLAB, NumPy, and SciPy

Deconvolution: Inverse convolution

Convolution in probability: Sum of independent random variables

Definition

In its simplest form, the convolution between two discrete-time signals x[n]x[n]x[n] and h[n]h[n]h[n] can be expressed as an infinite sum

x[n]∗h[n]=∑k=−∞∞x[k]h[n−k]=y[n],n∈Z.(1) x[n] \ast h[n] = \sum_{k=-\infty}^{\infty} x[k] h[n - k] = y[n], \quad n \in \mathbb{Z}. \quad (1)x[n]∗h[n]=k=−∞∑∞​x[k]h[n−k]=y[n],n∈Z.(1)<br>Whoa, what’s happened here? Under the sum we have the two signals, but the second one is not only shifted in time by nnn but also time-reversed !

Important assumptions

In order to make this discussion feasible, we must enforce x[n]x[n]x[n] and h[n]h[n]h[n] to have finite energy. A signal s[n]s[n]s[n] is said to have finite energy, if

∑n=−∞∞s2[n]∞,(2) \sum_{n=-\infty}^{\infty} s^2[n] n=−∞∑∞​s2[n]∞,(2)<br>i. e., s[n]s[n]s[n] is square-summable.

Additionally, we also assume that all considered signals s[n]s[n]s[n] (x[n],h[n],y[n]x[n], h[n], y[n]x[n],h[n],y[n], etc.) are 0 for negative time indices, i. e., s[n]=0∀n0s[n] = 0 \quad \forall n s[n]=0∀n0.

Intuition

In order to get an intuition behind the convolution, we should look at it from different perspectives.

Filtering perspective

Let’s consider a generic filter with input x[n]x[n]x[n], output y[n]y[n]y[n], and impulse response h[n]h[n]h[n] (Figure 1).

Figure 1. A generic filter.

A filter is a linear time-invariant (LTI) system. From signal processing we know that any LTI system is completely specified by its impulse response h[n]h[n]h[n]. The output y[n]y[n]y[n] of an LTI system is by definition equal to the convolution of the input x[n]x[n]x[n] with the system’s impulse response h[n]h[n]h[n]. That is why the output of an LTI system is called a convolution sum or a superposition sum in case of discrete systems and a convolution integral or a superposition integral in case of continuous systems.

Now, let’s consider again Equation 1 with h[n]h[n]h[n] denoting the filter’s impulse response and x[n]x[n]x[n] denoting the filter’s input signal.<br>We may look at the filter’s output y[n]y[n]y[n] as a weighted sum of filter’s impulse responses. How?

Consider n=0n=0n=0. At the output we get

y[0]=∑k=−∞∞x[k]h[0−k]=∑k=−∞∞x[k]h[−k]=x[0]h[0],y[0] = \sum_{k=-\infty}^{\infty} x[k] h[0 - k] = \sum_{k=-\infty}^{\infty} x[k] h[- k] = x[0] h[0],y[0]=k=−∞∑∞​x[k]h[0−k]=k=−∞∑∞​x[k]h[−k]=x[0]h[0],<br>y[1]=∑k=−∞∞x[k]h[1−k]=x[0]h[1]+x[1]h[0].y[1] = \sum_{k=-\infty}^{\infty} x[k] h[1 - k] = x[0]h[1] + x[1]h[0].y[1]=k=−∞∑∞​x[k]h[1−k]=x[0]h[1]+x[1]h[0].<br>Delaying-and-summing perspective

We can also look at that operation from a different perspective. What if we fix kkk in Equation 1? In this case, it describes the output of the system if only input sample x[k]x[k]x[k] was given:

yk[n]=x[k]h[n−k].(3) y_k[n] = x[k]h[n-k]. \quad (3)yk​[n]=x[k]h[n−k].(3)<br>The above equation basically says, that once x[k]x[k]x[k] enters the filter, it will weigh its entire impulse response delayed by kkk samples with respect to nnn. We then just have to sum up over all possible kkk values to conclude that y[n]y[n]y[n] is just filter’s impulse response, delayed and weighted by each sample of x[n]x[n]x[n].

This may all get a little bit confusing at this moment, so let’s look at an example, shall we?

Example

Let’s consider the following signal x[n]x[n]x[n] of length 4, i. e., consisting of x[0],x[1],x[2]x[0], x[1], x[2]x[0],x[1],x[2], and x[3]x[3]x[3]

Figure 2. Input signal x[n]x[n]x[n].

and filter’s...

convolution infty filter impulse response behind

Related Articles