DSP Lab 5
DSP Lab 5
Abstract
This lab report explores the concepts of upsampling and downsampling ap-
plied to digital audio signals. The report investigates the process of converting a
music excerpt between different sampling rates for high-quality streaming and low-
bandwidth transmission applications. We implement both upsampling (increasing
the sampling rate) and downsampling (decreasing the sampling rate) operations
in MATLAB, applying appropriate filtering techniques to maintain signal quality.
The analysis includes time-domain and frequency-domain visualizations, along with
discussions on practical considerations for real-world applications.
Contents
1 Introduction 3
2 Theoretical Background 3
2.1 Sampling and Nyquist Theorem . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Upsampling Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Downsampling Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
5 Conclusion 11
1
Your Name DSP Lab 5
6 Appendix 12
6.1 MATLAB Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
6.2 Audio Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.3 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2
Your Name DSP Lab 5
1 Introduction
This lab focuses on the implementation and analysis of sampling rate conversion tech-
niques for digital audio signals. Sampling rate conversion is a fundamental operation in
digital signal processing, particularly in audio applications where different systems may
operate at various sampling rates. The lab explores two main scenarios:
Through these exercises, we gain practical experience with rate conversion algorithms,
digital filtering, and the impact of sampling rate on audio quality. The implementations
are carried out in MATLAB, allowing for both theoretical analysis and auditory evalua-
tion.
2 Theoretical Background
2.1 Sampling and Nyquist Theorem
Digital audio signals are created by sampling continuous audio waveforms at discrete time
intervals. The Nyquist-Shannon sampling theorem states that to perfectly reconstruct
a continuous bandlimited signal, the sampling rate must be at least twice the highest
frequency present in the signal. For audio signals, which typically contain frequencies up
to 20 kHz (the upper limit of human hearing), standard CD-quality audio uses a 44.1
kHz sampling rate.
2. Interpolation filtering: Applying a low-pass filter to smooth the signal and re-
move spectral images introduced by zero insertion.
3
Your Name DSP Lab 5
4
Your Name DSP Lab 5
5
Your Name DSP Lab 5
The cutoff frequency was chosen to be at half the new Nyquist frequency (around
11.025 kHz) to preserve the entire frequency content of the original signal while suppress-
ing the spectral images.
6
Your Name DSP Lab 5
3.5 Discussion
Upon listening to both the original and upsampled audio files, the following observations
were made:
• Quality assessment: [Evaluate the quality difference between original and up-
sampled]
• Memory usage: Higher sampling rates require more memory for both storage and
processing.
• Quality vs. file size trade-off: While upsampling does not add new frequency
information beyond what was in the original recording, it may improve playback
quality on certain systems. However, this comes at the cost of approximately dou-
bling the file size.
7
Your Name DSP Lab 5
• It reduces the original sampling rate of 44.1 kHz to approximately 11.025 kHz
• Cutoff frequency: 4.96 kHz (90% of the new Nyquist frequency of 5.5125 kHz)
8
Your Name DSP Lab 5
Figure 5: Magnitude response of the anti-aliasing filter with the new Nyquist frequency
marked
The cutoff frequency was set slightly below the new Nyquist frequency to ensure
effective suppression of frequency components that could cause aliasing. This conservative
approach ensures cleaner audio at the expense of slightly reduced high-frequency content.
2. Selecting every M th sample from the filtered signal, where M = 4 is the downsam-
pling factor
9
Your Name DSP Lab 5
Upon listening to the downsampled audio, the following observations were made re-
garding perceived quality:
10
Your Name DSP Lab 5
• Content adaptation: Different types of audio content (speech vs. music) have
different minimum quality requirements. Speech may remain intelligible at lower
sampling rates compared to music.
• Application context: For applications like telephony or voice messages, the down-
sampled quality might be perfectly adequate, while for music appreciation, it rep-
resents a significant compromise.
5 Conclusion
This lab provided practical experience with sampling rate conversion techniques for dig-
ital audio signals. Through the implementation of both upsampling and downsampling
processes, we gained insights into the theoretical and practical aspects of these operations.
Key findings from the lab include:
• Upsampling can prepare audio for high-quality playback systems but does not add
information beyond what was present in the original signal.
• Proper filter design is crucial for both upsampling (interpolation) and downsampling
(anti-aliasing) operations to maintain signal integrity.
These concepts and techniques are fundamental to digital audio processing systems,
including streaming platforms, telecommunications, and multimedia applications.
11
Your Name DSP Lab 5
6 Appendix
6.1 MATLAB Code
Below is the MATLAB code implementation for both the upsampling and downsampling
operations:
1 % DSP Spring 2025 - Lab 5 Implementation
2 % Music Sampling Rate Conversion ( Upsampling and Downsampling )
3
4 % % Question 1: Upsampling a Music Excerpt for High - Quality Streaming
5
6 % 1. Music File Acquisition & Exploration
7 fprintf ( ’ Question 1: Upsampling Music for High - Quality Streaming \ n ’) ;
8 fprintf ( ’ = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = \ n \ n ’) ;
9
10 % Load the audio file - replace with your file path
11 [ y_orig , Fs_orig ] = audioread ( ’ sample_music . wav ’) ;
12
12
Your Name DSP Lab 5
87 figure (4) ;
88 subplot (2 ,1 ,1) ;
89 plot ( f_orig , 2* abs ( Y_orig (1: NFFT_orig /2+1) ) / length ( y_orig ) ) ;
90 title ( ’ Original Signal Spectrum ’) ;
91 xlabel ( ’ Frequency ( Hz ) ’) ;
92 ylabel ( ’ Magnitude ’) ;
93 grid on ;
94
95 subplot (2 ,1 ,2) ;
96 plot ( f_up , 2* abs ( Y_up (1: NFFT_up /2+1) ) / length ( y_upsampled ) ) ;
97 title ( ’ Upsampled Signal Spectrum ’) ;
98 xlabel ( ’ Frequency ( Hz ) ’) ;
99 ylabel ( ’ Magnitude ’) ;
100 grid on ;
101
102 % Save upsampled audio
103 audiowrite ( ’ upsampled_music . wav ’ , y_upsampled , Fs_upsampled ) ;
104
13
Your Name DSP Lab 5
14
Your Name DSP Lab 5
6.3 References
1. Smith, J. O. (2007). Mathematics of the Discrete Fourier Transform (DFT). W3K
Publishing.
3. Harris, F. J. (1978). On the use of windows for harmonic analysis with the discrete
Fourier transform. Proceedings of the IEEE, 66(1), 51-83.
4. Proakis, J. G., & Manolakis, D. G. (2006). Digital Signal Processing (4th ed.).
Pearson.
15