Upsample DSP
Upsample DSP
Upsampling:
Downsampling:
Also,known as Decimation Process in which we reduce the number of samples or data points in
a signal, image, or data set. This is typically done to decrease resolution, size, or processing
requirements.
DSP
Experiment # 5 Lab Report 1
Task 1:
Question 1 (Upsampling a Music Excerpt for High-Quality Streaming)
You have obtained a short excerpt of a music track recorded at a relatively low sampling rate (e.g.,
22.05 kHz). Your goal is to prepare this clip for high‐quality streaming, which requires a higher sampling
rate (e.g., 44.1 kHz or 48 kHz).
o Load a short excerpt (10–15 seconds) of a music clip in MATLAB. Confirm its original
sampling rate.
o Plot the time‐domain waveform of the music excerpt. Provide a brief description of the
music content (instruments, vocals, etc.) to understand its frequency range.
2. Upsampling Process
o Choose an upsampling factor (e.g., 2 if going from 22.05 kHz to 44.1 kHz). Explain why
this factor is suitable.
o Implement the upsampling in MATLAB (insert zeros between samples or use a built‐in
function such as resample or interp).
Plot the upsampled signal in the time domain (note the new sampling rate on
the axis).
(Optional if covered in lab) Use the FFT to compare the spectra before and after
upsampling.
4. Discussion
o Describe any audible differences between the original and the upsampled clip.
Code:
clc;
clear;
close all;
t = (0:length(audioIn)-1)/Fs;
figure;
plot(t, audioIn);
xlabel('Time (s)');
ylabel('Amplitude');
upsampleFactor = 2;
Fs_new = Fs * upsampleFactor;
tUp = (0:length(audioUp)-1)/Fs_new;
figure;
plot(tUp, audioUp);
xlabel('Time (s)');
ylabel('Amplitude');
N = 2^nextpow2(length(audioIn));
DSP
Experiment # 5 Lab Report 3
f_orig = Fs*(0:(N/2))/N;
f_up = Fs_new*(0:(N/2))/N;
figure;
subplot(2,1,1);
plot(f_orig, abs(Y_orig(1:N/2+1)));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
subplot(2,1,2);
plot(f_up, abs(Y_up(1:N/2+1)));
xlabel('Frequency (Hz)');
ylabel('Magnitude');
Plots:
DSP
Experiment # 5 Lab Report 4
Task 2:
DSP
Experiment # 5 Lab Report 5
o Choose a downsampling factor (e.g., from 44.1 kHz to 11 kHz ⇒factor of 4). Explain why
this factor meets the bandwidth limit.
2. Anti-Aliasing Filter
o Justify how you chose the cutoff frequency based on the critical musical content (e.g.,
considering humans generally hear up to ~20 kHz, but for more compressed music, you
might allow a lower bandwidth).
3. MATLAB Implementation
o Downsample the filtered signal by your chosen factor. Use a built‐in function like
downsample or decimate if desired, or do it manually in steps.
o Plot the time‐domain waveform of the original vs. the downsampled music. Label the
axes correctly (especially the sampling rate).
o Listen to the original and the downsampled file (if possible). Comment on the perceived
quality: Are certain instruments/vocals more affected than others?
Code:
[x, Fs] = audioread('C:\Users\twott\Downloads\akiaura-Sleepwalker-_Filtered-
Instrumental_.wav
');
if size(x, 2) > 1
DSP
Experiment # 5 Lab Report 6
x = mean(x, 2);
end
downsample_factor = 4;
Fs_new = Fs / downsample_factor;
cutoff_freq = 5000;
filter_order = 101;
figure;
subplot(2,1,1);
plot(t_original, x);
title('Original Music');
xlabel('Time (s)');
ylabel('Amplitude');
subplot(2,1,2);
plot(t_down, x_downsampled);
DSP
Experiment # 5 Lab Report 7
title('Downsampled Music');
xlabel('Time (s)');
ylabel('Amplitude');
Plots: