LAB 1 Machine Perception of Music Computer Science , Winter Quarter 2006

Similar documents
DSP First Lab 02: Introduction to Complex Exponentials

COS 116 The Computational Universe Laboratory 4: Digital Sound and Music

CSC 101: Lab #7 Digital Audio Due Date: 5:00pm, day after lab session

Digital Audio. Amplitude Analogue signal

Assignment 5 Audio & Files in MATLAB Due Friday, November 16, 11:59 pm

FRYE ELECTRONICS, INC.

COS 116 The Computational Universe Laboratory 4: Digital Sound and Music

Windows Movie Maker / Microsoft Photo Story Digital Video

Cassette2CD Wizard 2.05 User's Manual

DSP First. Laboratory Exercise #1. Introduction to MATLAB

Lab P-1: Introduction to MATLAB. 3. Learn a little about advanced programming techniques for MATLAB, i.e., vectorization.

Audacity is FREE as defined by the Audacity design team. IU Kokomo students can download Audacity from IUware at

Lab 2 Functions in matlab and Playing Sounds

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

BEE 235 Continuous-Time Linear Systems

EE3210 Lab 1: Introduction to MATLAB

Problem Set 6 Audio Programming Out of 40 points. All parts due at 8pm on Thursday, November 29, 2012

Getting Help in Microsoft Office

Tutorial: GNU Radio Companion

Technical Note. Installation and use of the VT200 IP audio

Laboratory Exercise #5

Unix Computer To open MATLAB on a Unix computer, click on K-Menu >> Caedm Local Apps >> MATLAB.

Setting Up the Cassette2USB Recorder (Audacity): Double click on the desktop icon to launch the program. The initial screen will appear:

Tech Day Camtasia. What is Camtasia Studio?

Introduction to MATLAB

2 The Stata user interface

How To Upload Your Newsletter

Windows XP. A Quick Tour of Windows XP Features

User Guide. FTR Manager For more information visit

Small rectangles (and sometimes squares like this

ELEC ENG 4CL4 CONTROL SYSTEM DESIGN

Finding MATLAB on CAEDM Computers

Audacity Tutorial Recording With Your PC

Audio-Technica AT-LP60-USB, AT-LP120-USB, AT-LP240-USB & AT-LP1240-USB Turntables. Software Guide

WebEx Recorder and Player

As CCS starts up, a splash screen similar to one shown below will appear.

ADOBE PRESENTER Version 7.0 for Windows PowerPoint 2007 (for Windows only)

D CLIENT for DIRECTOR/DIRECTOR PRO Series Publishing System Operator s Guide

Setting up FT3000 and version on Windows 7. This is a step by step guide for setting up the FT3000 on a new Windows 7 or 8 PC

How to Make a Podcast

Revealing Archaeology User Guide. Before you Begin. Running Revealing Archaeology from the CD-ROM. Installing Revealing Archaeology on Your Hard Drive

Selection tool - for selecting the range of audio you want to edit or listen to.

PHYS 5061 Lab 1: Introduction to LabVIEW

Last Updated: October 12, Learning Ally ReadHear by gh for PC, Quick Start Guide

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

Adobe Sound Booth Tutorial

ECE4703 B Term Laboratory Assignment 1

Part I. Introduction to Linux

Lectora Audio Editor Information Center

Digital Music. You can download this file from Dig Music May

Konexx USB Phone 2 PC Products. White Paper

User Guide 1 Revealing Criminology User Guide Before you Begin Running Revealing Criminology from the DVD-ROM

Quick Guide to Getting Started with:

AT-LP2D-USB Turntable. Software Guide

George Mason University Signals and Systems I Spring 2016

INSTALLATION AND OPERATION MANUAL ARCHIVEREVIEW SOFTWARE

Start menu. Toggles between All Programs & Back

Click here for a PDF version of this tutorial. Start. MSTI 260 l HOME

As CCS starts up, a splash screen similar to one shown below will appear.

INTERNET ORDERING YOU ARE NOW READY TO START YOUR ORDER SETTING UP YOUR COMPUTER IT S AS EASY AS NOTE: WHEN LOADING

Not For Sale. Offline Scratch Development. Appendix B. Scratch 1.4

Avaya CallPilot Mini/150 Desktop Messaging Quick Reference Guide

Introduction to Audacity

Part III Appendices 165

Table of Contents 1. INTRODUCING DLL MODES AND SETTINGS IN DLL GENERAL DLL FEATURES...4

SBX Tutorial: Music On Hold

Impatica and PowerPoint for Blackboard

Scott D. Lipscomb. Music Education & Music Technology. Tenure Dossier. Electronic Dossier Instructions

Digital Media. Daniel Fuller ITEC 2110

1 of 24 5/6/2011 2:14 PM

EE168 Lab/Homework #1 Introduction to Digital Image Processing Handout #3

Quick Start XLe Source Expansion Kit

I / PM Express Imaging and Process Management Web Express. User Guide EWU s Web based Document Imaging solution

Step 10: Conversion to PDF

Microsoft Windows 7 - Illustrated Unit A: Introducing Windows 7

User's Guide. Voice Messaging and Fax Software. FaxTalk Communicator SETM

CHAPTER 1 COPYRIGHTED MATERIAL. Finding Your Way in the Inventor Interface

Copyright JAVS

Introduction. Requirements. Activation

Spreading a Sample Across the Pads

HW3: CS 110X C Domain Information. Final Version: 1/29/2014

Matlab for FMRI Module 1: the basics Instructor: Luis Hernandez-Garcia

Professor s Manual For Practice Set Programs

Using Windows 7 Explorer By Len Nasman, Bristol Village Computer Club

Section 6 Storage Space

Introduction to MATLAB

User s Guide for Polycom HDX Desktop Systems

Matlab is a tool to make our life easier. Keep that in mind. The best way to learn Matlab is through examples, at the computer.

Website Administration Manual, Part One

DSP Laboratory (EELE 4110) Lab#1 Introduction to Matlab

Getting Started with. Microsoft Office 2010

GETTING STARTED. 3. Once in the Portal, click on the WebEx icon in the upper right corner of the screen.

GETTING STARTED WITH MINITAB INTRODUCTION TO MINITAB STATISTICAL SOFTWARE

Using the Computer for Essays

SuperNova. Screen Reader. Version 14.0

LP2CD Wizard 2.0 User's Manual

2IN35 VLSI Programming Lab Work Assignment 1: Hardware design using Verilog

Section 2 Getting Started

General Guidelines: SAS Analyst

Transcription:

1.0 Lab overview and objectives This laboratory assignment will help you learn basic sound manipulation using MATLAB 7. Lab due time/date: 1pn, 1/11/2006 What to hand in: see Section 5 of this document Format of required submission: see Section 5 of this document Where/who/how to submit: see Section 5 of this document IMPORTANT NOTE #1: If you complete Lab 1 in the T-lab (see section 2.0), you will need to provide your OWN pair of headphones with a 1/8 inch male stereo connector. There is a jack on the back of every T-lab computer where you may connect your headphones. IMPORTANT NOTE #2: The labs in this course presume a basic familiarity with MATLAB. If you have never used MATLAB before, you should count on spending the time required to learn basic MATLAB programming before doing the lab requirements in Section 5. 2.0 Getting access to MATLAB 7 MATLAB 7 is installed on all computers running Windows in the T-lab (at the Tech end of the bridge between Ford and Tech ) 2.1 Getting a key for the T-lab Entry to the T-lab requires a Marlok key. There's a FAQ for getting a key here: http://www.ece.northwestern.edu/cfs/faq/keys_procedure.html 2.2 Getting an EECS computer account To log on to a T-lab machine, you will need an account and password provided by the EECS department. Every student registered for an EECS course should be given a computer account. This account is different from the standard account given to all Northwestern students for email purposes. After they create user accounts at the beginning of each quarter, the department will send an email to each student with account information. 3.0 MATLAB 7 basics This section is included to help those who have never used MATLAB 7.0. This section of the lab contains no required tasks. If you feel confident in your ability to navigate MATLAB, feel free to skip all of section 3. If this is your first time using MATLAB, you should plan on spending a few hours familiarizing yourself with it. This section gives you

some pointers to how to use MATLAB s help system to learn how to write simple scripts and display graphics. 3.1 Starting MATLAB While there is MATLAB is on both Linux and Windows XP in the T-lab computers. The Windows XP version of MATLAB 7 is better for our purposes than rather than the MATLAB installed on the Linux partition of the T-lab machines, as the Linux version of MATLAB lacks useful audio functions. To start MATLAB on a Microsoft Windows platform, select the Start -> Programs -> MATLAB 7.0 -> MATLAB 7.0, or double-click the MATLAB shortcut icon on your Windows desktop. 3.2 Learning the basics from MATLAB help *NOTE* Learning the basics of MATLAB can take time. Don t forget to schedule in a couple of evenings of playing with MATLAB into the time you need to do this lab.and yes, I know I said this in Section 1. It is worth saying again. All future labs presume knowledge of MATLAB. If you don t get up to speed during Lab 1, you may not catch up later. Once you have MATLAB running, go to the Help menu on the MATLAB window by selecting Help -> MATLAB Help. This will call up a window with two panes. The right pane contains help content. The left pane contains the Help Navigator, which lets you search through the help system in various ways. At the top of the help navigator pane are several tabs labeled Contents, Index, Search, Demos. Click on the Contents tab. This will reveal a list of topics with subheadings. Select MATLAB by double clicking on it. This will reveal a number of subsections. I suggest you select Getting Started and read the entire Getting Started section. While reading this section, copy and run the examples they give. This will give you a better feel for the workings of MATLAB. In order to learn the MATLAB desktop interface, I also suggest you look at the help section MATLAB-> Desktop Tools and Development. This will give you an overview of the command line, the editor, and other tools. No textbook for MATLAB is required for. That said, some prefer learning from books. Both Barnes and Noble (http://search.barnesandnoble.com) and Borders books (http://www.bordersstores.com/index.jsp) have stores in downtown Evanston where one get a book on MATLAB. 4.0 Basic sound manipulation in MATLAB 7 MATLAB provides the following functions to record and play sounds. Detailed descriptions of each function can be found in the MATLAB help system. Simply select the search tab in the Help Navigator pane and enter the name of the function in the Search for: box. Alternately, you can type help, followed by the name of the command on the MATLAB command line. For example: help beep

General Audio Functions audioplayer audiorecorder beep lin2mu mmfileinfo mu2lin sound soundsc - Create audio player object - Perform real-time audio capture - Produce beep sound - Convert linear audio signal to mu-law - Information about a multimedia file - Convert mu-law audio signal to linear - Convert vector into sound - Scale data and play as sound Microsoft WAVE Sound Functions wavplay - Play sound on PC-based audio output device wavread - Read Microsoft WAVE (.wav) sound file wavrecord - Record sound using PC-based audio input device wavwrite - Write Microsoft WAVE (.wav) sound file Important Signal Display functions spectrogram plot - display a spectrogram of a signal on the screen - plot a signal on the screen 4.1 Open an example Matlab has an example audio file you can load by doing the following at the command line: >> load mtlb See what variables have been loaded by typing: >> who You should see two variables, Fs and mtlb. The first is the sample frequency. The second is the audio recording. 4.2 Play the contents of a standard.wav file in MATLAB The three commands typically used to play an acoustic signal in MATLAB are sound, soundsc, and wavplay. First, look at the MATLAB help information for these three functions.

Now, type the following series of commands on the MATLAB command line to hear what happens.(note: If you are using a T-lab computer, you will need to have headphones plugged into the 1/8 inch stereo headphone jack on the computer). >> soundsc(mtlb, Fs) >> soundsc(mtlb, Fs /2) >> soundsc(mtlb, Fs *2) >> backwardssignal = mtlb(end:-1:1) >> soundsc(backwardssignal, Fs) Try playing the sound with the other two common sound playing functions. Is there any difference in how they work? 4.2 Display the contents of a standard.wav file in MATLAB It is often helpful to see the acoustic signal when working with it. The plot command is an easy-to-use data visualization function. To see what plot does, type the following: >> plot(mtlb) You should see a window appear that contains a time-amplitude representation of the audio signal you loaded into MATLAB. It would be a good idea for you to play with the toolbar at the top of the plot window. See if you can zoom in and zoom out using the toolbar. See if you can figure out how to print the figure. Learning how to do this stuff now will help you later. The zoom function can also be turned on via the command line. Type the following. >> zoom xon Now try clicking on the figure containing the display of the audio signal. It should zoom in the horizontal dimension, while leaving the vertical dimension unchanged. This will prove handy in section 5. A spectrogram shows the estimate of the relative amplitudes of a set of sinusoids used to approximate the wave form analyzed. A spectrogram can be created for the signal by doing the following >> spectrogram(mtlb,256,250,256,fs,'yaxis'); See MATLAB help for more details on use of the spectrogram function 4.4 Create a.wav file in MATLAB (only works in WINDOWS) So-called pure tones are formed by simple sine waves. It is easy to create a pure tone of any desired frequency in MATLAB using the trigonometric functions. Determine how long you want your tone to be. One second? Ten seconds? Once you have decided this, define a MATLAB variable containing that value.

>> duration = 2 Determine the sample rate (or frequency) you would like to use, as measured in Hertz (repetitions per second). Commonly used audio sample rates include 44,100 Hz (CD quality), 48,000 Hz (DAT tape), and 8000 Hz (telephone quality). Define a variable with this value. >> samplerate = 8000 Now, the number of samples needed is simply the sample rate multiplied by the duration >> numberofsamples = samplerate * duration Now, determine the frequency of the tone you wish to create. Like the sample rate, frequency of the tone is measured in Hertz. Here, I select the frequency of Middle C on the piano. This means that the sine wave should repeat 262 times per second. >> frequency = 262 Next, you should create a sequence of values that will be used to create a sine wave of the appropriate duration and frequency. >> maxval = frequency * duration * 2 * pi >> stepsize = maxval/(samplerate * duration) >> myvals = [0: stepsize: maxval] >> mysinewave = sin(myvals) Now display the sinewave sequence and play it. >> plot(mysinewave) >> soundsc(mysinewave, samplerate) Finally, save the sine wave as a.wav file >> filename = 'example.wav' >> wavwrite(mysinewave,samplerate,filename) 4.5 Create a function file in MATLAB You add new functions to the MATLAB vocabulary by expressing them in terms of existing functions. The existing commands and functions that compose the new function reside in a text file called an M-file. M-files can be either scripts or functions. Scripts are simply files containing a sequence of MATLAB statements. Functions make use of their own local variables and accept input arguments. The name of an M-file begins with an alphabetic character and has a filename extension of.m. The M-file name, less its

extension, is what MATLAB searches for when you try to use the script or function. A line at the top of a function M-file contains the syntax definition. The name of a function, as defined in the first line of the M-file, should be the same as the name of the file without the.m extension. For example, the existence of a file on disk called stat.m with function [mean,stdev] = stat(x) % any line starting with % is a comment in a MATLAB M-file n = length(x); mean = sum(x)/n; stdev = sqrt(sum((x-mean).^2/n)); defines a new function called stat that calculates the mean and standard deviation of a vector. The variables within the body of the function are all local variables. For more on MATLAB functions, go to the MATLAB help window and select the search tab from the Help Navigator pane of the help window. In the search for: field, enter function. The first entry should be function. Select this choice. A help page will appear that explains how to create a MATLAB function. Note: Select function and not functions. NOTE: MATLAB will only find your function if it is in the current directory or on the MATLAB path. The help system will tell you how to update the path. 5.0 Lab assignment 5.1 Make a function that makes a pitch For this lab, make a MATLAB function, makepitch that outputs a vector containing a sine wave of the given frequency. It should accept the following parameters duration samplerate frequency - the desired duration in seconds - the sample rate of the encoding, in Hz - the desired frequency of the signal, in Hz This function should return a MATLAB vector containing a sine wave which, if played at the given sample rate, will sound like a pitch of the desired frequency. We will test your function using an existing script. Given the following script, the sequence of commands should result in one second of the A above middle C on the piano. NOTE THE ORDER OF THE PARAMETERS! >> duration = 1 >> samplerate = 12000 >> frequency = 440 >> mysound = makepitch(duration, samplerate, frequency) >> wavplay(mysound, samplerate)

*NOTE* You are REQUIRED to place a comment in the file containing your function stating your name and email address. This comment MUST be the second line in the file. Thus, when someone types the following at the command line. >> help makepitch your name and email address should be included in the resulting output. 5.2 The major scale The C major scale, starting on Middle C of a typical piano, is the set of pitches that sound when playing the white keys from Middle C to the C one octave above it. The following table shows the frequency, in Hertz, of each pitch in this scale. Name C D E F G A B C Freq 262 294 330 349 392 440 494 524 Create a.wav file whose sample rate is 8000 Hz and whose content is the C major scale, from middle C to the C one octave above middle C. Each note in the C major scale should last ½ second. The entire file should last four seconds. The name of this file MUST be of the format <firstname>_<lastname>_scale.wav. Thus, if your name is Billy Budd, the file must be called billy_budd_scale.wav. Hint: This will be easier if you use the function created in 5.1 and learn to concatenate vectors. Consult MATLAB help to figure out how to append one vector to the end of another. 5.3 Adding two signals Load the major scale you created in 5.2 as a signal in MATLAB. You can do this using the wavread function. Then, load the mtlb signal as you did in Section 4.1. Now, add the two signals together so that, if played, the sound from the file in 5.3 plays simultaneously with the one from section 5.2. Save the resulting signal to a file..the name of this file MUST be of the format <firstname>_<lastname>_both.wav. Thus, if your name is Billy Budd, the file must be called billy_budd_both.wav. 5.4 Harmonic and non harmonic tones Harmonic sounds are generally considered to be sounds whose primary frequency components are all integer multiples of a fundamental frequency within the range of human hearing (20 to 20,000 Hz). Create a harmonic sound composed of three sine waves in the range of human hearing.save this as <firstname>_<lastname>_harmonic.wav. Create a non-harmonic sound composed of three sine waves in the range of human hearing. Save this as <firstname>_<lastname>_nonharmonic.wav. Now create a random signal (also known as white noise ) by using the rand function.

y = rand(8000,1); LAB 1 Save this as <firstname>_<lastname>_noise.wav. 5.4 Handing in your assignment You need to hand in the following: 1) A file, makepitch.m, containing your implementation of the function makepitch, as described in section 5.1 2) The.wav file created in section 5.2. 3) The.wav file created in section 5.3 4) The three.wav files created in section 5.4 How to submit assignments: 1. Create a zip file of your assignment if there is more than one file to submit* 2. Go to http://www.northwestern.edu/student/ 3. In the QUICK LINKS column, click on Course Management System (Blackboard) 4. Log in 5. Click on the link to this course in "My Courses" 6. Click on the Tools link 7. Click on Digital Drop Box 8. Click on Send File. 9. Ignore the drop down menu next to Select File and instead make the Title "Assignment X", where X is the number of the assignment. 10. Browse for your zip file. 11. Click submit. 12. Click OK and you're done. *Freeware zip programs, such as 7-Zip, are available on the web. I will accept single files submitted one after the other for an assignment, but would prefer zipped submissions.