Project Title:
To Design And Implement Digital Noise Cancellation System for Speech Signal
Enhancement.
Problem Statement:
Develop and implement a digital noise cancellation system using MATLAB to mitigate
background audio noise, (such as traffic noise or continuous frequency tones), from a
given speech signal while simulating the acoustic characteristics of an
auditorium/lecture hall environment.
Project deliverables:
1. A report in word format and its printout containing mentioning entire process of execution. The
report should contain MATLAB code / simulation.
2. Input audio file (With Noise) and output audio file (Filtered Signal).
Abstract:
This project explores the design and implementation of digital noise cancellation system
using MATLAB to mitigate background audio noise, from a given speech signal while
simulating the acoustic characteristics of an auditorium/lecture hall environment. The
project addresses the challenge of isolating the voice from noise. To tackle this, a high-
pass filter was first applied to remove low-frequency noise, and the resulting output was
passed through a low-pass filter to target remaining high-frequency noise. This dual-
filter approach effectively preserved speech quality while minimizing background noise,
providing a clear and intelligible output. The solution simulates an auditorium ambiance,
enhancing the listener's experience.
Task identifications:
Record Voice In Noisy Environment:
The Initial Audio Recording Was Performed Using A Mobile Phone In A Controlled
Noisy Environment With Traffic Noise Playing In The Background. The Recording Was
Then Transferred To A Computer, Where It Was Converted From ACC To WAV Format
To Ensure Compatibility With MATLAB's Signal Processing Tools.
Upload Voice On MATLAB:
After converting the audio file to WAV format, it was uploaded to MATLAB for
processing. This step enabled access to MATLAB’s extensive signal processing tools,
allowing for the implementation of filters to remove background noise and enhance the
voice signal’s clarity."
Fourier transform analysis of noisy signal:
Noise identification: If there’s significant amplitude in the very low frequencies (below 100 Hz) or
higher frequencies (above 4000 Hz), it could represent background noise or non-voice artifacts,
especially since traffic noise was present during the recording. The low-pass filter would help to
reduce such noise if it's beyond the vocal range.
Selection of cutoff frequencies for designing filters:
To effectively reduce noise in voice recording while preserving voice clarity, we choose
cutoff frequencies based on typical human voice frequency ranges and the
characteristics of the background noise by hit and trial different values of cutoff
frequency. Here are general recommendations:
For highpass cutoff frequency:
o Set the cutoff frequency around 200 Hz.
o This range helps to remove low-frequency noise, such as rumbles while
preserving the fundamental frequencies of the human voice. Frequencies
below 200 Hz are typically not crucial for intelligibility in voice recordings
and are more likely to contain non-voice noise
For lowpass cutoff frequency:.
o Set the cutoff frequency around 3000-4000 Hz.
o Most of the essential voice content lies below 4000 Hz. This low-pass filter
cutoff helps to reduce high-frequency noise, such as hissing or other
background sounds, without affecting the clarity of your speech.
Now we design filters for noise cancellation :
Selection of Filters for Noise Reduction:
1:Design Highpass filter:
The first step in the processing chain is to apply a high-pass filter with a cutoff
frequency of 200 Hz. This filter is chosen to remove low-frequency noise (e.g., rumble
that typically occur at lower frequencies) from the recorded audio. By using a second-
order Butterworth high-pass filter, we ensure a smooth transition at the cutoff
frequency, minimizing any distortion to the original audio content above the cutoff. The
choice of 200 Hz as the cutoff frequency is based on the assumption that most
unwanted low-frequency noise in the audio lies below this threshold. The filter's second-
order design allows for a steeper roll-off compared to a first-order filter, enhancing noise
removal.
2:Design lowpass filter:
A low-pass filter is a filter that passes signals with a frequency lower than a selected cutoff
frequency and attenuates signals with frequencies higher than the cutoff frequency. The
exact frequency response of the filter depends on the filter design. The filter is sometimes called
a high-cut filter, or treble-cut filter in audio applications. A low-pass filter is the complement of
a high-pass filter.
Implementation of difference equation :
In discrete-time systems, the digital filter is often implemented by converting
the transfer function to a linear constant-coefficient difference equation (LCCD) via
the Z-transform. The discrete frequency-domain transfer function is written as the
ratio of two polynomials. For example: low pass filter is described by difference
equation is given by:
y(n)= -∑𝑁 𝑀
𝑘=1 𝑎𝑘 𝑦(𝑛 − 𝑘) + ∑𝑘=0 𝑏𝑘 𝑥(𝑛 − 𝑘)
and its frequency response is
Here we create difference equation of high pass filter:
audioHighPassed(n) = -a_hp(2) * audioHighPassed(n-1) - a_hp(3) * audioHighPassed(n-2)+ b_hp(1) *
audioIn(n) + b_hp(2) * audioIn(n-1) + b_hp(3) * audioIn(n-1)
y= the output, or filtered value
x=the input, or incoming raw value
n= the sample number, iteration number, or time period number
and therefore:
y(n)= the current filtered (output) value (audio High Passed(n))
y(n-1)= the last filtered (output) value (audio High Passed(n-1))
y(n-2)= the 2nd to last filtered (output) value (audio High Passed(n-2))
x(n)= the current (input) value (audio In(n))
x(n-1)= the last (input) value (audio In(n-1))
nd
x(n-1)= the 2 to last (input) value (audio In(n-2))
Here we create difference equation of lowpass filter:
audioFiltered (n) = -a_lp(2) * audioFiltered (n-1) - a_lp(3) * audioFiltered(n-2)+ b_lp(1) *
audioHighPassed (n) + b_lp(2) * audioHighPassed (n-1) + b_hp(3) * audioHighPassed (n-1)
here output of high pass act as an input of low pass filter
y= the output, or filtered value
x=the input, or incoming raw value
n= the sample number, iteration number, or time period number
and therefore:
y(n)= the current filtered (output) value (audio Filtered(n))
y(n-1)= the last filtered (output) value (audio Filtered (n-1))
y(n-2)= the 2nd to last filtered (output) value (audio Filtered (n-2))
x(n)= the current (input) value (audio high passed(n))
x(n-1)= the last (input) value (audio high passes(n-1))
x(n-1)= the 2nd to last (input) value (audio high passed(n-2))
here is block diagram implementation of above difference equation:
Reverberation Effect for Auditorium Ambiance:
To create the feeling of being in an auditorium or lecture hall, we added several
delayed versions of the filtered audio signal, each with different delay times and lower
volume levels. This technique creates a reverberation effect, which makes the audio
sound an ambience of lecture hall, as if you’re hearing it in a large hall.*Each delayed
signal is made quieter to imitate the natural way sound fades in an auditorium. This
adds depth and richness to the sound, enhancing the listening experience while
keeping the speech clear and understandable.*(chtgpt)
Plot and save filtered audio file
To visualize the effectiveness of the noise reduction and auditorium effect, the
original, filtered, and reverberated signals were plotted in MATLAB. These plots
clearly illustrate the progression from noisy to clean, reverberated audio.
RESULTS:
HIGH PASS FILTER RESPONSE:
LOW PASS FILTER RESPONSE:
NOISY SIGNAL:
AUDIO OF 5 SEC
AUDIO OF 2 MINS:
NOISE REDUCED SIGNAL:
AUDIO OF 5 SEC :
AUDIO OF 2 MIN:
REVERBERATED SIGNAL:
AUDIO OF 5 SEC :
AUDIO OF 2 MIN:
Conclusion:
Appendices:
Low pass frequency response:
% High-pass filter settings
lowpassCutoff = 3000; % Cutoff frequency in Hz
[b_lp, a_lp] = butter(2, lowpassCutoff / (fs / 2), 'low');
% Frequency response
[H, f] = freqz(b_lp, a_lp, 1024, fs);
% Plot the frequency response
figure;
plot(f, abs(H));
title('low-Pass Filter Frequency Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
xlim([0 2000]); % Limit x-axis to 2000 Hz for better visualization
high pass frequency response:
[audioIn, fs] = audioread('noise audio.wav');
% High-pass filter settings
highpassCutoff = 200; % Cutoff frequency in Hz
[b_hp, a_hp] = butter(2, highpassCutoff / (fs / 2), 'high');
% Frequency response
[H, f] = freqz(b_hp, a_hp, 1024, fs);
% Plot the frequency response
figure;
plot(f, abs(H));
title('High-Pass Filter Frequency Response');
xlabel('Frequency (Hz)');
ylabel('Magnitude');
grid on;
xlim([0 2000]); % Limit x-axis to 2000 Hz for better visualization
noise cancellation with ambience of auditorium:
[audioIn, fs] = audioread('noise audio.wav');
highpassCutoff = 200;
[b_hp, a_hp] = butter(2, highpassCutoff / (fs / 2), 'high');
N = length(audioIn);
audioHighPassed = zeros(N, 1); % Initialize high-pass output
for n = 3:N
audioHighPassed(n) = -a_hp(2) * audioHighPassed(n-1) - a_hp(3) *
audioHighPassed(n-2) ...
+ b_hp(1) * audioIn(n) + b_hp(2) * audioIn(n-1) +
b_hp(3) * audioIn(n-1);
end
lowpassCutoff = 3000;
[b_lp, a_lp] = butter(2, lowpassCutoff / (fs / 2), 'low');
audioFiltered = zeros(N, 1); % Initialize low-pass output
for n = 3:N
audioFiltered(n) = -a_lp(2) * audioFiltered(n-1) - a_lp(3) *
audioFiltered(n-2) ...
+ b_lp(1) * audioHighPassed(n) + b_lp(2) *
audioHighPassed(n-1) + b_lp(3) * audioHighPassed(n-2);
end
delayTimes = [0.3, 0.6, 0.9, 1.2]; % Delays in seconds
attenuationFactors = [0.5, 0.3, 0.2, 0.1]; % Attenuation for each delay
audioReverb = audioFiltered;
for i = 1:length(delayTimes)
delaySamples = round(delayTimes(i) * fs); % Convert delay time to samples
delayedSignal = zeros(N, 1); % Initialize delayed signal
% Apply delay and attenuation using a difference equation
for n = (delaySamples + 1):N
delayedSignal(n) = audioReverb(n - delaySamples) *
attenuationFactors(i);
end
% Add delayed signal to the original
audioReverb = audioReverb + delayedSignal;
end
% Normalize the reverberated signal to avoid clipping
audioReverb = audioReverb / max(abs(audioReverb));
audioFiltered = audioFiltered / max(abs(audioFiltered));
% Plotting the results
t = (0:length(audioIn)-1) / fs;
figure;
% Original Noisy Signal
subplot(3,1,1);
plot(t, audioIn);
title('Original Noisy Signal');
xlabel('Time (s)');
ylabel('Amplitude');
% Noise-Reduced Signal (Filtered Only)
subplot(3,1,2);
plot(t, audioFiltered);
title('Noise-Reduced Signal (Filtered Only)');
xlabel('Time (s)');
ylabel('Amplitude');
% Reverberated Signal (Auditorium Effect)
subplot(3,1,3);
plot(t, audioReverb);
title('Reverberated Signal (Auditorium Effect)');
xlabel('Time (s)');
ylabel('Amplitude');
% Play the original, filtered, and reverberated signals for comparison
disp('Playing Original Noisy Signal...');
soundsc(audioIn, fs); % Play original audio
pause(2);
audiowrite('C:\Users\HAROON TRADERS\Downloads\Original Noisy Signal.wav',
audioIn, fs);
disp('Playing Noise-Reduced Signal...');
soundsc(audioFiltered, fs); % Play noise-reduced audio
pause(2);
audiowrite('C:\Users\HAROON TRADERS\Downloads\noise-reduced audio.wav',
audioFiltered, fs);
% Save the processed audio to a file
audiowrite('C:\Users\HAROON TRADERS\Downloads\filtered_audio_with_reverb.wav',
audioReverb, fs);
%Play the reverberated audio
disp('Playing Reverberated Signal with Auditorium Effect...');
soundsc(audioReverb, fs);
% Display completion message
disp('Processing complete. Filtered and reverberated audio saved as
"filtered_audio_with_reverb.wav".');
audio files :
Original Noisy Signal.wav
noise-reduced audio.wav
filtered_audio_with_reverb.wav