Indian Institute of Technology Patna
ME3101: Data Analytics and Machine Learning for Engineers
Tutorial 2– Submission Due: 12/08/2025
Instructions
• Complete this tutorial using Python (preferably in a Colab Notebook) or MATLAB.
• Ensure all code is executable, well-commented, and neatly organized.
• Answer all parts and save results/plots in the specified folders.
• Use the file and directory structure given in the checklist at the end.
• Complete the provided worksheets before attempting this tutorial.
• Data file link: Download Data (Google Drive)
Problem Statement – Tutorial 2: Time–Frequency
Analysis of Audio Signals
The objective of this tutorial is to analyze, filter, and visualize audio signals in both the time
and frequency domains, and to generate spectrograms, using any appropriate computational
tool (e.g., MATLAB, Python). The analysis will be performed on the provided audio files
guitar.wav and Q2_audio.wav.
Part 1 – Time-Domain and Frequency-Domain Analysis [15]
File: guitar.wav
1. Data Import and Preprocessing
o Load guitar.wav. If the audio is stereo, convert it to mono by averaging the
channels.
o Normalize the signal to floating-point values in the range [-1, 1].
2. Basic Signal Information
o Print:
▪ Sampling frequency (Fs, Hz)
▪ Number of samples (N)
▪ Duration (seconds)
3. Time-Domain Plots
o Plot the full waveform of the signal.
o Plot a zoomed-in view of the first 0.1 seconds.
4. Frequency Analysis (FFT)
o Compute the FFT and generate a single-sided magnitude spectrum.
o Plot magnitude vs frequency up to Fs/4 Hz.
5. Peak Frequency Identification
o Identify and print the top 8 frequency components (Hz and magnitude),
where the magnitude is at least 5% of the maximum peak.
6. Inverse FFT Reconstruction
o Reconstruct the signal via inverse FFT.
o Compute and report the Mean Squared Error (MSE) and maximum
absolute difference between the original and reconstructed signals.
o Overlay both signals on a plot for the first 50 ms segment.
Indian Institute of Technology Patna
ME3101: Data Analytics and Machine Learning for Engineers
Tutorial 2– Submission Due: 12/08/2025
Part 2 – Frequency-Domain Filtering [15]
File: Q2_audio.wav
1. Data Import and Initial Analysis
o Load Q2_audio.wav. If stereo, use only the left channel.
o Plot the full waveform.
o Plot the magnitude spectrum up to 2000 Hz.
2. Low-Pass Filtering
o Apply a low-pass filter with a cutoff frequency of 500 Hz by zeroing
frequency components above this limit in the FFT domain.
o Reconstruct the filtered signal using inverse FFT.
o Save the filtered signal as low_pass_filtered.wav.
o Plot the magnitude spectrum (up to 2000 Hz).
3. High-Pass Filtering
o Apply a high-pass filter with a cutoff frequency of 500 Hz by zeroing
frequency components below this limit in the FFT domain.
o Reconstruct and save as high_pass_filtered.wav.
o Plot the magnitude spectrum (up to 2000 Hz).
Part 3 – Spectrogram Analysis [10]
File: Q2_audio.wav
1. Spectrogram Computation
o Use:
▪ nperseg = 1024
▪ noverlap = 512
▪Provide a colorbar with an intensity legend indicating signal strength
2. Spectrogram Plot
o X-axis: Time (seconds)
o Y-axis: Frequency (Hz)
o Color scale: Intensity in dB (use a perceptually distinct colormap such as jet).
Submission Checklist [10]
Name your compressed file:
ROLLNUMBER_NAME_week2.zip
Folder structure inside the zip:
[ROLLNUMBER]_[NAME]_week2/
│
├── report.pdf ← Summary + screenshots (Optional)
├── answers.ipynb ← Colab notebook (if using Python)
Indian Institute of Technology Patna
ME3101: Data Analytics and Machine Learning for Engineers
Tutorial 2– Submission Due: 12/08/2025
├── answers.m ← MATLAB script (if using MATLAB)
├── audio/ ← Audio files (e.g., sample.wav)
│ └── sample.wav
└── outputs/ ← Output figures or plots (e.g., Q1.png, Q2.png)
Ensure:
• All code is executable and well-commented
• All figures and data are saved in the correct folders
• You maintain the given structure for easy evaluation
Submit your .zip file in the Tutorial-2 (Microsoft Teams)