← Back to list

A Practical Approach to Denoising Sound

Using Fourier transforms to separate signal from noise

sandoh · 2026-06-16 16:41 · 6 claps · 4.9 min read
#audio-signal-processing #signal-processing
Open on Medium ↗
Wiki topics: 🎵 · Music & Audio

A Practical Approach to Denoising Sound

Using Fourier transforms to separate signal from noise

If you have ever tried to record yourself for a YouTube video, a podcast, or a voice note you actually wanted to keep, you know the problem. You hit record, you say what you want to say, you play it back. And underneath your voice, there it is: the hum of the fan, the street outside, someone’s music bleeding through the wall. The recording is ruined, and no amount of re-recording seems to fix it because the noise was always there. You just did not notice it until the microphone did.

This was the kind of situation I found myself in at AIMS Rwanda, one evening when our Signal Processing lecturer, Professor Paul Taylor of the National Institute of Mental Health, played us a recording of lions. Real lions, recorded in the field, buried under background noise. The assignment was simple: clean it up. No audio software. Just mathematics. It was one of those rare moments where mathematics stopped feeling abstract. I was not solving for x. I was listening to the difference between before and after, and the difference was audible.

This article is about how that works, what the mathematics actually says, why it gives you a way to separate sound from noise, and what the Fourier transform has to do with any of it.

Think about what sound actually is. When a lion roars, it disturbs the air around it. That disturbance travels outward, reaches your ears, and you hear something. A microphone does the same thing your ear does: it picks up those disturbances and records how strong they are at each moment in time.

Plot that and you get a waveform. Time on one axis, amplitude on the other.

Here is what the lions recording looks like:

Figure 1: Waveform of the lions recording. The horizontal axis is time in seconds, the vertical axis is amplitude. The background cricket noise is visible throughout, even in the quieter moments between lion sounds.

Figure 1: Waveform of the lions recording. The horizontal axis is time in seconds, the vertical axis is amplitude. The background cricket noise is visible throughout, even in the quieter moments between lion sounds.

You can already see something is wrong. Even in the quiet moments, the signal is not flat. There is always something there. That is the crickets, a background noise that never goes away.

The frustrating thing is that just looking at this picture, you cannot tell the lions apart from the crickets. They are all mixed together in the same plot, at the same time. To separate them, you need to stop thinking about time altogether.

This is the fundamental limitation of the time domain. When multiple sounds are recorded together, their amplitudes add up at every point in time. There is no way to untangle them without more information.

What you need is a way to ask a different question. Instead of asking “how loud is the signal at each moment in time,” you want to ask “what frequencies make up this signal, and how strong is each one?”

That is exactly what the Fourier transform does.

Every sound you have ever heard is made up of pure frequencies added together. The low hum of a fan is one frequency. The high pitch of a cricket is another. A lion’s roar is a combination of many. Even the most complex sound is just a sum of simpler ones, each with its own frequency and strength.

The Fourier transform takes your signal and asks: what are those frequencies, and how much of each one is present? Instead of plotting amplitude against time, it plots amplitude against frequency. That new plot is called the frequency spectrum.

Here is what the lions recording looks like in the frequency domain:

Figure 2: Frequency spectrum of the lions recording, obtained by applying the Fourier transform. The horizontal axis is frequency in Hz, the vertical axis is magnitude (the absolute value of each frequency coefficient). The concentrated spikes near the centre correspond to the dominant frequency components in the recording.

Figure 2: Frequency spectrum of the lions recording, obtained by applying the Fourier transform. The horizontal axis is frequency in Hz, the vertical axis is magnitude (the absolute value of each frequency coefficient). The concentrated spikes near the centre correspond to the dominant frequency components in the recording.

Now that we can see the signal in the frequency domain, we can do something we could not do before: we can choose which frequencies to keep and which to remove.

The idea is simple. We create a filter, an array of the same length as our signal, filled with zeros everywhere except in the low frequency range, where we set it to 1. When we multiply our Fourier transform by this filter, only the frequencies we marked with a 1 survive. Everything else gets zeroed out.

This is called a low pass filter. It lets the low frequencies pass through and blocks the high ones.

In code, it looks like this:

H = np.zeros(N)
H[0:N//30] = 1
C = X * H

Here, X is the Fourier transform of our signal, the array of frequency coefficients behind Figure 2, one value for every frequency present in the recording. H is the filter, and C is the filtered result, still living in the frequency domain.

We are keeping only the first 1/30th of the frequency range. Everything beyond that gets set to zero.

The result, C, is our filtered signal, still in the frequency domain. The lion sounds, which are concentrated in the low frequencies, are largely preserved. The cricket noise, which was spread across the higher frequencies, is largely gone.

Now we need to bring it back to time.

To get back to something we can actually hear, we apply the inverse Fourier transform.

If the Fourier transform takes a signal from time to frequency, the inverse does the opposite: it takes a signal from frequency back to time. You give it the filtered frequency spectrum, and it reconstructs a waveform.

In code, this is one line:

new_x = np.fft.ifft(C)

What comes back is a new time series, a waveform that contains only the frequencies we chose to keep. Here is what the original and the cleaned signal look like side by side:

Figure 3: Raw signal (blue) and processed signal (orange) plotted together. The processed signal is visibly smoother, with the background noise reduced while the main lion sounds are preserved.

Figure 3: Raw signal (blue) and processed signal (orange) plotted together. The processed signal is visibly smoother, with the background noise reduced while the main lion sounds are preserved.

The difference is visible. The processed signal is smoother, the constant background activity reduced. What remains is closer to the lions alone.

But the real test is not visual. It is audible. When you play back the cleaned recording, you can actually hear the difference. The crickets are quieter. The lions are clearer.

That is the Fourier transform at work.

There is something satisfying about this that goes beyond the result.

You started with a recording that was ruined by noise. You could hear the problem but you could not see it, and you certainly could not fix it just by staring at the waveform. The noise and the signal were tangled together in time, and time gave you no way to separate them.

The Fourier transform gave you a different perspective. Not better data, just a different way of looking at the same data. And from that perspective, the solution became obvious.

This is what mathematics does at its best. It does not always give you new information. Sometimes it just gives you the right way to look at the information you already have.

The lions were always there. You just needed the right lens to find them.

Audio source The lion recording used here comes from BBC Sound Effects and is free for non-commercial use.

To follow along, download the file from that link and place it in audio/ (or whichever folder you're working from). Not for commercial use.

The jupyter notebook with the code can be found here.


메타데이터
post_id
5422beebeb74
slug
a-practical-approach-to-denoising-sound-5422beebeb74
url
https://medium.com/@pearlsandoh/a-practical-approach-to-denoising-sound-5422beebeb74
canonical_url
https://medium.com/@pearlsandoh/a-practical-approach-to-denoising-sound-5422beebeb74
author_url
https://medium.com/@pearlsandoh
status
ok
fetched_at
2026-08-28 07:53:33