Lab 4: Quantization, Oversampling, and Noise Shaping

Similar documents
Massachusetts Institute of Technology

George Mason University ECE 201: Introduction to Signal Analysis Spring 2017

E : Lecture 1 Introduction

EE538 Final Exam Fall :20 pm -5:20 pm PHYS 223 Dec. 17, Cover Sheet

EEM 409. Random Signals. Problem Set-2: (Power Spectral Density, LTI Systems with Random Inputs) Problem 1: Problem 2:

LAB 6: FIR Filter Design Summer 2011

Centre for Mathematical Sciences HT 2017 Mathematical Statistics

Homework 5 Solutions

Homework 5 Solutions

Each problem is worth 25 points, and you may solve the problems in any order.

Centre for Mathematical Sciences HT 2017 Mathematical Statistics. Study chapters 6.1, 6.2 and in the course book.

ELEN E4810: Digital Signal Processing Topic 11: Continuous Signals. 1. Sampling and Reconstruction 2. Quantization

ADSP ADSP ADSP ADSP. Advanced Digital Signal Processing (18-792) Spring Fall Semester, Department of Electrical and Computer Engineering

EE538 Final Exam Fall 2007 Mon, Dec 10, 8-10 am RHPH 127 Dec. 10, Cover Sheet

ECE4270 Fundamentals of DSP Lecture 20. Fixed-Point Arithmetic in FIR and IIR Filters (part I) Overview of Lecture. Overflow. FIR Digital Filter

Signals and Systems. Problem Set: The z-transform and DT Fourier Transform

LECTURE NOTES IN AUDIO ANALYSIS: PITCH ESTIMATION FOR DUMMIES

UNIVERSITY OF OSLO. Please make sure that your copy of the problem set is complete before you attempt to answer anything.

2.161 Signal Processing: Continuous and Discrete Fall 2008

FINITE PRECISION EFFECTS 1. FLOATING POINT VERSUS FIXED POINT 3. TYPES OF FINITE PRECISION EFFECTS 4. FACTORS INFLUENCING FINITE PRECISION EFFECTS

Lecture 3 January 23

Due dates are as mentioned above. Checkoff interviews for PS4 and PS5 will happen together between October 24 and 28, 2012.

Random signals II. ÚPGM FIT VUT Brno,

Review of Fundamentals of Digital Signal Processing

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science Discrete-Time Signal Processing Fall 2005


Principles of Communications

Practical Spectral Estimation

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science : Discrete-Time Signal Processing

! Introduction. ! Discrete Time Signals & Systems. ! Z-Transform. ! Inverse Z-Transform. ! Sampling of Continuous Time Signals

Laboratory Project 2: Spectral Analysis and Optimal Filtering

EE482: Digital Signal Processing Applications

Problem Value Score No/Wrong Rec

Oversampling Converters

NAME: ht () 1 2π. Hj0 ( ) dω Find the value of BW for the system having the following impulse response.

Time-domain representations

EE123 Digital Signal Processing

Grades will be determined by the correctness of your answers (explanations are not required).

Digital Signal Processing. Midterm 1 Solution

6.003 (Fall 2011) Quiz #3 November 16, 2011

Computer Engineering 4TL4: Digital Signal Processing

CMPT 889: Lecture 3 Fundamentals of Digital Audio, Discrete-Time Signals

EE482: Digital Signal Processing Applications

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING EC2314- DIGITAL SIGNAL PROCESSING UNIT I INTRODUCTION PART A

CHAPTER 2 RANDOM PROCESSES IN DISCRETE TIME

ECE 3084 OCTOBER 17, 2017

Communications and Signal Processing Spring 2017 MSE Exam

Fourier Methods in Digital Signal Processing Final Exam ME 579, Spring 2015 NAME

Homework 6 Solutions

Adaptive Systems Homework Assignment 1

Exercises in Digital Signal Processing

Digital Filters Ying Sun

DFT & Fast Fourier Transform PART-A. 7. Calculate the number of multiplications needed in the calculation of DFT and FFT with 64 point sequence.

EE482: Digital Signal Processing Applications

Aspects of Continuous- and Discrete-Time Signals and Systems

Stochastic Processes. M. Sami Fadali Professor of Electrical Engineering University of Nevada, Reno

ECE 636: Systems identification

ELEN E4810: Digital Signal Processing Topic 2: Time domain

7.1 Sampling and Reconstruction

2.161 Signal Processing: Continuous and Discrete

EECS 123 Digital Signal Processing University of California, Berkeley: Fall 2007 Gastpar November 7, Exam 2

Lesson 1. Optimal signalbehandling LTH. September Statistical Digital Signal Processing and Modeling, Hayes, M:

Roundoff Noise in Digital Feedback Control Systems

Discrete-Time Gaussian Fourier Transform Pair, and Generating a Random Process with Gaussian PDF and Power Spectrum Mark A.

Probability Space. J. McNames Portland State University ECE 538/638 Stochastic Signals Ver

Discrete-Time David Johns and Ken Martin University of Toronto

Massachusetts Institute of Technology

Multirate Digital Signal Processing

0 for all other times. Suppose further that we sample the signal with a sampling frequency f ;. We can write x # n =

EE 521: Instrumentation and Measurements

Lecture 7 Random Signal Analysis

2.161 Signal Processing: Continuous and Discrete

The Discrete-Time Fourier

Stability Condition in Terms of the Pole Locations

Digital Signal Processing: Signal Transforms

LAB 2: DTFT, DFT, and DFT Spectral Analysis Summer 2011

The Cooper Union Department of Electrical Engineering ECE111 Signal Processing & Systems Analysis Final May 4, 2012

DIGITAL SIGNAL PROCESSING LABORATORY

INTRODUCTION TO DELTA-SIGMA ADCS

6.003: Signals and Systems. Sampling and Quantization

Chap 2. Discrete-Time Signals and Systems

Digital Signal Processing Lecture 3 - Discrete-Time Systems

Question Bank. UNIT 1 Part-A

Analysis of Finite Wordlength Effects

ECGR4124 Digital Signal Processing Midterm Spring 2010

Designing Information Devices and Systems I Spring 2018 Homework 11

System Identification & Parameter Estimation

Solutions. Number of Problems: 10

Review of Fundamentals of Digital Signal Processing

DISCRETE-TIME SIGNAL PROCESSING

Digital Signal Processing

Your solutions for time-domain waveforms should all be expressed as real-valued functions.

Finite Word Length Effects and Quantisation Noise. Professors A G Constantinides & L R Arnaut

Discrete-Time Signals & Systems

Quantization and Compensation in Sampled Interleaved Multi-Channel Systems

LTI H. the system H when xn [ ] is the input.

Chapter 2: Problem Solutions

Final Exam January 31, Solutions

Experimental Fourier Transforms

FACULTY OF ENGINEERING MULTIMEDIA UNIVERSITY LAB SHEET

Transcription:

Lab 4: Quantization, Oversampling, and Noise Shaping Due Friday 04/21/17 Overview: This assignment should be completed with your assigned lab partner(s). Each group must turn in a report composed using a word processor (e.g., Word, Pages, L A TEX, etc...) including a cover page with full names of all group members. The remaining pages should contain (in order) the answers and MATLAB scripts for the exercises. MATLAB figures can be pasted into the document or saved as PDF files. When working on the project, please follow the instructions and respond to each item listed. Your project grade is based on: (1) your MATLAB scripts, (2) your report (plots, explanations, etc. as required), and (3) your final results. For all labs, you must clearly write the problem number next to your solution and label the axes on all plots to get full credit. Submission can be done electronically in PDF format or on paper. Plagiarism is a very serious offense in Academia. Any figures in the paper not generated by you should labeled Reproduced from.... Any portions of any simulation code (e.g., MATLAB, C, etc...) not written by you be clearly marked in your source files. The original source of any mathematical derivation or proof should be explicitly cited. 1 Overview In this lab, we will explore quantization, oversampling, and noise shaping in analog-to-digital (A/D), digital-to-analog (D/A), and digitial-to-digital (D/D) conversion. Amplitude quantization is a fundamental process in the conversion from continuous to discrete amplitude. This topic is quite interesting because there are a number of non-obvious tricks that can be used to improve performance. The first trick is the addition of random dither before quantization. Surprisingly, adding noise before quantization helps one reduce the negative effects of quantization noise. The second trick is sampling much faster than the Nyquist rate. The idea is that low-accuracy samples taken at a high rate can be used to get high-accuracy samples at a low rate. The last trick is noise shaping with sigma-delta converters. By cleverly combining A/D and D/A converters together, one can drastically improve the benefit of oversampling. 2 Background To understand the effects of quantization, we first have to observe and understand the spectral behavior of white noise and colored noise. The power of a white-noise process is spread uniformly across the full spectrum π, π, whereas the power of a colored noise process is spread non-uniformly across the spectrum. Let Xn be a stationary discrete-time white-noise process whose sample at time index n is denoted by the random variable Xn. For example, one can generate a length-l sample from such a random process using the Matlab command x=randn(1,l). The autocorrelation function of this random process is defined to be R xx τ E XnXn + τ ; τ {..., 1, 0, 1,...} and the power spectral density is related to it as S xx (e jω ) = F (R xx τ), where F represents the discretetime Fourier transform operator. Note that, since this process is stationary, R xx τ does not depend on n but only on the time difference between the samples, τ. Now let us consider the particular example of a white noise process generated from the standard normal distribution N (0, 1). So each Xn is independent and distributed according to Xn N (0, 1). From the definition of this distribution we know that if Z N (0, 1) then its mean is EZ = 0 and its variance is EZ 2 = 1. Therefore, for our Gaussian white noise process, we have E Xn = 0 and 1

E Xn 2 = 1. Let us now compute the autocorrelation function and power spectral density of this process. For τ = 0, we get R xx 0 = E Xn 2 = 1. For τ > 0, observe that Xn and Xn + τ are two independent standard normal random variables. Since they are independent, the expectation of their product is the product of their expectations: R xx τ = E XnXn + τ = E Xn E Xn + τ = 0 0 = 0. Hence we have R xx τ = { 1, τ = 0 0, τ 0, which is a discrete-time impulse function. This means the noise process is completely uncorrelated with itself for any non-zero lag. Computing the DTFT, we see that the power spectral density is given by S xx (e jω ) = 1 and hence the process is white. Next, let us run this process Xn through a low-pass filter whose impulse response is given by hn = 0.5δn + 0.5δn 1. Hence the output process is given by Y n = 0.5Xn + 0.5Xn 1. Let us proceed to compute the autocorrelation function of the process Y n. We have R yy τ E Y ny n + τ = E (0.5Xn + 0.5Xn 1) (0.5Xn + τ + 0.5Xn + τ 1) = 0.25 E XnXn + τ + E XnXn + τ 1 + E Xn 1Xn + τ + E Xn 1Xn + τ 1 0.25 1 + 0 + 0 + 1 if τ = 0 0.25 0 + 1 + 0 + 0 if τ = 1 = 0.25 0 + 0 + 1 + 0 if τ = 1 0.25 0 + 0 + 0 + 0 if τ > 1 0.5 if τ = 0 0.25 if τ = 1 = 0.25 if τ = 1 0 if τ > 1. Therefore the power spectral density is S yy (e jω ) = τ= R yy τe jωτ = 0.5 e jω(0) + (0.25) (e jω(1) + e +jω(1)) = 0.5(1 + cos(ω)), which equals the magnitude squared H(e jω ) 2 of the low-pass filter hn and is clearly not uniform on π, π. Since this spectrum has more power at low frequencies than high frequencies, the noise process Y n is called colored noise. 3 Exercises 3.1 Random Noise, Autocorrelation and Power Spectral Density Let us complement our theoretical understanding of the spectral behavior of white noise and colored noise processes with MATLAB experiments. (a) Let x be 2 seconds of white noise sampled at Fs=22050 Hz. This can be generated using the randn in-built function in MATLAB. For example, if we need L samples of the process, we can obtain it using x=randn(1,l). This generates L independent samples from the standard normal distribution N (0, 1). Plot the deterministic autocorrelation r xx τ and power spectral density 2

R xx (e jω ) functions for the vector x using the autocorr and pwelch in-built functions, respectively, using their default options. Comment on the two plots in connection with the background theory. Play this signal using the sound function and briefly describe what you hear. (b) Now, filter the signal x using the low-pass filter with coefficients b=0.5 0.5,a=1 to get a signal ylp and plot its autocorrelation and power spectral density using the same in-built functions as in the previous part. Comment on the two plots, in comparison to those for x. Play ylp using the sound function and briefly describe what you hear, compared to what you heard when you played x. Note that the autocorr function normalizes the plot so that r xx 0 = 1. (c) Repeat the previous part using the high-pass filter with coefficients b=0.5-0.5,a=1 to get a signal yhp. Can this also be called colored noise? How does it sound? The following are some additional comments/suggestions and you need not include these in your lab submissions. You can compare the pwelch plots with their corresponding periodogram plots with which you are more familiar now. The frequency response of the filters can be visualized using freqz and/or fvtool functions, or you could obtain the impulse response using the filter function and then observe its pwelch or periodogram plot. Realize that all of these are different ways to observe the spectrum, although pwelch is more sophisticated than periodogram. As mentioned in the MATLAB Help documentation for pwelch, for a wide-sense stationary process, like we have above, the periodogram is not a consistent estimator of the true power spectral density whereas pwelch is, since it averages the estimate over multiple windowed segments to reduce the variability in its answer. 3.2 Basic Quantization For this exercise, we will quantize a sinusoid at different resolutions with and without dither. (a) Let x be 2 seconds of a 600 Hz unit amplitude sinusoid sampled at Fs=22050 Hz. Let L be the length of this sequence. (b) For = 2 m with m = 1, 3, 5, 7, quantize x with. 2 For m = 1, how many quantization levels do we have for the given signal? Hence, how many bits of quantization does this correspond to, ignoring boundary effects (at the maximum and minimum values for the signal)? Measure the SQNR in db and compare your result (for the noise power) with the theoretical prediction from class. For each m, listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. Plot the power spectral density of the quantization error using pwelch and explain the association between this plot and the audio artifacts. Note: For this lab, always use the sound function. Avoid using the soundsc function since it scales the whole signal to make it as loud as possible (without clipping). So, for higher levels of quantization, this will play the (quantization) error signal loudly although it has very low energy in the full spectrum. (c) Repeat the previous part using uniform dither over one quantization cell. In this case, 2 + Z, where Z is uniform over 1 2, 1 2 and drawn independently each time the quantizer is used. Note: You can generate such a sequence with z=rand(1,l)-1/2. Measure the SQNR in db and compare with the theoretical prediction. For each m, listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. Note: The addition of Z before quantization adds 2 Var(Z) = 2 12 to the theoretical quantization noise power but guarantees that the quantization error is uncorrelated with the signal. 3

(d) Use x,fs = audioread( singing8.wav ) to load a sound clip. Let L=2*Fs and x=x(1:l) be the first 2 seconds of the clip. For = 2 m with m = 1, 3, 5, 7, quantize x without dither. Compute the actual SQNR and the theoretical prediction. For each m, listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. (e) For the signal in the previous part, use = 2 m with m = 1, 3, 5, 7 to quantize x with uniform dither over one quantization cell. Compute the actual SQNR and the theoretical prediction. For each m, listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. (f) For the signal in the previous part, use = 2 m with m = 1, 3, 5, 7 to quantize x with triangular dither: 2 + Z 1 + Z 2, where z1=rand(1,l)-1/2 and z2=rand(1,l)-1/2. Compute the actual SQNR and the theoretical prediction. For each m, listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. Can you explain why triangular dither is preferred in high-quality audio applications? Note: The addition of Z 1 + Z 2 before quantization adds 2 Var(Z 1 + Z 2 ) = 2 6 quantization noise power. to the theoretical 3.3 Oversampled Quantization To evaluate an oversampled quantization system, we must have an oversampled waveform. The following MATLAB code computes this waveform. % Load sound clip x,fs = audioread( singing8.wav ); % Band-limited oversampling of x by factor M M = 6; % Oversampling factor xo = zeros(m*length(x),1); % Init oversampled waveform xo(1:m:end) = x; % Upsample waveform h = fir1(300,0.9/m,chebwin(301,80)); % Design interpolation filter xo = M*filter(h,1,xo); % Filter upsampled waveform keeping same amplitude (a) For = 2 m with m = 1, 3, 5, 7, quantize the oversampled signal xo with 2 + Z, where Z is uniform over 1 2, 1 2 and drawn independently each time the quantizer is used. (b) Measure the SQNR in db and compare your result with the theoretical prediction from class. For each m, listen to both the quantized waveform and the quantization error signal. Use sound(xo,m*fs) to play the clip at the oversampled rate. (c) For m = 1, 3, 5, 7, apply the following to each quantized signal: (i) Filter the quantized oversampled signal xoq with xoqf=filter(h,1,xoq) to remove out of band quantization noise and (ii) measure the SQNR in db by comparing xoqf with the filtered oversampled signal xof=filter(h,1,xo). Compare your result with the SQNR gain predicted by theory. Note: The reason that one should filter xo before comparing with xoqf is because the true noise power is represented by the power of the filtered error signal ef=filter(h,1,xo-xoq). Additionally, this approach allows one to ignore any delay and/or scaling changes introduced by filtering. 4

3.4 Oversampled Quantization with Noise Shaping % Quantization of xo with noise shaping yo = zeros(1,length(xo)); y = 0; v = 0; for i=1:length(xo) w = xo(i)-y; % Subtract previous quantized output v = v+w; % Accumulate all inputs so far minus all past outputs y = floor(v/d+rand(1))*d; % Quantize accumulated error with uniform dither yo(i) = y; end (a) Use the above script with = d = 1/8 to quantize the oversampled signal xo with noise shaping. Measure the SQNR in db by filtering yo and comparing with the filtered oversampled signal xof=filter(h,1,xo). Listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. (b) Suppose the original signal xo is not bandlimited to Ω π M, π M, but instead has a spectrum that decays rapidly with frequency and becomes negligible for Ω > 2π M. Can you think of a way to retain the high frequency components in the original signal and still take advantage of noise shaping? Extra Credit: Digital Mastering and Noise Shaping Noise shaping can also be used to improve the quality of D/A conversion and D/D quantization. The idea of digital-to-digital quantization is to reduce the number of bits per sample in an audio clip. With noise shaping, one can retain a high level of quality by shaping the noise into bands where hearing is less sensitive. The block diagram of a dithered noise-shaping quantizer is shown below. d(n) x(n) u(n) Q y(n) h(m) In this diagram, x(n) is the input, d(n) is the dither sequence, y(n) is the output, and the h(m) is the impulse response of the noise-shaping filter. Using the same approach as we used in class, one can show that Y (z) = X(z) + E(z) (1 H(z)). We note that h(m) = 0 for m 0 is required for causality. Otherwise, choosing h(0) = 1 allows one to cancel all of the quantization noise. For audio applications with F s = 44100, a good choice for h(m) is h = 0 1.47933-1.59032 1.64436-1.36613 0.926704-0.557931 0.267859-0.106726... 0.028516 0.001230-0.006165 0.003067 Try using freqz(1 -h(2:end)) to see the noise-shaping response of 1 H(z). Use this approach to convert singing8.wav from 16-bit resolution to 12-bit resolution. Plot the power spectral density of the quantization error to verify that your noise shaping is working correctly. Listen to both the quantized waveform and the quantization error signal. Describe the artifacts that you hear in each case. 5