0% found this document useful (0 votes)
11 views8 pages

Upsample DSP

This lab report from the Department of Electrical Engineering at NUST-Pakistan focuses on upsampling and downsampling voice signals. The report details the processes of increasing and decreasing sample rates for audio clips, including MATLAB implementations for both tasks. It also discusses the implications of these processes on audio quality and bandwidth considerations for streaming and transmission.

Uploaded by

Mustafa Aasim
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)
11 views8 pages

Upsample DSP

This lab report from the Department of Electrical Engineering at NUST-Pakistan focuses on upsampling and downsampling voice signals. The report details the processes of increasing and decreasing sample rates for audio clips, including MATLAB implementations for both tasks. It also discusses the implications of these processes on audio quality and bandwidth considerations for streaming and transmission.

Uploaded by

Mustafa Aasim
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/ 8

DEPARTMENT OF ELECTRICAL ENGINEERING

College of Electrical and Mechanical Engineering (CEME), NUST-Pakistan


B.E. Electrical Engineering

Digital Signal Processing


Lab Report

Up sampling and Down sampling on Voice Signals


Lab# 4:
Group Members Registration Number Syndicate
M.Ashiq Rasool Mustafa 414361
Shehrooz Akram 423739 A
Ali Iqbal 415290
Adnan Ishaq 413582

Upsampling:

Also,known as interpolation or expander it is a process in which the number of samples or data


points in a signal, image, or dataset. This usually involves adding new points using methods like
interpolation to estimate missing values.

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).

1. Music File Acquisition & Exploration

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).

3. Filtering & Analysis

o Design/Apply an interpolation filter to remove the spectral images introduced by zero‐


insertion. Provide the filter’s magnitude response and justify the cutoff frequency choice
(around the Nyquist limit of the new sample rate).

o Time‐Domain & Frequency‐Domain Analysis:

 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.

o In a real‐world streaming platform, consider factors like computational cost, memory


usage for filtering, and whether the upsampled music truly benefits from a higher rate
or if it merely increases file size without substantial quality improvement.
DSP
Experiment # 5 Lab Report 2

Code:

clc;

clear;

close all;

[audioIn, Fs] = audioread('C:\Users\twott\Downloads\akiaura-Sleepwalker-_Filtered-


Instrumental_.wav');

disp(['Original Sampling Rate: ', num2str(Fs), ' Hz']);

t = (0:length(audioIn)-1)/Fs;

figure;

plot(t, audioIn);

xlabel('Time (s)');

ylabel('Amplitude');

title('Original Audio Waveform');

upsampleFactor = 2;

Fs_new = Fs * upsampleFactor;

audioUp = resample(audioIn, upsampleFactor, 1);

tUp = (0:length(audioUp)-1)/Fs_new;

figure;

plot(tUp, audioUp);

xlabel('Time (s)');

ylabel('Amplitude');

title('Upsampled Audio Waveform (44.1 kHz)');

N = 2^nextpow2(length(audioIn));
DSP
Experiment # 5 Lab Report 3

Y_orig = fft(audioIn, N);

Y_up = fft(audioUp, N);

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)));

title('Original Spectrum (22.05 kHz)');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

subplot(2,1,2);

plot(f_up, abs(Y_up(1:N/2+1)));

title('Upsampled Spectrum (44.1 kHz)');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

Plots:
DSP
Experiment # 5 Lab Report 4

Task 2:
DSP
Experiment # 5 Lab Report 5

Question 2 (Downsampling a Music Excerpt for Low-Bandwidth Transmission)


In a different scenario, you need to transmit the music clip over a low‐bandwidth connection. You will
downsample (decimate) the file to meet strict bandwidth constraints without losing essential music
content.

1. Bandwidth Constraints & Downsampling Factor

o Identify the maximum allowable sampling rate for your channel.

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 Design/Select a low‐pass filter to remove frequency components above the new


Nyquist frequency before downsampling. Provide the filter’s magnitude response and
discuss any trade‐offs in filter order, cutoff, and roll‐off.

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 Filter the music clip with your anti‐aliasing filter.

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.

4. Time‐Domain & Subjective Analysis

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?

o Discuss real‐world considerations for low‐bandwidth scenarios (e.g., phone lines,


wireless links, or streaming on slow networks).

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;

h = fir1(filter_order - 1, cutoff_freq / (Fs / 2));

x_filtered = filter(h, 1, x);


x_downsampled = downsample(x_filtered, downsample_factor);

audiowrite('downsampled_music.wav', x_downsampled, Fs_new);

t_original = (0:length(x)-1) / Fs;


t_down = (0:length(x_downsampled)-1) / Fs_new;

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:

You might also like