frequencyspectra.s2014

6
8/21/2019 FrequencySpectra.s2014 http://slidepdf.com/reader/full/frequencyspectras2014 1/6 Experiment # 7 Frequency Spectra (Fourier Transforms)and Spectrograms PHYS/MUS 102—Spring 2014 Background Why do two instruments sound different even when the same note is struck, sung, plucked? The answer lies in the nature of the instrument. Depending on how instrument’s geometry and mode of operation, the waveforms it produces will differ, thus the sound we perceive will defer. The difference in waveforms can be quantified by  Harmonic Series Analysis  (aka  Frequency Spectrum Analysis  aka  Fourier Transforms ) Fortunately, no matter how complicated the waveform, Fourier came along and told us “Fear not! Everything can just be decomposed (or synthesized) from a harmonic series of sine waves.” The “mixture” of waveforms can be easily visualized and assessed in a  frequency spectrum . This is simply a plot that tells us how much of each harmonic to include in order to sum up to the recorded/final waveform. In this lab, you will explore various aspects of Fourier transforms and applications thereof. Theory Any  periodic function  x(t) can be expressed as a sum of sines or cosines—or equivalently as a sum of sines which can have a phase lag: x(t) = A o  + A 1  sin(2πf 1 t) + B 1  cos(2πf 1 t) + A 2  sin(2πf 2 t) + B 2  cos(2πf 2 t) + ...  (1) where the the coefficients  A n  and  B n  (n  = 0, 1, 2, 3,  ...) tell us how much of each sin and cosine wave at frequency  f n  =  nf 1  to mix together to add up to get the final waveform  x(t). It is the magnitude of the √ A n  + B n  that are plotted vs frequency  f  in a  frequency spectrum . Experiment Fourier Synthesis: Synthesize Me To start, let’s build some intuition regarding how sine waves in a harmonic series can be added up to get a more exotic (arbitrary) waveform. To do this, you will use a computer-based  Fourier synthesizer . Navigate to this url 1 :  http://www.falstad.com/fourier/ 1 You may need to download and install the latest version of java to get this to run properly. In the instructor’s experience, google chrome is the easiest to use in terms of security settings and updating java versions. 1

Upload: yasheive-saadi

Post on 07-Aug-2018

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 1/6

Experiment # 7Frequency Spectra (Fourier Transforms)and Spectrograms

PHYS/MUS 102—Spring 2014

Background

Why do two instruments sound different even when the same note is struck, sung, plucked? Theanswer lies in the nature of the instrument. Depending on how instrument’s geometry and mode of operation, the waveforms it produces will differ, thus the sound we perceive will defer. The differencein waveforms can be quantified by   Harmonic Series Analysis   (aka   Frequency Spectrum 

Analysis   aka   Fourier Transforms) Fortunately, no matter how complicated the waveform,Fourier came along and told us “Fear not! Everything can just be decomposed (or synthesized)from a harmonic series of sine waves.” The “mixture” of waveforms can be easily visualized andassessed in a  frequency spectrum . This is simply a plot that tells us how much of each harmonicto include in order to sum up to the recorded/final waveform. In this lab, you will explore variousaspects of Fourier transforms and applications thereof.

Theory

Any   periodic function  x(t) can be expressed as a sum of sines or cosines—or equivalently as a sumof sines which can have a phase lag:

x(t) = Ao + A1 sin(2πf 1t) + B1 cos(2πf 1t) + A2 sin(2πf 2t) + B2 cos(2πf 2t) + . . .   (1)

where the the coefficients  An  and  Bn   (n  = 0, 1, 2, 3,   . . .) tell us how much of each sin and cosinewave at frequency   f n   =  nf 1  to mix together to add up to get the final waveform  x(t). It is the

magnitude of the

√ An

 +Bn

 that are plotted vs frequency f 

  in a  frequency spectrum 

.

Experiment

Fourier Synthesis: Synthesize Me

To start, let’s build some intuition regarding how sine waves in a harmonic series can be addedup to get a more exotic (arbitrary) waveform. To do this, you will use a computer-based  Fourier 

synthesizer .

Navigate to this url1:   http://www.falstad.com/fourier/

1You may need to download and install the latest version of java to get this to run properly. In the instructor’sexperience, google chrome is the easiest to use in terms of security settings and updating java versions.

1

Page 2: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 2/6

Have a play with the applet, synthesizing various waveforms using only sine waves. You canchange the fundamental frequency using the slider toward bottom, right. Note the values of thecoefficients An  and carefully observe the  timbre. (Make sure the box labeled ”Sound” is checked.)Next, turn all of the sine wave coefficients back to zero, then set all the series of cosine coefficients(Bn) to be the same values as you had for the sine wave coefficients. Compare and contrast whatyou hear? Does the timbre depend on if you use sines vs. consines. Lastly, make a mix of sinesand cosines by setting the  An  back to their previous value (don’t adjust the  Bn). Does the soundquality change at all? The vast majority of humans can’t tell the difference, the point being that

only the frequency content matters, not the actual waveform shape.

Quick tips/hints: wear headphones and/or keep your volume low. Else you are likely to driveyour neighbors insane. Also, a richer mix of waves is typically much more pleasing to the ear. Seeif you can synthesize a waveform that sounds like a particular instrument. Be sure to clearly statewhat instrument you were trying to replicate and what note you are ”playing”.

Next, adjust the coefficients as necessary in order to synthesize some or all of the following. Of course, try your best to achieve the desired waveform before just hitting the button to give you theanswer.

1. Square Wave

2. Sawtooth Wave

3. Triangle Wave

Consult Fig.   1   for what these (standard) waveforms look like. Choose an arbitrary “basefrequency” (fundamental frequency) of 110 Hz—two octaves below concert A440.

Compare and contrast the Fourier coefficients you found in a general sense. You should noticesome significant differences in the frequency spectra (or  harmonic structure). For instance, for

which waveforms above are the odd harmonics most dominant, which waveforms rely mostly on just a few of the harmonic series, etc?

Decomposing Beethoven’s 5th

No doubt you are familiar with the opening bars of Beethoven’s 5th symphony and its trippletrhythm landing on a sustained chord: dum-dum-dum-DUM! But what are these famous chords?Your task is to find out. Enter: harmonic series analysis!

Download a clip of the first 10 sec of Beethoven’s 5th Symphony, 1st Movement (played bythe Dresden Symphony). The file is available here:   http://home.wlu.edu/~ericksonj/phys102_

s2014.html

Below are some very specific instructions about how to use computer software to do this.

2

Page 3: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 3/6

Figure 1: Basic waveforms. Use the Fourier synthesizer to build these using a sum of sine waves ina harmonic series

1. Launch Audacity, then open the file you jus downloaded. Highlight and zoom in on thesection of interest. You want to analyze only a single note/chord at a time, so somethinglike 100 msec worth of data should be  plenty . If you highlight to much data, say 500 msec,you’ll be cropping a section with multiple notes, so it would be difficult to tell which notesare playing in the opening.

2. Export this cropped selection as a .wav format sound file for further analysis. To do this,navigate to File  >>   Export Selection as WAV. Important: when saving the file, save toyour h: drive, or other network drive. You will need to access this file while using theStablethestable.wlu.edu.

3. For frequency analysis of the .wav file you will use MATLAB (a powerful software packagethat is particularly good at computing and displaying frequency spectra). To access matlab,log on to the stable:   thestable.wlu.edu. Choose the “computational and scientific software”option. From the windows start menu, launch MATLAB. Up near the top of the commandwindow, you will see three dots in a button which you can press. Doing so launches a pop-upasking you to navigate to a folder (“directory”). Be absolutely certain to choose the folder inwhich you just saved your .wav file(s).

4. Now, download the frequency spectra analysis script from the course webpage (it is a .m file).Save this file to exactly the same folder where your .wav files are. Do NOT place it in asubfolder/directory.

To test whether everything is working ok, type at the command prompt:>>   which freqAnalysis

You should see a directory/folder returned as text. Otherwise, if you get a message like“freqAnalysis not found” something has gone wrong. Consult the instructor for help asneeded.

3

Page 4: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 4/6

5. Now to use the function, you can type at the command prompt something like:>>FFT = freqAnalysis(’pianoE4.wav’, [0 3000]);

This says to matlab “please analyze the audio file pianoE4.wav, compute the Fourier trans-form, and display the results for all frequencies between 0–3000 Hz. Of course you need tochange the file name to whatever you named your file. Also, you may want to change thefrequency limits to something more conducive for viewing, should you have mostly very lowfrequency content, or high frequency content. Don’t forget the square brackets around 0 and3000—they are essential! If all goes well, the computer should think for a few seconds, then

output a nice graph of the frequency spectra, which you can then analyze in detail. I highlyrecommend saving and/or printing out frequency spectra. You’ll want them for discussion inyour final report.

6. For each of the opening four chords of Beethoven’s 5th symphony, include a plot of thefrequency spectrum, annotated clearly to show how you determined which notes (pitches)were sounding. Also, denote the pitches sounded by the orchestra using the standard bassand treble clef shown below. What is the name of each of these chords (e.g., C major, E-flatminor, etc.). You may find the following chart helpful, it lists the notes of the 12-tone westernscale with corresponding frequencies:   http://www.phy.mtu.edu/~suits/notefreqs.html

(a) Chord 1 (b) Chord 2 (c) Chord 3 (d) Chord 4

Figure 2: Bass and Treble Clefs. Use them to sketch out the chords of Beethoven’s immortal 5th.

Human voice

Are men from Mars, women from Venus? We’re not going to solve (or even weigh in!) on thatage-old conundrum, but we will investigate differences in the human voice in various ways.

Compare the sound quality and spectrograms for the following pairs:

1. Male vs female voice saying the same phrase.

2. News anchor or radio personality vs “average” voice. Ideas: compare Brian Williams (NBCnews) to a nerdy TV character’s voice; or Katie Couric to whomever (Miiley Cyrus? Pleaseno. =) ) Maybe even compare their voice to yours!

4

Page 5: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 5/6

Here’s how you will accomplish this task. You’ll use a RadioShack brand condenser microphoneand  Audacity   software to record sounds/voice. For this exercise, do NOT rely on your built inlaptop microphone. It is a low fidelity recording device. The condenser mic offers much betterrecording quality. Plug in the mic to your laptop before launching audacity. Make sure the mic isswitched on. Then launch Audacity. Before recording in Audacity, you’ll need to set the microphoneinput to “Microphone.” To do this, navigate toward the upper-right of the audacity window. Youshould see a drop down box with the desired selection. See Fig.   3, which highlights where to makethis change:

Figure 3: Screenshot from audacity showing where to change the source input for recording. Itshould be set to “Microphone”, NOT “digital mic”.

Obtain clips of a famous personality talking via youtube, or elsewhere on the internet. Startplaying the clip while you simultaneously record the sound with condenser mic. You may need

to play around with positioning of the mic, or the mic input sensitivity controls in audacity foroptimal recording (just to the left of where you changed the input source). Just a short clip willdo–something like 2-5 s should be plenty.

One other important note: do NOT use the version of audacity through theStable—you won’tbe able to record anything. The computer you are working on isn’t sophisticated enough to shareaudio measurements with the computer “in the cloud”, which you are accessing through the stable.Instead, download a local copy of audacity on to the computer or your laptop from the followinglink (’tis free!).   http://audacity.sourceforge.net/download/   Do NOT use download linksother than the one explicitly listed here (they could be pirated version, malware, etc.)

When you are finished recording, highlight and zoom in on some selections that look interesting

to study. Something like a few sec worth of data should be plenty. You will export this selectionas a .wav format sound file for further analysis.

For frequency analysis of the .wav file you will use MATLAB. However, you will use a differentanalysis script this time. Download the spectrogram analysis script from the course webpage (it isa .m file). Save this file to exactly the same folder where your .wav files are. Do NOT place it in asubfolder/directory.

To test whether everything is working ok, type at the command prompt:>>   which drawSpectrogram

You should see a directory/path returned as text. Otherwise, if you get a message like “drawSpec-trogram not found” something has gone wrong. Consult the instructor for help as needed.

Now to use the function, you’ll need to consult and carefully read the directions found by typing:>>help drawSpectrogram.

5

Page 6: FrequencySpectra.s2014

8/21/2019 FrequencySpectra.s2014

http://slidepdf.com/reader/full/frequencyspectras2014 6/6

The default values suggested under “Example:” should be good for now.

In your report, comment on the sound difference you perceive relative to the frequency content,as revealed in the frequency spectra plot. Can you identify characteristics common to “good” or“soothing” famous voices relative to the average joe? Make substantial qualitative comments, andbe quantitative in your discussion, referring to the frequency spectra as much as possible.

Choose your own Adventure!

Lastly, develop your own little mini-project involving frequency spectra analysis and musical in-struments. Be creative and study whatever aspect is interesting to you! If you are stuck (doubt youwill be) consult the instructor for ideas. To help get the wheels turning : you could compare soundquality from various instruments (piano vs guitar). Or compare sound quality on the differentmakes/models of the same instrument (e.g. an upright piano vs a grand (your friend singing vsyour own pipes); an acoustic guitar vs electric. Anything and everything is possible, so let yourimagination run wild!

For your report, describe what you studied, and present your main findings. You should defi-

nitely discuss what you heard in relation to how that manifested in the frequency spectra.

Report

You will make an oral report only; You do NOT need to make a written report. The Oral reportshould cover: 1) Your Beethoven ”decomposition”; 2) Human voice results; 3) Choose your ownadventure. Emphasize number 3 in your presentation. Be sure to clearly explain what you wereinvestigating, your methods for investigating it, results (frequency spectra and or spectrograms),and how you interpreted the results. Each group/presenter will be allotted 15 total minutes for a

presentation. Make judicious use of powerpoint/prezi/whatever software for visual aids.

You will be graded on the following criteria

•   Presenters spoke audibly and clearly

•  Visual aids used effectively

•  Clarity, concision,organization of presentation.

•  Technical accuracy and thoroughness.

6