Lab 2 Audio Sampling and Quantization Levels
Lab 2 Audio Sampling and Quantization Levels
Lab 2
Objective:
To investigate how different sampling rates and quantization levels affect the quality and
representation of audio signals.
Note:
Sampling rate:
• Refers to the number of samples taken per second when converting a continuous signal
into a discrete signal.
• It is usually expressed in hertz (Hz). For example, a sampling rate of 44.1 kHz means
44,100 samples are taken each second.
Quantization level:
• The process of mapping a continuous range of values to a finite set of discrete levels.
• For example, an analog audio signal may have an infinite range of amplitudes, but
amplitudes use a limited number of discrete values in quantization.
Materials Needed:
• MATLAB
Procedure:
• Create a sine wave at a specific frequency (e.g., 440 Hz, which is the musical note A4)
• Quantize the sine wave to various bit depths (e.g., 8-bit, 16-bit, and 24-bit).
• For each quantization level, quantize the sine wave and plot the waveform
𝑆𝑖𝑔𝑛𝑎𝑙 𝑝𝑜𝑤𝑒𝑟
SNR(dB) = 10 log10 ( )
𝑁𝑜𝑖𝑠𝑒 𝑝𝑜𝑤𝑒𝑟
where
for j = 1:length(quant_levels)
bits = quant_levels(j); % Current quantization level
% Quantization
y_quantized = round(y_original * (2^(bits-1) - 1)) / (2^(bits-1)
- 1); % Normalize
% Calculate SNR
signal_power = mean(y_quantized.^2); % Signal power
noise_power = mean((y_original - y_quantized).^2); % Noise power
snr = 10 * log10(signal_power / noise_power); % SNR in dB
2. How does the Nyquist theorem relate to sampling rates, and what is its significance in
preventing aliasing?
3. What are the differences between low, medium, and high sampling rates in terms of
sound quality and fidelity?
5. What are the consequences of using a low bit depth for quantization when converting
an analog signal to digital?
6. How does oversampling help improve the quality of digitally recorded audio?
7. In what ways can quantization errors manifest in digital audio, and how can they impact
sound quality?
8. Why is 44.1 kHz commonly used as a standard sampling rate for audio CDs?
9. What is the relationship between sampling rates and quantization levels in the context
of audio signal representation?
10. How can the choice of sampling rate and quantization level influence the file size of a
digital audio recording?