0% found this document useful (0 votes)
24 views9 pages

Final DSP

This document describes a digital signal processing project to implement a digital hearing aid using MATLAB. The hearing aid filters noise from an audio signal using a 4th order Butterworth filter and then enhances the filtered output using a peaking equalizer. The methodology loads a noisy audio file, applies the Butterworth filter in the frequency domain to remove noise, then uses an equalizer to boost specific frequency bands. Plots of the fast Fourier transforms show the effects of filtering and equalization on the signal. The conclusion is that digital hearing aids can improve hearing by filtering noise and enhancing the audio quality.

Uploaded by

hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views9 pages

Final DSP

This document describes a digital signal processing project to implement a digital hearing aid using MATLAB. The hearing aid filters noise from an audio signal using a 4th order Butterworth filter and then enhances the filtered output using a peaking equalizer. The methodology loads a noisy audio file, applies the Butterworth filter in the frequency domain to remove noise, then uses an equalizer to boost specific frequency bands. Plots of the fast Fourier transforms show the effects of filtering and equalization on the signal. The conclusion is that digital hearing aids can improve hearing by filtering noise and enhancing the audio quality.

Uploaded by

hello
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

DSP PROJECT

By:
204146 Mayank Singh Bisht
204168 S Sashank Bhamidipati

Course
Digital Signal Processing

Guided by: Dr. J.RAVI KUMAR

Year
B.Tech III ECE
OBJECTIVE
To understand the working of a digital hearing aid that filters noise and then enhances
the filtered output by an audio equalizer, using MATLAB.

INTRODUCTION
Digital hearing aids are used to improve the hearing ability of people with hearing
impairments. They are designed to filter out unwanted noise and enhance the audio
signals to make them more audible. In this project, we aim to implement a digital
hearing aid that filters out noise and enhances the audio signal using MATLAB.

THEORY
Digital hearing aids are electronic devices that help people with hearing impairments
by amplifying the sound and improving their ability to hear. The devices consist of a
microphone, a signal processing unit, an amplifier, and a speaker. The microphone
captures the sound and converts it into an electrical signal. The signal processing unit
then filters the electrical signal to remove unwanted noise and enhances it to improve
the audio quality. The amplified signal is then sent to the speaker, which converts the
electrical signal back into sound that the user can hear.
Filtering: In this project, we focus on filtering the electrical signal using a 4th-order
Butterworth filter. A 4th order Butterworth filter is a type of low-pass filter that allows
low-frequency signals to pass through while attenuating high-frequency signals. This
filter has a slope of 24 dB per octave (80 dB per decade) and a cut-off frequency at
which the power of the signal is attenuated to half its maximum value (-3 dB point). In
a 4th order Butterworth LPF, the filter response rolls off at a rate of 24 dB per octave
beyond the cut-off frequency, which is a relatively steep roll off compared to low-
order filters. This results in a narrower transition band, which is the range of
frequencies between the passband and the stopband where the filter response is
changing. The cutoff frequency of the filter determines the frequency at which the
filter starts to attenuate the signal. The Butterworth filter is designed using the
frequency domain approach, where the filter coefficients are calculated in the
frequency domain and then transformed back to the time domain using an inverse
Fourier transform.
Equalization: Equalization is the process of adjusting the frequency response of a
signal to achieve a desired sound quality. In this project, we use a peaking equalizer to
boost the amplitude of a specific frequency band. The peaking equalizer consists of a
bandpass filter and a gain stage. The bandpass filter selects a specific frequency band,
and the gain stage amplifies the selected band by a specified amount. The center
frequency of the bandpass filter determines the frequency band to be boosted, and the
bandwidth determines the range of frequencies around the center frequency to be
affected. The gain adjustment in dB determines the amount of amplification to be
applied to the selected frequency band.

METHODOLOGY
The project consists of two major parts - filtering and equalization. The first step
involves loading the noisy audio recording and specifying filter parameters such as
order and cut-off frequency. We then convert the cut-off frequency to the normalized
frequency range, perform FFT on the input signal, and design Butterworth filter
coefficients in the frequency domain. The filter is then applied in the frequency
domain by multiplying the FFT of the input signal with the filter coefficients. The
filtered signal is obtained by performing inverse FFT and extracting the real part of
the filtered signal.
In the second step, we define equalizer parameters such as center frequency,
bandwidth, and gain adjustment in dB. We then create the equalizer filter coefficients
using a function that calculates the numerator and denominator coefficients. The filter
coefficients are then normalized, and the equalizer is applied to the filtered signal
using MATLAB's built-in filter function.

FLOW CHART OF THE CODE


BLOCK DIAGRAM

Block Diagram of Equalizer.


PROCEDURE
1. Load the noisy audio signal into MATLAB using the audioread() function. The signal
is stored as an array 'x', and the sampling frequency is stored in 'fs'.
2. Specify the parameters for the Butterworth filter: the order of the filter and the
cut-off frequency.
3. Convert the cut-off frequency to the normalized frequency range [0, 1] by dividing
it by half the sampling frequency.
4. Perform the fast Fourier transform (FFT) on the input signal 'x' using the fft()
function. This produces a complex-valued frequency spectrum 'X' of the signal.
5. Design the Butterworth filter coefficients in the frequency domain. This is done by
creating an array of the same length as the FFT output, where each value is a function
of the frequency at that bin. The function used is based on the Butterworth filter,
which is a type of low-pass filter that has a flat frequency response in the passband
and a rapid roll-off in the stopband.
6. Apply the filter in the frequency domain by multiplying the FFT of the input signal
by the filter coefficients. This produces a complex-valued frequency spectrum 'Y' of
the filtered signal.
7. Obtain the filtered signal by performing the inverse FFT on the filtered spectrum
using the ifft() function. This produces a complex-valued time-domain signal 'y'.
8. Extract the real part of the filtered signal to remove any imaginary components
using the real() function.
9. Define the parameters for the equalizer: the center frequency, bandwidth, and gain
adjustment in decibels.
10. Create the equalizer filter coefficients using the equalizerCoefficients() function,
which generates the numerator and denominator coefficients for a second-order
infinite impulse response (IIR) filter based on the given parameters.
11. Apply the equalizer to the filtered signal using the filter() function. This produces
the enhanced signal.
12. Plot the FFT of the unfiltered signal, the FFT of the filtered signal, and the FFT of
the enhanced signal using the subplot() and plot() functions.
13. Save the enhanced speech signal to a new file using the audiowrite() function.
14. Play the unfiltered sound using the sound() function.
15. Pause for the duration of the unfiltered sound using the pause() function.
16. Play the enhanced sound using the sound() function.

MATLAB Code
% Load the noisy recording
[x, fs] = audioread('speech_n.wav');

% Specify filter parameters


order = 4; % Filter order
cutoffFreq = 1000; % Cutoff frequency in Hz

% Convert cutoff frequency to the normalized frequency range [0, 1]


normalizedCutoff = cutoffFreq / (fs / 2);

% Perform FFT on the input signal


X = fft(x);

Butterworth filter Parameters


% Design Butterworth filter coefficients in the frequency domain
n = length(x); % Length of the input signal
frequencies = (0:n-1) / n * fs; % Frequencies corresponding to each FFT bin
filterCoeffs = 1 ./ (1 + (frequencies ./ cutoffFreq).^(2*order));

% Apply the filter in the frequency domain


Y = X .* filterCoeffs';

% Obtain the filtered signal by performing inverse FFT


y = ifft(Y);

% Extract the real part of the filtered signal


y = real(y);
y=10*y;
% Define equalizer parameters
centerFreq = 125; % Center frequency in Hz
bandwidth = 50; % Bandwidth in Hz
gain = 6; % Gain adjustment in dB

% Create the equalizer filter coefficients


[b, a] = equalizerCoefficients(centerFreq, bandwidth, gain, fs);

% Apply the equalizer to the filtered signal


enhanced_signal = filter(b, a, y);

% Plot the FFT of the unfiltered signal


figure;
subplot(3, 1, 1);
plot(frequencies, abs(X));
title('FFT of Unfiltered Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');

% Plot the FFT of the filtered signal


subplot(3, 1, 2);
Y_filtered = fft(y);
plot(frequencies, abs(Y_filtered));
title('FFT of Filtered Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');

% Plot the FFT of the enhanced signal


subplot(3, 1, 3);
Enhanced_filtered = fft(enhanced_signal);
plot(frequencies, abs(Enhanced_filtered));
title('FFT of Enhanced Signal');
xlabel('Frequency (Hz)');
ylabel('Magnitude');

% Save the enhanced speech signal to a new file


audiowrite('enhanced_speech.wav', enhanced_signal, fs);

% Play the unfiltered sound


sound(x, fs);

% Pause for the duration of the unfiltered sound


pause(numel(x) / fs);

% Play the enhanced sound


sound(enhanced_signal, fs);

Equalizer function
% Function to design equalizer filter coefficients
function [b, a] = equalizerCoefficients(centerFreq, bandwidth, gain, fs)
% Convert the center frequency and bandwidth to radians per sample
wc = 2 * pi * centerFreq / fs;
wb = 2 * pi * bandwidth / fs;

% Calculate the numerator and denominator coefficients


K = tan(wb / 2);
V0 = 10^(gain / 20);
b0 = 1 + K / V0;
b1 = -2 * cos(wc);
b2 = 1 - K / V0;
a0 = 1 + K * V0;
a1 = -2 * cos(wc);
a2 = 1 - K * V0;

% Normalize the coefficients


b = [b0, b1, b2] / a0;
a = [a0, a1, a2] / a0;
end
OUTPUT
FFT Plots of the input and output signal

Power Spectral Density (PSD) of unfiltered, filtered and enhanced signal


Input Audio (NOISY SIGNAL)

speech_n.wav

Output Audio (FILTERED SIGNAL)

enhanced_speech.wav

CONCLUSION
In conclusion, digital hearing aids are essential devices that help people with hearing
impairments to improve their hearing ability. In this project, we implemented a digital
hearing aid using MATLAB, which filters out unwanted noise using a Butterworth
filter and enhances the audio signal using a peaking equalizer. The results indicate that
the audio quality has improved after filtering and equalization. The project can be
extended further by implementing real-time processing and exploring different types
of filters and equalizers to achieve better audio quality.

You might also like