Set-up. Equipment required: Your issued Laptop MATLAB ( if you don t already have it on your laptop)

Similar documents
Figure 1: Block diagram of Digital signal processing

Laboratory Assignment 2 Signal Sampling, Manipulation, and Playback

Music 270a: Fundamentals of Digital Audio and Discrete-Time Signals

Continuous vs. Discrete signals. Sampling. Analog to Digital Conversion. CMPT 368: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

Fourier Series and Gibbs Phenomenon

Digital Sampling. This Lecture. Engr325 Instrumentation. Dr Curtis Nelson. Digital sampling Sample rate. Bit depth. Other terms. Types of conversion.

Additive Synthesis OBJECTIVES BACKGROUND

Lab 4: Using the CODEC

CMPT 318: Lecture 4 Fundamentals of Digital Audio, Discrete-Time Signals

! Where are we on course map? ! What we did in lab last week. " How it relates to this week. ! Sampling/Quantization Review

Using the CODEC ReadMeFirst

Advanced Lab LAB 6: Signal Acquisition & Spectrum Analysis Using VirtualBench DSA Equipment: Objectives:

Analog to Digital Converters

ENSC327 Communication Systems Fall 2011 Assignment #1 Due Wednesday, Sept. 28, 4:00 pm

Princeton ELE 201, Spring 2014 Laboratory No. 2 Shazam

PHYS225 Lecture 22. Electronic Circuits

ENGR 210 Lab 12: Sampling and Aliasing

Lab 4 Fourier Series and the Gibbs Phenomenon

Laboratory Assignment 1 Sampling Phenomena

EGR 111 Audio Processing

EE482: Digital Signal Processing Applications

In this lecture. System Model Power Penalty Analog transmission Digital transmission

Fill in the following worksheet-style pages. A colored pen or pencil works best. The procedure is:

Communication Systems Lab Manual

Islamic University of Gaza. Faculty of Engineering Electrical Engineering Department Spring-2011

Experiment No. 6. Audio Tone Control Amplifier

CS101 Lecture 18: Audio Encoding. What You ll Learn Today

ECE 2111 Signals and Systems Spring 2009, UMD Experiment 3: The Spectrum Analyzer

EECS 216 Winter 2008 Lab 2: FM Detector Part II: In-Lab & Post-Lab Assignment

Type pwd on Unix did on Windows (followed by Return) at the Octave prompt to see the full path of Octave's working directory.

Laboratory Experiment #1 Introduction to Spectral Analysis

Based with permission on lectures by John Getty Laboratory Electronics II (PHSX262) Spring 2011 Lecture 9 Page 1

Fundamentals of Digital Audio *

Pre-Lab. Introduction

MUSC 316 Sound & Digital Audio Basics Worksheet

The Audio Synthesizer

Lab 12 Laboratory 12 Data Acquisition Required Special Equipment: 12.1 Objectives 12.2 Introduction 12.3 A/D basics

EXPERIMENT 4 INTRODUCTION TO AMPLITUDE MODULATION SUBMITTED BY

SGN Bachelor s Laboratory Course in Signal Processing Audio frequency band division filter ( ) Name: Student number:

MUSC 1331 Lab 3 (Northwest) Using Software Instruments Creating Markers Creating an Audio CD of Multiple Sources

L A B 3 : G E N E R A T I N G S I N U S O I D S

George Mason University Signals and Systems I Spring 2016

C.8 Comb filters 462 APPENDIX C. LABORATORY EXERCISES

Chapter 5: Signal conversion

Sound synthesis with Pure Data

ECEGR Lab #8: Introduction to Simulink

Analog ó Digital Conversion Sampled Data Acquisition Systems Discrete Sampling and Nyquist Digital to Analog Conversion Analog to Digital Conversion

Cyber-Physical Systems ADC / DAC

Introduction. A Simple Example. 3. fo = 4; %frequency of the sine wave. 4. Fs = 100; %sampling rate. 5. Ts = 1/Fs; %sampling time interval

Lab 4: Static & Switched Audio Equalizer

UNIVERSITY OF WARWICK

SAMPLING AND RECONSTRUCTING SIGNALS

Media Devices: Audio. CTEC1465/2018S Computer System Support

Sampling and Reconstruction

2: Audio Basics. Audio Basics. Mark Handley

ELEC350 Assignment 5

ECE 556 BASICS OF DIGITAL SPEECH PROCESSING. Assıst.Prof.Dr. Selma ÖZAYDIN Spring Term-2017 Lecture 2

EEO 401 Digital Signal Processing Prof. Mark Fowler

Digital Design Laboratory Lecture 7. A/D and D/A

ANALOGUE AND DIGITAL COMMUNICATION

LAB 2: Sampling & aliasing; quantization & false contouring

Fourier Signal Analysis

Electrical & Computer Engineering Technology

Advantages of Analog Representation. Varies continuously, like the property being measured. Represents continuous values. See Figure 12.

Digital Signal Processing Laboratory 1: Discrete Time Signals with MATLAB

EE 421L Digital Electronics Laboratory. Laboratory Exercise #9 ADC and DAC

Tektronix digital oscilloscope, BK Precision Function Generator, coaxial cables, breadboard, the crystal earpiece from your AM radio kit.

Chapter 4. Digital Audio Representation CS 3570

Experiment 3. Direct Sequence Spread Spectrum. Prelab

Sampling and Reconstruction of Analog Signals

DSP First. Laboratory Exercise #7. Everyday Sinusoidal Signals

HOWTO PROPERLY SET YOUR GAINS

Experiment 1 Introduction to MATLAB and Simulink

FM RADIO TRANSMITTER

Waveform Encoding - PCM. BY: Dr.AHMED ALKHAYYAT. Chapter Two

THE CITADEL THE MILITARY COLLEGE OF SOUTH CAROLINA. Department of Electrical and Computer Engineering. ELEC 423 Digital Signal Processing

Analog-Digital Interface

EE 233 Circuit Theory Lab 2: Amplifiers

Lab 6 - MCU CODEC IIR Filter ReadMeFirst

EP375 Computational Physics

Bioacoustics Lab- Spring 2011 BRING LAPTOP & HEADPHONES

Lindell TE 100 User Manual. Lindell TE 100. User Manual

UNIVERSITY OF WARWICK

Chapter 4 Digital Transmission 4.1

Lab 2: Digital Modulations

Pulse Code Modulation (PCM)

Lab S-8: Spectrograms: Harmonic Lines & Chirp Aliasing

ECE 271 Microcomputer Architecture and Applications University of Maine

EE 264 DSP Project Report

EBU5375 Signals and Systems: Filtering and sampling in Matlab. Dr Jesús Requena Carrión

Lab 8. Signal Analysis Using Matlab Simulink

E40M Sound and Music. M. Horowitz, J. Plummer, R. Howe 1

Basic Transceiver tests with the 8800S

INTRODUCTION TO COMMUNICATION SYSTEMS LABORATORY IV. Binary Pulse Amplitude Modulation and Pulse Code Modulation

MASSACHUSETTS INSTITUTE OF TECHNOLOGY /6.071 Introduction to Electronics, Signals and Measurement Spring 2006

PYKC 27 Feb 2017 EA2.3 Electronics 2 Lecture PYKC 27 Feb 2017 EA2.3 Electronics 2 Lecture 11-2

University of North Carolina-Charlotte Department of Electrical and Computer Engineering ECGR 3157 Electrical Engineering Design II Fall 2013

14 fasttest. Multitone Audio Analyzer. Multitone and Synchronous FFT Concepts

Introduction to Equalization

YEDITEPE UNIVERSITY ENGINEERING FACULTY COMMUNICATION SYSTEMS LABORATORY EE 354 COMMUNICATION SYSTEMS

Transcription:

All signals found in nature are analog they re smooth and continuously varying, from the sound of an orchestra to the acceleration of your car to the clouds moving through the sky. An excerpt from http://www.netguru.net/ntc/ntcc5.htm provides some additional background on analog signals: The term "analog" comes from the word "analogous" meaning something is similar to something else. It is used to describe devices that turn the movement or condition of a natural event into similar electronic or mechanical signals. There are numerous examples, but let's look at a couple. A prime example of an analog device is a non-digital thermometer measuring a constantly changing temperature. The action is continuous and the range is not very limited, though sometimes we wish it were. The data produced by a thermometer is analogous to the change in temperature. Therefore, it is an analog signal. Analog signals most closely represent the natural form of information as closet vinyl enthusiasts would agree: http://brokensecrets.com/2010/02/19/why-vinyl-records-are-becoming-popularagain/ If analog recordings provide superior sound quality, why has the world gone digital? There s a major disadvantage to the analog format: Noise. Digital signals, on the other hand, have several advantages, including noise immunity. In this Practical Exercise, we ll explore the process of converting analog signals to digital signals. Set-up. Equipment required: Your issued Laptop MATLAB ( if you don t already have it on your laptop) MATLAB files and code for the Analog to Digital lab o Download the MATLAB files and code for PE17 from your instructor s Google share drive lab Folder and place in a folder called a2d-matlab on your Desktop. 1

Part I: Introduction A simple sine wave representative of an analog tone is shown below. Question 1: What is the period of this signal? Question 2: What is this signal s frequency? (Show your work!) Question 3: What does this signal look like in the frequency domain? In order for this sine wave to be converted to a digital signal, it must be sampled (measured at regular time intervals), quantized (divided into levels), and encoded (assigned binary values to each sample). In order for the original signal to be recreated in digital form, it must be sampled at greater than the Nyquist Sampling Rate (fn), which is twice the highest frequency component of the signal. Question 4: Solve for fn. (Show your work!) If this signal is sampled at less than fn, aliasing will occur. Aliasing is the distortion that results when the signal reconstructed from samples is different from the original continuous signal. Think of it as connect-the-dots: Each time the signal is sampled, a dot represents a snapshot of the signal at that point in time. When the signal is reconstructed using Digital to Analog Conversion (which is the opposite of Analog to Digital Conversion), the converter plays a game of connect-the-dots And if there aren t enough dots to give the converter a good idea of the original signal, then the original signal is essentially lost. 2

http://zone.ni.com/images/reference/en-xx/help/371361g-01/loc_eps_aliasing_effects.gif Part II: Sampling a Tone We re going to use MATLAB, which is a high-level programming environment think of it as your calculator on some heavy-duty performance enhancing drugs. It s similar to C, but MATLAB s GUI makes it more userfriendly for our purposes. The MATLAB code provided allows you to adjust the sampling frequency (fs) for an analog file you select. Open the provided ADC lab code (soundcard_adc_lab2013b.m) in MATLAB by double clicking the soundcard_adc_lab2013b.m file in the a2d-matlab folder you created on your desktop. Briefly review the program. (You don t have to be able to reproduce it, but you should have a general understanding of what it does.) %%%%%%%%%%%%%%%%% % SAMPLING CODE % %%%%%%%%%%%%%%%%% % Clear out memory and initialize default settings % % DO NOT CHANGE THIS SECTION % clear all close all set(0,'defaultaxesfontsize',20) set(0,'defaultaxesfontweight','bold') % Load "Analog" Audio File % % The following variables are loaded into the workspace: % % audio -- The audio samples % % time -- The corresponding timevector % % ADD/REMOVE COMMENT (%) ONLY WHEN DIRECTED % load('4_khz_tone.mat'); %load('lorde_royals.mat'); %load('imagine_dragons_radioactive.mat'); %load('blink_182_midnight.mat'); %load('lady_gaga_applause.mat'); 3

% Setup major variables % % CHANGE FS (ONLY) TO CHANGE SAMPLING FREQUENCY % % Note fs = 96000/N, where N is an INTEGER % % Valid fs = 48 khz, 32 khz, 24 khz, etc. % fs = 48e3; % Sampling frequency in Hz % Get audio samples % % DO NOT CHANGE THIS SECTION % [sampled_time, sampled_audio] = sample(time,audio,fs); % Plot time and frequency % % CHANGE AXIS "COMMENT" (%) ONLY WHEN DIRECTED % [freq, power] = get_spectrum(sampled_audio, fs); figure subplot(2,1,1) plot(sampled_time,sampled_audio,'ko-') xlabel('time (sec)') ylabel('amplitude') axis([2 2.00226 -.5.5]) %axis([2 2.2 -.5.5]) title('sampled Signal vs. Time and Frequency') subplot(2,1,2) plot(freq/1e3,power,'k-') xlabel('frequency (khz)') ylabel('relative Power (db)') axis([0 20-60 1]) 4

Question 5: What does the soundcard_adc_lab2013b.m program do? What variable do you manipulate? The sampling code loads an analog-like audio file, which you can select by uncommenting (removing the % from) the beginning of the line of the selected file in the Load Analog Audio File section, reproduced below. Initially, the code is set up to sample a 4 khz tone. % Load "Analog" Audio File % % The following variables are loaded into the workspace: % % audio -- The audio samples % % time -- The corresponding timevector % % ADD/REMOVE COMMENT (%) ONLY WHEN DIRECTED % load('4_khz_tone.mat'); %load('lorde_royals.mat'); %load('imagine_dragons_radioactive.mat'); %load('blink_182_midnight.mat'); %load('lady_gaga_applause.mat'); Question 6: What sampling frequency (fs) must be exceeded for the 4 khz tone in order to ensure that aliasing is always avoided? Listen to the 4 khz audio file by typing load( 4_kHz_tone.mat ) into the MATLAB command window, pressing <enter>, and then typing soundsc(audio,96000) and pressing <enter> as shown below. You should hear several seconds of the 4 khz tone through your laptop speakers. If you don t, adjust your speaker settings so you can hear the 4 khz tone. 5

Adjust the sampling frequency in your MATLAB code to the value obtained in Question 6. Press to sample the tone. When the program obtains 5 seconds of samples, a display of the signal in the time domain and frequency domain will appear. Use the marker in the Figure 1 window to determine the frequency of the sampled signal from the (bottom) frequency domain plot. Question 7: Is the frequency of the sampled signal still 4 khz? Play back your sampled signal by typing soundsc(sampled_audio,fs) in the MATLAB Command Window (as shown). You should hear the samples you captured. 6

Question 8: Does the sampled tone you played sound the same as your original tone? Why or why not? If your sampled signal did not display 10 or fewer periods, use the zoom icon in the Figure 1 window to zoom in on the time domain plot. Question 9: Count to determine how many times the sine wave was sampled per period. Now change your sampling frequency to 48 khz. Press to sample the tone at your new sampling frequency. Question 10: Count to determine how many times the sine wave was sampled per period. Does this make sense with your new sampling frequency? Why or why not? Now change your sampling frequency to 6 khz. 7

Question 11: Is your new sampling frequency greater than fn? What phenomenon will result? Press to sample the tone at your new sampling frequency and type soundsc(sampled_audio,fs) to play it back. Question 12: Can you hear the difference between your sampled signal and the 4 khz analog tone? What frequency does your undersampled signal appear to be? (Hint: Use to determine the frequency from the frequency domain plot.) Part III: Sampling a Tune Since listening to a 4 khz tone is about a much fun as watching paint dry, let s try something more practical. Your soundcard_adc_lab2013b.m program also includes selections from Lorde, Imagine Dragons, Blink 182, and Lady Gaga. Select your favorite artist by adding a comment (%) to the beginning of the 4 khz tone and removing the comment from your selected tune. Add % Remove % % Load "Analog" Audio File % % The following variables are loaded into the workspace: % % audio -- The audio samples % % time -- The corresponding timevector % % ADD/REMOVE COMMENT (%) ONLY WHEN DIRECTED % %load('4_khz_tone.mat'); %load('lorde_royals.mat'); load('imagine_dragons_radioactive.mat'); %load('blink_182_midnight.mat'); %load('lady_gaga_applause.mat'); Change the commented line in the Plot time and frequency section of the MATLAB code so that the first axis line has a % at the beginning and the second does not. % Plot time and frequency % % CHANGE AXIS "COMMENT" (%) ONLY WHEN DIRECTED % [freq, power] = get_spectrum(sampled_audio, fs); figure 8

subplot(2,1,1) plot(sampled_time,sampled_audio,'ko-') xlabel('time (sec)') ylabel('amplitude') %axis([2 2.00226 -.5.5]) axis([2 2.2 -.5.5]) title('sampled Signal vs. Time and Frequency') subplot(2,1,2) plot(freq/1e3,power,'k-') xlabel('frequency (khz)') The generally accepted standard range of audible frequencies is 20 to 20,000 Hz, so let s assume that the highest frequency in whatever you chose as your groove is 20 khz. Question 13: What sampling rate should be exceeded in order to avoid aliasing? Sample your music at 48 khz (close enough) and play it back by typing soundsc(sampled_audio,fs) Does it sound right? Question 14: Undersample your song (so that aliasing occurs): 8 khz should do it. Play it back & compare the frequency content to the previous plot. How is it different? In reality, most CD-quality digital audio systems sample at a minimum of 44.1 khz and use 16-bit quantization. DVD-quality audio samples at 96 khz and uses 24-bit quantization. Question 15: How many quantization levels result from a 16-bit A/D converter? A 24-bit A/D converter? Question 16: Suppose the samples of your song are depicted by the image below. If a system uses an 8- bit quantizer (A/D converter), how many bits represent each sample, and how many quantization levels result? 9

Question 17: If the 1 st sample falls into level 0, the 2 nd sample falls into level 150, the 3 rd sample falls into level 192, the 4 th sample falls into level 131, and the 5 th sample falls into level 84, what is the bit stream that represents the beginning of your signal (in binary)? Question 18: What is the significance of the bit stream obtained in Question 17? Question 19: What does the red outline in the figure below represent? Assoc. Prof. Chris Anderson and LCDR Jennie Wood 10

Name: Question 1: Question 2: Question 3: Question 4: Question 5: Question 6: Question 7: Question 8: Question 9: Question 10: Question 11: 11

Question 12: Question 13: Question 14: Question 15: Question 16: Question 17: Question 18: Question 19: 12