EGR 111 Audio Processing

Similar documents
Lab P-4: AM and FM Sinusoidal Signals. We have spent a lot of time learning about the properties of sinusoidal waveforms of the form: ) X

George Mason University Signals and Systems I Spring 2016

DSP First Lab 03: AM and FM Sinusoidal Signals. We have spent a lot of time learning about the properties of sinusoidal waveforms of the form: k=1

School of Engineering and Information Technology ASSESSMENT COVER SHEET

Data Analysis in MATLAB Lab 1: The speed limit of the nervous system (comparative conduction velocity)

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

Fourier Series and Gibbs Phenomenon

Sound synthesis with Pure Data

Figure 1: Block diagram of Digital signal processing

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

Laboratory Assignment 2 Signal Sampling, Manipulation, and Playback

DSP First Lab 4a: Synthesis of Sinusoidal Signals Speech Synthesis

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2

Lab 4 Fourier Series and the Gibbs Phenomenon

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

EE477 Digital Signal Processing Laboratory Exercise #13

Digital Signal Processing ETI

ELT COMMUNICATION THEORY

EEL 4350 Principles of Communication Project 2 Due Tuesday, February 10 at the Beginning of Class

UNIVERSITY OF WARWICK

Here are some of Matlab s complex number operators: conj Complex conjugate abs Magnitude. Angle (or phase) in radians

SIGNALS AND SYSTEMS LABORATORY 3: Construction of Signals in MATLAB

Electrical & Computer Engineering Technology

Digital Signal Processing ETI

Creating Digital Music

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering. EIE2106 Signal and System Analysis Lab 2 Fourier series

ECE 2713 Design Project Solution

BIOE 198MI Biomedical Data Analysis. Spring Semester Lab6: Signal processing and filter design

STANFORD UNIVERSITY. DEPARTMENT of ELECTRICAL ENGINEERING. EE 102B Spring 2013 Lab #05: Generating DTMF Signals

Armstrong Atlantic State University Engineering Studies MATLAB Marina Sound Processing Primer

Lab S-5: DLTI GUI and Nulling Filters. Please read through the information below prior to attending your lab.

Digital Signal Processing Laboratory 1: Discrete Time Signals with MATLAB

Recording your Voice Tutorials 3 - Basic Uses of Audacity Wayne B. Dickerson

Introduction to Simulink Assignment Companion Document

Laboratory Assignment 4. Fourier Sound Synthesis

UNIVERSITY OF WARWICK

C.8 Comb filters 462 APPENDIX C. LABORATORY EXERCISES

Computer Music in Undergraduate Digital Signal Processing

ECEGR Lab #8: Introduction to Simulink

GEORGIA INSTITUTE OF TECHNOLOGY. SCHOOL of ELECTRICAL and COMPUTER ENGINEERING

Laboration Exercises in Digital Signal Processing

EE 5410 Signal Processing

Lab S-7: Spectrograms of AM and FM Signals. 2. Study the frequency resolution of the spectrogram for two closely spaced sinusoids.

Signal Processing First Lab 02: Introduction to Complex Exponentials Multipath. x(t) = A cos(ωt + φ) = Re{Ae jφ e jωt }

Lab 4 An FPGA Based Digital System Design ReadMeFirst

Measuring Modulations

Laboratory 7: Active Filters

1 Introduction and Overview

Fall Music 320A Homework #2 Sinusoids, Complex Sinusoids 145 points Theory and Lab Problems Due Thursday 10/11/2018 before class

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

GEORGIA INSTITUTE OF TECHNOLOGY. SCHOOL of ELECTRICAL and COMPUTER ENGINEERING. ECE 2026 Summer 2018 Lab #8: Filter Design of FIR Filters

LAB 2 Machine Perception of Music Computer Science 395, Winter Quarter 2005

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

Lab 8: Frequency Response and Filtering

Spring 2018 EE 445S Real-Time Digital Signal Processing Laboratory Prof. Evans. Homework #1 Sinusoids, Transforms and Transfer Functions

Lab 1: Analog Modulations

EE 215 Semester Project SPECTRAL ANALYSIS USING FOURIER TRANSFORM

Lowpass A low pass filter allows low frequencies to pass through and attenuates high frequencies.

ECE 201: Introduction to Signal Analysis

DSP First. Laboratory Exercise #7. Everyday Sinusoidal Signals

Click on the numbered steps below to learn how to record and save audio using Audacity.

Experiment 1 Introduction to Simulink

EECE 323 Fundamentals of Digital Signal Processing. Spring Section A. Practical Homework MATLAB Application on Aliasing and Antialiasing

CS/NEUR125 Brains, Minds, and Machines. Due: Wednesday, February 8

ECE 3793 Matlab Project 4

C.11 Sampling and Aliasing Solution

Introduction to Simulink

ECE 2026 Summer 2016 Lab #08: Detecting DTMF Signals

Problem Set 1 (Solutions are due Mon )

Seeing Sound Waves. sound waves in many different forms, and you get to have fun making a loud mess.

UNIVERSITY OF UTAH ELECTRICAL AND COMPUTER ENGINEERING DEPARTMENT

PLEASE NOTE: EVERY ACTIVITY IN THIS SECTION MUST BE SAVED AS A WAV AND UPLOADED TO YOUR BOX.COM FOLDER FOR GRADING.

Signal Processing. Introduction

DSP First. Laboratory Exercise #4. AM and FM Sinusoidal Signals

Lab 6 - MCU CODEC IIR Filter ReadMeFirst

Lab Report #10 Alex Styborski, Daniel Telesman, and Josh Kauffman Group 12 Abstract

The Theremin was invented by Leon Theremin, a Russian scientist who was working on proximity sensors. It does, in fact, detect your body s proximity

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

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

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

Name That Tune: Matching musical tones through waveform analysis

Experiment 1 Introduction to MATLAB and Simulink

The Audio Synthesizer

ECE411 - Laboratory Exercise #1

DIGITAL SIGNAL PROCESSING TOOLS VERSION 4.0

LABORATORY - FREQUENCY ANALYSIS OF DISCRETE-TIME SIGNALS

MAE143A Signals & Systems - Homework 9, Winter 2015 due by the end of class Friday March 13, 2015.

Introduction to R Software Prof. Shalabh Department of Mathematics and Statistics Indian Institute of Technology, Kanpur

Lab 1: Analog Modulations

Signal Processing First Lab 20: Extracting Frequencies of Musical Tones

Forensics with TI-NspireTM Technology

Signal Processing First Lab 02: Introduction to Complex Exponentials Direction Finding. x(t) = A cos(ωt + φ) = Re{Ae jφ e jωt }

Lab 2: Digital Modulations

Stay Tuned: Sound Waveform Models

Sound Waves and Beats

Fundamentals of Digital Audio *

SP.718 Special Topics at Edgerton Center: D-Lab Health: Medical Technologies for the Developing World

When you load GarageBand it will open a window on your desktop that will look like this:

Experiment 9 AC Circuits

Sound is the human ear s perceived effect of pressure changes in the ambient air. Sound can be modeled as a function of time.

Transcription:

EGR 111 Audio Processing This lab shows how to load, play, create, and filter sounds and music with MATLAB. Resources (available on course website): speech1.wav, birds_jet_noise.wav New MATLAB commands: audioread, sound, soundsc, filter, fir1 1. Reversing a Vector In this section, we will learn how to reverse the order of the elements in a vector, and then in the next section we will reverse the order of a sound vector in order to play it backwards. As an example, generate the following vector: >> v = [10 20 30 40] We can copy the elements of the vector v and store them in the variable vc as follows: >> vc = v(1:end) vc = 10 20 30 40 Note that when the keyword end is used to index a vector, MATLAB replaces it with the length of the vector, so the command above is equivalent to vc = v([1 2 3 4]). If we reverse the order of the index values, then MATLAB will copy the elements in reverse order as follows: >> vr = v(end:-1:1) vr = 40 30 20 10 When the expression end:-1:1 is used to index a vector, it generates a vector starting with the length of the vector, with an increment of -1, and ending with the value 1. So vr = v(end:-1:1)is equivalent to vr = v([4 3 2 1]), which copies the elements of the vector v in reverse order. Exercise 1: Generate the vector x = 10:10:100, reverse the order of the elements, and store the result in a vector called xr. EGR111 - p. 1 of 7 - Audio Processing_rev3.docx

2. Play an Audio Signal Backwards In the previous lab we downloaded the EGR111 files (which included speech1.wav) and saved them in your P:\MATLAB folder. Change the Current Folder in MATLAB to P:\MATLAB. The MATLAB command audioread can be used to load.wav files into MATLAB as follows: [x,fs] = audioread('speech1.wav'); If you get an error message that says something like Error using audioread. The filename specified was not found in the MATLAB path., check to make sure that you have saved the file speech1.wav in P:\MATLAB and that you have changed the Current Folder to P:\MATLAB. See the previous lab for details. The audioread command above places the audio signal from the file speech1.wav into a vector called x and puts the sampling rate (in Hz) into a variable called fs. The sampling rate is the number of times that the original signal was measured per second. We can use the sound function to play the recording through the speakers as follows: sound(x,fs) If you play the sound back at a higher sampling rate, it increases the pitch. Type the following: sound(x,2*fs) Try playing the sound at a lower sampling rate to see how it sounds. Exercise 2: Write a script file that clears the workspace, loads the sound file speech1.wav into vector x, reverses the vector, and plays the reversed vector through the speakers. You may want to put a semi-colon at the end of the statements, so the sound data does not print to the screen. Also plot the original data and the reversed data. EGR111 - p. 2 of 7 - Audio Processing_rev3.docx

3. Generating Tones Consider the signal xx(tt) = AAAAAAAA(2ππff 0 tt) where A is the peak amplitude and f0 is the frequency of the cosine in Hz. Cosine is a periodic signal with a period of TT = 1 ff 0 seconds, so it repeats every T seconds. The MATLAB commands below create a cosine with a peak amplitude of 0.5 and a frequency of 500 Hz. The cosine is then plotted, and played through the speakers. The frequency of the cosine (500 Hz) determines the pitch, and the peak amplitude determines the loudness of the tone. The sampling rate (fs) is the number of times that the cosine is sampled (or evaluated) per second. clear % clear variables fo = 500; % frequency of the cosine (in Hz) A = 0.5 % peak amplitude fs = 44100; % sampling frequency (in Hz) Ts = 1/fs; % sampling interval (in Sec) t = 0:Ts:2; % sample every Ts seconds for 2 sec x = A*cos(2*pi*fo*t); % generate cosine plot(t,x) % plot cosine sound(x,fs) % play through speakers (no scaling) Exercise 3: a. Open the editor window (click on File, New, Script) and type the commands above into a MATLAB script file. b. Save the file as Anote.m and run the program by either clicking the run button near the top of the editor, or by typing the filename without.m into the command window: Anote c. The plot looks like a big blue screen because there are 1000 cycles squeezed into the graph. Use the zoom tool in the figure to zoom in on just one or two periods (see next page). EGR111 - p. 3 of 7 - Audio Processing_rev3.docx

Zoom Tool Click here, and drag to here Data Cursor Tool Click on graph EGR111 - p. 4 of 7 - Audio Processing_rev3.docx

d. Use the Data Cursor to measure the period (see previous page). Compare the measured period to the theoretical period. Are they close? e. Edit the.m file to change the frequency of the cosine (fo) and run the program again. How does changing the frequency change how the tone sounds? f. Change the peak amplitude (A). How does changing the amplitude change how the tone sounds? (The maximum amplitude that the sound card can handle is 1.0, so any values that are bigger than 1 are clipped before the signal is sent to the soundcard, and so the sound may be distorted. There is a command that scales the signal to prevent clipping and distortion called soundsc.) Checkpoint 1: Show the instructor your script file and results for Exercise 3 parts e and f. 5. Synthesizing Music The pitch of a musical note is determined by the frequency of the signal, with higher pitch corresponding to higher frequency. Look at the following webpage to see the list of frequencies and how they correspond to piano notes. http://en.wikipedia.org/wiki/piano_key_frequencies Note that the frequency of the A above middle C (which is called A4) is 440 Hz. What is the frequency of the next higher A (which is called A5)? What is the frequency of the A below middle C (which is called A3)? How does the frequency change between each octave? Let's make the A note above middle C (i.e. A4) sound for.5 seconds. Modify your Anote.m script file to make the frequency of the sinusoid be 440 Hz, run the file, and listen to the sound. Now modify the file to create the tone for the A an octave below middle C (A3). EGR111 - p. 5 of 7 - Audio Processing_rev3.docx

In order to play music we need to generate several notes and concatenate them together. If we want silence in between the notes, we can use the zero command to generate a vector of zeros and place this vector between the notes. The following commands generates the notes A, B, and C with 0.1 seconds of silence between each note. fs = 44100; % sampling frequency (in Hz) Ts = 1/fs; % sampling interval (in seconds) t = 0:Ts:1; % sample every Ts seconds for 1 second A = 0.5*cos(2*pi*440*t); % generate note A B = 0.5*cos(2*pi*493.883*t); % generate note B C = 0.5*cos(2*pi*523.251*t); % generate note C s = zeros(1,fs*0.1); % generate 0.1 second silence y = [A, s, B, s, C]; % concatenate notes soundsc(y, fs) % send to speakers (with autoscaling) Exercise 4: Create a script file to generate your own short piece of music that has at least 4 different notes and 3 rests (silent sections). Name the file song_lastname.m where lastname is replaced by your last name. You can re-create an existing song or make an original composition. The sheet music for the first few notes of Fur Elise are on the course website, in case you would like to synthesize that song. There is a tutorial on reading music at http://www.wikihow.com/read-music. Checkpoint 2: Show the instructor your commands and the results for Exercise 4. 6. Filters Most engines have an air filter that allows air to pass through the filter and into the engine, but the filter blocks larger particles like dust that would be harmful to the engine. A digital filter is a device that is used to block signals based not on their size, but on their frequency. For example, the antenna in an FM radio receives all of the radio stations added together. Since each station is assigned a different frequency, a filter can be used to block all of the stations except one, which is then played to the speakers. Without the filter, the output of a radio would be corrupted by all of the other radio stations and would be completely unusable. Filters are classified according to which frequencies they pass. A lowpass filter, for example, allows low frequency signals to pass and blocks high frequency signals. On the other hand, a highpass filter allows high frequency signals to pass and blocks low frequency signals. EGR111 - p. 6 of 7 - Audio Processing_rev3.docx

Load the file birds_jet_noise.wav into MATLAB and listen to it as follows: [x,fs] = audioread('birds_jet_noise.wav'); soundsc(x,fs) If you get an error message that says something like Error using audioread. The filename specified was not found in the MATLAB path., check to make sure that you have saved the file birds_jet_noise.wav in P:\MATLAB and that you have changed the Current Folder to P:\MATLAB. Notice that it is a recording of bird chirps with jet engine noise in the background. The jet engine noise is at frequencies below about 1800 Hz, and the bird chirps are above 1800 Hz. Use the following command to compute the filter coefficients for a lowpass filter with order 300 that passes frequencies below 1800 Hz (the jet engine noise) and removes frequencies above 1800 Hz (the bird chirps): b = fir1(300,1800/(fs/2)); Next pass the recording through the filter using the following command: y = filter(b,1,x); The new signal y is the output signal of the filter, and it has the same sampling rate as the input (fs). Now listen to output signal. Did the lowpass filter pass the jet noise and remove the bird chirps? The fir1 command can also be used to compute the coefficients for a highpass filter as follows: b = fir1(300,1800/(fs/2),'high'); Exercise 5: Use the fir1 command to compute the coefficients for a highpass filter and use those coefficients to filter the original signal x. Listen to the output of the highpass filter. Did the filter pass the bird chirps and remove the noise? Checkpoint 3: Play the results from Exercise 5 for your instructor. EGR111 - p. 7 of 7 - Audio Processing_rev3.docx