DSP from Scratch · Lesson 6
Frequency Response Explained Simply: Gain, Phase and Filters
Why a wall lets the bass through but never the words, and the one graph that shows what any system does to every frequency.

Press play: it starts at
Chapters16 parts, tap one to jump there
In one sentence
Same frequency, new height, new timing.
Watch first, then read. The video shows every idea moving. These notes write out each step so you can check the maths at your own pace. Press any ▶ time button to jump the video to that moment.
When your neighbours have a party, the music comes through the wall as nothing but a deep, muffled beat. The bass arrives. The words never do.
The wall is not choosing. It simply treats low sounds and high sounds differently. So do your headphones, and the bass and treble sliders on your phone. One graph shows you how: the frequency response. Frequency just means how fast a wave repeats, and all it takes to understand the graph is the strip from lesson 5, with just two numbers on it.
Quick recap
- Lesson 2: a sine wave has a height (its amplitude), a frequency in hertz (how many times it repeats each second) and a starting point (its phase).
- Lesson 3: every sound is a mix of sine waves, its ingredients.
- Lesson 4: a system turns an input into an output.
- Lesson 5: to find what comes out, slide a strip of weights along the input, multiply and add.
Sine in, sine out
Play one pure low note against the wall and listen on the other side. You hear the same note: quieter, and a tiny moment later, but still exactly that note. Play a high note: again the same note comes out, just far, far quieter. The wall never turns a high note into a low one.
The rule holds for systems that are linear and time-invariant (lesson 4): inputs simply add, and the same input later gives the same output later. A wall behaves like that.
We measure the change in height with one number, the gain:
A gain of 1 means no change; ½ means half as tall; 0 means gone.
In symbols, from lesson 2, a sine wave going in is
where is its height and its frequency in radians per step. Out comes
The same . is the gain, and , a new starting point, is the timing change.
Why fast waves cancel
Why would a wall care how fast a wave wiggles? Because a wall is heavy. A slow push has time to move it. A quick push turns into a pull before the wall gets going, so the two cancel.
We can build that heavy wall out of numbers with a strip of two weights, ½ and ½: each output is the average of the newest number and the one before it. In lesson 5’s symbols, the impulse response is and
- A very slow wave hardly moves from one step to the next: 1, then 1, then 1. The average of 1 and 1 is 1. It comes straight through: gain 1.
- The fastest wave a list of numbers can hold (lesson 3) goes up, down, up, down: 1, −1, 1, −1. The average of 1 and −1 is 0, every time. The wave is completely gone: gain 0.
A very slow wave
Neighbours agree: the average of 1 and 1 is 1.
The fastest wave
Neighbours disagree: the average of 1 and −1 is 0.
There is the whole secret. On a slow wave neighbours agree, so averaging keeps it. On a fast wave neighbours disagree, so averaging cancels it, just like a push and a pull on a heavy wall.
And something in between? Take a wave that repeats every four steps: 0, 1, 0, −1. The averages come out as ½, ½, −½, −½. It still repeats every four steps, the same frequency as the rule promised. Draw a smooth wave through those numbers and its peak reaches about 0.71, so the gain here is about 0.71. And the peak now falls halfway between two steps, where the original peak was on a step: the wave came out half a step late. That is the timing change.
The frequency response graph
Suppose our numbers arrive 6,000 times a second. The fastest wave they can hold is half of that (lesson 3): 3,000 Hz. Send in one sine wave at a time, measure the gain, and mark it on a graph:
- at 0 Hz, a wave so slow it does not move at all, the gain is 1;
- at 1,500 Hz, our wave that repeats every four steps, it is about 0.71;
- at 3,000 Hz it is 0.
Fill in all the frequencies between and you get a smooth curve falling from 1 to 0.
The frequency response of the two-number average: for every frequency, the gain. Read straight off it: 2,000 Hz has gain ½.
That curve is the frequency response: for every frequency, what the system does to it.
The same graph in symbols
From lesson 2, the frequency per step is . With , the frequencies 0, 1,500 and 3,000 Hz become , and .
Textbooks call the frequency response and write the gain as , between two bars (lesson 7 shows why the bars). For our strip the gain has a neat formula:
Check it: ; ; .
Where does the cosine come from? Feed in . Then
A rule from school trigonometry adds two sines:
With and , the half and the 2 cancel and
There is the gain, . And means the wave comes out half a step late: the timing change we saw.
A sine wave of height 3, because . Its frequency is still 2,000 Hz: the height changes, the frequency never does.
What happens to a mix
Real sounds are not one sine wave. Here is a deep hum at 100 Hz with a high hiss at 2,800 Hz on top. What does our strip do to the mix?
Remember lesson 4: in a linear system, inputs simply add. So each ingredient goes through on its own, with its own gain, and the outputs add up at the end:
Read them off the curve. The hum is near the left: gain almost 1. The hiss is far to the right: gain about 0.1. Out comes the hum nearly untouched, with a hiss one tenth as tall.
The hum sits where the gain is almost 1; the hiss sits where it is about 0.1.
2, 2, 2. Look at the input again: it is a steady 2, plus a fast wiggle of 2 up and 2 down. The steady part came through; the fast wiggle vanished.
And that is your neighbour’s wall. It lets low frequencies through far better than high ones. The bass gets through; the high sounds that carry the words do not.
Low-pass and high-pass filters
Change just one sign: a half times the newest number, minus a half times the one before:
Instead of averaging neighbours, we are measuring how much they differ. On the slow wave, 1 and 1, there is no difference, so 0 comes out. On the fastest wave, 1 and −1, the difference is big, so it comes through at full height. The curve has flipped: now it rises from 0 to 1. A twin of that school rule, for subtracting two sines, gives its formula:
One sign changes everything: the average keeps the lows, the difference keeps the highs.
A system chosen for its curve is called a filter. One that keeps the low frequencies is a low-pass filter; one that keeps the high frequencies is a high-pass filter. The weights decide the curve. Choose more weights and you can shape it far more sharply. That is what designing a filter means: pick the curve you want, and find the weights that give it.
Gain and phase
So far we have mostly drawn the gain. But remember the second change, timing. A shift in timing is a shift in the starting point, and we know that name from lesson 2: phase.
Our two-number average delays every frequency by the same half a step, so a signal just arrives a little late. Other systems delay different frequencies by different amounts, and that can reshape a signal even when no height changes.
So the complete frequency response has two parts: the gain graph we drew, and a phase graph beside it. For our strip the phase is
a straight line, which is exactly what an equal delay looks like.
The average’s phase: a straight line from 0 down to −π/2. Every frequency arrives the same half a step late.
Frequency response in real life
- The sliders on your phone are called an equaliser. Each slider sets the gain of one slice of frequencies. Drag them, and you are drawing a frequency response with your finger.
- Headphone reviews print this very curve. “Bass-heavy” simply means the gain is higher at the low frequencies.
- An old-style phone call keeps only about 300 to 3,400 Hz. It lets through a slice in the middle, which is why voices on those calls sound so thin.
Three common mistakes
Recap
- A sine wave going into a linear, time-invariant system comes out as a sine wave of the same frequency. Only its height and timing change.
- The frequency response lists those changes for every frequency: the gain and the phase.
- Averaging keeps slow waves because neighbours agree, and cancels fast ones because they do not: , a low-pass filter. The difference does the opposite: a high-pass filter.
- Mix them, and each ingredient goes through with its own gain. That is why the bass gets through the wall.
Say it aloud once: same frequency, new height, new timing.
Next, lesson 7 finds one neat way to store a height and a timing in a single number. It is called a complex number, and it is really just an arrow on a page.
Interactive lab
The wall in numbers
Send one sine wave at a time through a two-number strip. Watch its height change while its rhythm never does, flip the strip to keep the highs instead, and hear a hum and a hiss go through.
Sign in to open the lab
It is free. Signing in with Google also keeps your progress and your scores.
Sign in with GoogleLesson 1 of every course is open without signing in.
Check yourself
Did it stick?
Work each one out on paper first. Every question has a full worked answer.
- 1
A 440 Hz sine wave goes into a linear, time-invariant system. What frequency comes out?
Worked answer
440 Hz. A linear, time-invariant system can only change a sine wave’s height and timing. It can never change its frequency, so a 440 Hz wave comes out as a 440 Hz wave.
- 2
A sine wave of height 5 goes in, and a sine wave of height 2 comes out. What is the gain?
Worked answer
- 3
The averaging strip is ½, ½. The input is 8, 0, 8, 0. What comes out (once two numbers have arrived)?
Worked answer
Average each number with the one before it: , , . So 4, 4, 4.
Another way to see it: the input is a steady 4 plus the fastest wiggle, 4 up and 4 down. The steady part has gain 1 and comes through; the fastest wiggle has gain 0 and vanishes.
- 4
Numbers arrive 6,000 times a second and the averaging strip has gain ½ at 2,000 Hz. A sine wave of height 10 goes in at 2,000 Hz. What height comes out?
Worked answer
Height out = gain × height in = . It is still a 2,000 Hz sine wave: only its height (and timing) changed.
The ½ comes from the formula: , and .
- 5
A frequency response starts at 0 on the left and rises to 1 on the right. What does this filter do to a deep hum?
Worked answer
A deep hum is a low frequency, so it sits on the left of the graph, where the gain is close to 0. Most of it is removed. A filter that keeps the high frequencies and drops the low ones is a high-pass filter, like the difference strip . It never changes the hum into a different note.
Sign in to open the checks
It is free. Signing in with Google also keeps your progress and your scores.
Sign in with GoogleLesson 1 of every course is open without signing in.
Was this lesson clear?
Free weekly email
Get the next lesson by email.
The week's new lessons, the daily facts in one place, one thing to try in the lab and one puzzle. Free.
No spam. One click to leave.