Digital Signal Procesing Lab Complex Engineering Design Submitted TO Mam Rida Maamoor BY
Digital Signal Procesing Lab Complex Engineering Design Submitted TO Mam Rida Maamoor BY
Digital Signal Procesing Lab Complex Engineering Design Submitted TO Mam Rida Maamoor BY
Spring 2023
Acknowledgement
First of all thanks to ALLAH Almighty who gives us the courage and His blessings to do
this project. Without His blessings nothing is possible. Allah is very towards us throughout
the project.
I am thankful to Mam Rida for providing me the opportunity to work on this Project and
provide me the technical and moral support during the project.
1
Abstract
In this project, we aim to design a digital filter for analyzing the spectral dynamics of
a real-time voice signal using signal processing techniques. The project will leverage the
background knowledge and available resources for signal processing to develop a filter that
effectively captures changes in the spectral content of the voice signal. The filter will
enable us to examine the frequency distribution and composition of the voice signal in real-
time. Ultimately, the project goal is to develop a tool that can be applied in a variety
of scenarios where the analysis of real-time voice signals is required, such as in speech
recognition, voice authentication, and emotion detection. The proposed approach holds
promise for providing more accurate and reliable results than existing methods while also
offering greater computational efficiency.
2
Contents
1 Introduction 5
1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Aim Of The Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.3 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2 Filters 7
2.1 Digital Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 FIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.2 IIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.3 CIC Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2 Design Criteria . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.1 Magnitude Response . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.2 Phase Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.3 Ripple . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.4 Group Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.2.5 Transition Region . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.6 Stop Band Attenuation . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2.7 Computational Complexity . . . . . . . . . . . . . . . . . . . . . . . 9
3 Procedure 10
3.1 Procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4 Software Implementation 11
4.1 MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.1 MATLAB Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.2 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Using App Designer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2.1 Code View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.2.2 Result . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3
5 Conclusion 17
5.1 Reason For Finding Energy Spectrum . . . . . . . . . . . . . . . . . . . . . 17
5.2 Reason For Using Low Pass Filter . . . . . . . . . . . . . . . . . . . . . . . 17
5.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5.4 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4
Chapter 1
Introduction
1.1 Introduction
Audio signal processing is the science of manipulating sound waves to achieve a desired
outcome or effect. It involves the use of specialized algorithms and techniques to modify,
filter, and analyze audio signals. In MATLAB, audio signal processing can be performed
using various built-in features and toolboxes, such as the Audio System Toolbox and the
Signal Processing Toolbox. These tools provide functions for tasks such as audio playback,
audio recording, filtering, compression, and visualization. Additionally, MATLAB also
supports the use of external audio hardware, such as microphones and speakers, to interact
with audio signals in real-time. By using MATLAB for audio signal processing, researchers
and engineers can develop advanced audio applications, analyze audio data, and optimize
audio systems for improved performance.
5
1.3 Block Diagram
6
Chapter 2
Filters
7
output signal is a function of not only the current input sample, but also of past input
samples.
The IIR filter can be implemented using difference equations, which are based on the
principles of linear time-invariant systems. In contrast to finite impulse response (FIR)
filters, which have a finite duration of their impulse response, IIR filters have an impulse
response that goes on indefinitely. This makes them more versatile and efficient in certain
applications.
2.2.3 Ripple
This is the amount of variation or fluctuations in the frequency response of the filter. The
smaller the ripple, the better the filter.
8
2.2.5 Transition Region
This is the range of frequencies in which the filter transitions from pass band to stop band.
The ideal filter should have a narrow transition region to minimize unwanted attenuation
and phase shifts.
9
Chapter 3
Procedure
3.1 Procedure
These are the following steps we follow:
1. First we record the sample voice signal in real-time using a microphone.
2. Use the ’audiorecord’ function in MATLAB to record the audio signal. Set the
parameters such as sample rate, duration of recording, and number of channels.
3. Analyze the time domain of the recorded audio signal using the ’plot’ function in
MATLAB. Plot the amplitude of the signal as a function of time.
4. Calculate the energy spectrum of the recorded audio signal using the ’fft’ function in
MATLAB . Convert the signal to the frequency domain and plot the signal over a range of
frequencies.
5. Apply a low pass filter to the audio signal using the ’filter’ function in MATLAB.
Determine the cutoff frequency of the filter and design the filter using the ’fir1’ function in
MATLAB.
6. Filter the audio signal with the designed low pass filter using the ’filter’ function in
MATLAB.
7. Plot the filtered audio signal in the time domain using the ’plot’ function in MATLAB.
Compare it with the original signal to see the effect of the low pass filter.
8. Calculate the energy spectrum of the filtered audio signal using the ’fft’ function in
MATLAB. Convert the signal to the frequency domain and plot the signal over a range of
frequencies to see the effect of the low pass filter on the spectrum.
10
Chapter 4
Software Implementation
4.1 MATLAB
All of the program and all of the code was written in Mathworks Matlab 2021a.Matlab
(short for ”Matrix Laboratory”) is a programming language and numerical computing en-
vironment developed by MathWorks. It is used for a wide range of applications, including
engineering and scientific computations, data analysis and visualization, and algorithm de-
velopment. Matlab provides an extensive library of built-in functions for performing various
computations, as well as an interactive development environment for writing and debug-
ging code. It also supports various data types, including matrices, arrays, and structures,
which enable users to manipulate complex data sets with ease. Matlab is widely used in
academia and industry for research and development, and is considered to be one of the
leading software packages for numerical computation.
11
plot(t,X)
title(’Audio signal’)
xlabel(’Time(sec)’)
ylabel(’Amplitude’)
subplot(322)
plot(f,Y)
title(’FFT of audio signal’)
xlabel(’Frequency(hz)’)
ylabel(’Magnitude’)
win = hamming(N); % Window function
E = abs(fft(win.*X)).^2/N; % Compute energy spectrum
% Plot energy spectrum
subplot(323)
plot(f,E); % Plot energy spectrum
title(’Energy Spectrum of Speech Signal’);
xlabel(’Frequency (Hz)’);
ylabel(’Energy (dB)’);
% Apply Low-Pass Filter with Cutoff Frequency of 3000 Hz
b = fir1(100,3000/(Fs/2));
y = filter(b,1,X);
% Plot Filtered Signal and Spectrum
subplot(324), plot(t,y)
xlabel(’Time (s)’)
ylabel(’Amplitude’)
title(’Filtered Speech Signal’)
Y1 = fft(y);
E = abs(fft(win.*Y1)).^2/N; % Compute energy spectrum
% Plot energy spectrum
subplot(325);
freq1 = 0:Fs/length(E):Fs/2;
plot(freq1,10*log10(E(1:length(freq1))))
% Plot energy spectrum
title(’Energy Spectrum of filtered speech signal Speech Signal’);
xlabel(’Frequency (Hz)’);
ylabel(’Energy (dB)’);
figure;
cwt(X,Fs)
figure;
cwt(y,Fs)
12
4.1.2 Results
13
Figure 1.5: Wavelet Transform of Filtered signal
14
Stop Button
Clear Button
15
4.2.2 Result
16
Chapter 5
Conclusion
5.3 Conclusion
In summary, by using the principles of signal processing, we can design a digital filter for
the analysis of spectral dynamics in real-time voice signals. The filter should extract the
spectral dynamics of the audio signal by identifying the lower frequency components. This
filtered signal can provide insights into the spectral dynamics of the voice signal.
17
5.4 Reference
[1] J. Nordstr¨om, “Real time digital signal processing using matlab,” 2017.
[2] S. M. Kuo, B. H. Lee, and W. Tian, Real-time digital signal processing: fundamentals,
implementations and applications. John Wiley Sons, 2013.
[3] Z.-J. Mou and P. Duhamel, “Short-length fir filters and their use in fast nonrecursive
filtering,” IEEE Transactions on Signal Processing, vol. 39, no. 6, pp. 1322–1332, 1991.
18