% ECE 1250 Lecture 1 % % PowerPoint presentation: Sound Overview %---------------------------------------- % % Matlab¨ is a computer language that is especially useful when processing large arrays % of numbers, such as images, speech, or experimental data. % Matlab¨ has features similar to C or Java, but is distinctive for the following % collection of features: % 1) Variable types do not have to be declared % 2) Array sizes do not have to be declared and may change when necessary % 3) Array operations are simple and well-supported % Matlab also has some quirks such as the following: % 1) Variables have invisible types assigned after certain (e.g., logical) operations % 2) Array functions behave differently when operating on one-dimensional versus two- % dimensional arrays % 3) Array indexing comes in many types and, though powerful, is a challenge to master % 4) Array operations may be embedded in equations allowing massive computations, but % deciphering the formulas can be a challenge % 5) Numerical values are not exact, so a result that should be zero may be shown as % e.g., 1e-16 % Nevertheless, Matlab¨ is the industry standard for solving numerical problems, and it % is a very useful language once you master it. % Launching Matlab¨: % Double click on icon that is orange and blue 3D plot of surface % Primer p. 1-3 % The Matlab¨ desktop: % 1) Current Folder (put code here and Matlab¨ will find it) % 2) Workspace (shows what values are stored by Matlab¨ in named variables) % 3) Command History (previous commands, use arrow keys, too) % 4) Command Window (type commands into the glorified graphing calculator that is Matlab¨) % Housekeeping: % 1) Use Preferences in MATLAB menu to set print format to compact % 2) Change current folder to Desktop so Matlab can find files % 3) >> pwd % print current directory % 4) Use Set Path under File Menu to add desired folder to where Matlab¨ looks % for files (remember to Save before you Close the Set Path window) % 5) Use arrow keys to reuse previous commands (Primer p. 1-5) % Cool things Matlab¨ can do: >> load handel % load a snippet of Handel's "Messiah" >> sound(y) % play the snippet of "Messiah" stored in variable "y" >> plot(y(1:200)) % Shows us what the sound waveform looks like >> y = y(2000:4048)*0.3; % extract a portion of the sound waveform >> sound(y) % "ah" sound >> plot(abs(fft(y(2000:4048)))) % Shows the frequencies in the "ah" sound % Our goal in the labs will be to analyze sounds and then create a sound effect. % Matlab¨ works like a calculator, but everything is typed out: >> sin(pi) % pi is built-in constant. % The answer should have been zero, but Matlab¨ is numerical and rounds off. Be careful. sqrt(-1) % The square root of -1 is imaginary. Matlab¨ is okay with that. % Some things not in the early part of the book but Very useful: % 1) Put a semicolon ; at the end of a command to suppress printout. Very handy for % huge arrays you don't want to see. % 2) Use the >>diary on and >>diary off commands to create a file containing % a transcript of your Matlab¨ session, input and output.