+ All Categories
Home > Documents > Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf ·...

Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf ·...

Date post: 28-Mar-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
16
P.Mease 2009 | Freshman Clinic Fall 2009 | Lab 3 1 Lab 3 In the HarmonicsFRESHMAN CLINIC FALL 2009 CREATED BY P. MEASE, 2009 [1] OBJECTIVES In this lab, you will connect mathematical signals to physical quantities, materialized as sound, and ultimately timbre. You will experiment with real signals and listen to the effects of changing various parameters. You will record actual instruments (a woodwind, string, and brass) for analysis and create three simulated (or ‘synthesized’) instruments by combining and experimenting with only sinusoid, triangle, sawtooth, and square waveforms i.e. you’ll be making make your first basic instrument synthesizer! WARNING: There will be MATLAB I NTRODUCTION & BACKGROUND Signals that we hear every day are normally realized viewed in what we call the ‘time domain.’ This domain represents the signals in two dimensions. In an ‘x-y’ graph or plot, the x would be time, in seconds, minutes, or some other unit of time and the y direction represents the signal’s amplitude. The time domain is very intuitive because it is directly mapped to what we experience on a daily basis. We are used to time because everything we do has a time component. Without thinking, we wait for class, the bus, or the dinner timer to go off all in units of time. A ‘signal’ can be many things, even something as simple as the force by our footsteps as we walk or run. If we want to figure out the frequency of our footsteps, we would simply count the number of steps over some time window. If you were running from the clutches of an angry bear, for example, the rate of our steps (or frequency of our footstep signal) may be calculated by counting how many times your feet strike the ground in one minute: You came up with: 100 steps/minute (and luckily escaped a potential mauling). Since frequency is in ‘number of times’ per second, we need to simply divide using the factor label method: 100 steps min 1 min 60 sec = 1.667 Hz TIP: USE UNITS PROPERLY!
Transcript
Page 1: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 1

Lab 3 – “In the Harmonics”

FRESHMAN CLINIC – FALL 2009 CREATED BY P. MEASE, 2009

[1]

OBJECTIVES

In this lab, you will connect mathematical signals to physical quantities, materialized as sound, and ultimately

timbre. You will experiment with real signals and listen to the effects of changing various parameters. You will

record actual instruments (a woodwind, string, and brass) for analysis and create three simulated (or ‘synthesized’)

instruments by combining and experimenting with only sinusoid, triangle, sawtooth, and square waveforms – i.e.

you’ll be making make your first basic instrument synthesizer!

WARNING: There wi l l be MATLAB

INTRODUCTION & BACKGROUND

Signals that we hear every day are normally realized viewed in what we call the ‘time domain.’ This domain

represents the signals in two dimensions. In an ‘x-y’ graph or plot, the x would be time, in seconds, minutes, or

some other unit of time and the y direction represents the signal’s amplitude. The time domain is very intuitive

because it is directly mapped to what we experience on a daily basis. We are used to time because everything we

do has a time component. Without thinking, we wait for class, the bus, or the dinner timer to go off – all in units of

time.

A ‘signal’ can be many things, even something as simple as the force by our footsteps as we walk or run. If we

want to figure out the frequency of our footsteps, we would simply count the number of steps over some time

window. If you were running from the clutches of an angry bear, for example, the rate of our steps (or frequency

of our footstep signal) may be calculated by counting how many times your feet strike the ground in one minute:

You came up with: 100 steps/minute (and luckily escaped a potential mauling).

Since frequency is in ‘number of times’ per second, we need to simply divide using the factor label method:

100 steps

min

1 min

60 sec = 1.667 Hz

TIP: USE UNITS PROPERLY!

Page 2: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 2

The frequency of our steps would be 1.667 Hz. From frequency, we can directly get the amount of time it takes us

to make one step. This time is called the ‘period.’ This period is the distance between the steps during our flee for

dear life and is defined as:

𝑇 =1

𝑓

where f is frequency (in Hz) and T is period (in seconds)

In our example:

𝑇 =1

𝑓=

1

1.667 Hz= 0.60 s

In this example, I forgot to mention that you also had robotic legs (Figure 1) and each step was precisely the same

time, or period, between the next footstep.

Figure 1. Hybrid robot-fisher/camper.

This makes this signal ‘periodic’ because the steps occur at a constant frequency. This means that at anytime we

take the period measurement anywhere in the 1 minute window, it is the same. The signal may be represented

something like this:

Figure 2. Stepping at fixed frequency.

Page 3: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 3

So what if we wanted to view the frequency of our footsteps just like we can view time in the time domain on the

simple x-y plot? Luckily, there already exists such a thing: the ‘frequency domain.’ This domain is just like our time

domain representation except that now the x axis is no longer time but ‘frequency.’ The frequency domain can tell

us many things including ‘how fast’ a time-domain signal is changing.

This lab relies heavily on viewing a signal in the frequency domain (the signal’s spectrum). From the spectral view,

we can look at the frequency content of any time domain signal in an easy, intuitive format. The spectrum of the

above signal will look like this:

Figure 3. Spectrum of a pure single frequency sinusoid.

By the way, the transformation of a signal from the time domain to the frequency domain is made possible by the

Fourier Transform, named after the French mathematician Joseph Fourier (pronounced “4-yay” – see Figure 4).

His name will come up again in your near future and will make your life much easier. Here he is (cue angelic

ambiance):

Figure 4. Jean Baptiste Joseph Fourier.

Print this picture and add it with your other idols in your sacred candle-lit closet.

Page 4: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 4

READ THIS MANY TIMES: Mr. Fourier tells us that ANY SIGNAL can be represented as a sum of sinusoids. I’m going

to repeat this because you really should remember this: ANY SIGNAL CAN BE REPRESENTED AS A SUM OF SIMPLE

SINUSOIDS. One more time for good luck: ANY SIGNAL CAN BE REPRESENTED AS A SUM OF SIMPLE SINUSOIDS!

The ‘ANY SIGNAL’ part really means ANY SIGNAL. It could be another sinusoid, it could be a square or triangle

wave, it could be a highly complex radio signal – ANYTHING! I don’t know about you, but that is one BOLD

statement. Why? Because sinusoids are very easy signals to understand, visualize, create, analyze, etc… You will

later SEE and HEAR that this statement is not only true, so awesome it will fill you with joy beyond belief.

Now back to camping, let’s pretend that your camping adventure wasn’t for the purposes of social isolation and

you had a friend with you. Unfortunately, your friend has an older model of robotic legs installed and can’t run

quite as fast (don’t worry, your friend lives, I think). Over the 1 minute, your friend ran at a rate (or frequency) of 1

Hz, or one step every second.

If we took the spectrum of this new periodic signal, we would see something like in Figure 5.

Figure 5. Spectrum of combined pure sinusoids at two frequencies.

From the above ‘spectrum’ of both the foot signals, we can easily see the frequency content they contain. For

these examples, the time domain waveforms are very basic, but when signals are more complex, the frequency

domain is an invaluable tool. Don’t believe me? Turn on the oscilloscope visualization on one of your media

players and see if you can make sense out of it in the time domain!

Now let’s talk about harmonics. In the above examples, our time-domain signals were sinusoids so we’ll only see

their ‘fundamental’ frequency (remember this term) in the spectrum (recall Figures 3 and 5). This is kind of boring

so let’s plot something that is a little more interesting; a triangle wave (let’s say its frequency is 1 kHz or 1000 Hz):

Page 5: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 5

Figure 6. Triangle wave.

If we look at this signal in the frequency domain, we see its spectrum in Figure 7:

Figure 7. Spectrum of triangle wave.

A little different than the good-ol sinusoid, huh (or is it?)?! Because the signal has sharper ‘turns’ (at the tops and

bottoms of the triangle), ‘harmonics’ trickle well outside the 1 kHz fundamental. Harmonics are the integer-

multiple frequency components off the fundamental. For the pure triangle wave, only odd harmonics are

produced. Different signals will have different harmonic content. These components (excluding the fundamental)

are called overtones or partials. The spectrum of a signal displays how a signal may sound to us.

You may be saying to yourself: “wait… this is great for looking at signals in this new thing called the ‘frequency

domain’ but how do these harmonics relate to something real, like an instrument?!” Thanks for asking! If we look

closely at a vibrating string (like that on a harp or guitar), you can actually catch these harmonics with your eye if

you look real close and you pluck a low enough note. These harmonics make themselves present as vibrating

modes shown in Figure 8.

Page 6: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 6

Figure 8. Vibrating modes. Image source: [2]

Many things will affect the spectral content and correspondingly, how an instrument sounds (which is its timbre –

pronounced “tamber”). This includes its shape, what material(s) it’s made from, the room acoustics, the player,

and many other factors. Instruments such as the flute have very pure sinusoidal-esk outputs whereas the clarinet

has much more complex harmonic content.

I will leave you with one more pondering thought: In Figure 3, we see the spectrum of a pure sinusoid whose

frequency is 1.667Hz, which is represented as a single spike. In Figure 7, we see the spectrum of a triangle wave,

which has many ‘spikes’ whose frequencies lie at odd multiples of the fundamental frequency. What would

happen if we took a few simple sinusoids like those in Figure 3, made their frequencies odd multiples of some

fundamental frequency, then added them up? Do you think we’d obtain the same spectrum as in Figure 7?

EQUIPMENT & SOFTWARE

Rope

Audio Interface – FireBox

Mixing Console (or MATLAB)

Headphones/Speakers

Breakout Box

Arbitrary Function Generator

Oscilloscope

Laptop/PC

Cabling: BNC, BNC Tee, etc…

Microphone

DAW - Reaper

Flute

Trumpet

Guitar + Amp

MATLAB

Page 7: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 7

PROCEDURE

Part 1 – Wet Feet in the ECE Lab

- Grab a section of rope approximately 2 m long. Tie one end of the rope to a tree or bench. Have a

partner looking at it from the side.

o Move the jump rope and create a simple primary wave (see the first wave in Figure 8).

NOTE: It is very difficult to get the rope to work as a string if you are moving it in just one

direction since the ends are essentially fixed. A string also does not simply vibrate in one

plane. Therefore, try rotating the rope first then slowly restricting arm movement, switching

to wrist till both ends are ‘fixed.’

o Now try and get the center of the rope to become stationary by flicking the rope at about

twice the speed. This is the octave harmonic or 2 * ffundamental and can be seen in the second

wave in Figure 8. See if you can get any more modes out of the rope – it will become more

difficult as frequency increases. If you can get 4 or 5, then you should flap both hands and

fly away.

- Back in the lab, create and listen to common signals (sin, saw, tri, square, and noise) using the

function generator. Connect the function generator, scope, and PC speakers as shown in Figure 9.

Figure 9. Connectivity diagram. The function generator generates and outputs signals, the oscilloscope

reads signals, the BNC tee splits the signal from the function generator into two, the breakout box simply

converts a BNC connection to the 3.5mm stereo jack, and the PC speakers play sound.

- Experiment with both the amplitude and frequency of the signals. Listen!

o Now capture these signals’ spectra using the oscilloscope while varying the frequency. See

the tutorial on my website for performing an FFT on the oscilloscope. Note where the

Page 8: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 8

harmonics or ‘partials’ lie in relation to the fundamental frequency. TIP: Audio signals have a

bandwidth between 20 Hz and 20 kHz. Make sure you select frequencies (and set the

spectrum analyzer’s range) somewhere in this band.

I warned you. Here comes the MATLAB…

- Experiment by combining two 1 second long sinusoids at different frequencies using MATLAB.

Hopefully by this point, you’ve at least went through the basic MATLAB tutorial I sent you. You can

make the sinusoid by first creating a time vector, then plugging that time vector into the sinusoid

function. Be sure to select a frequency that allows (at least) a few periods to be created. You also do

not want too many periods of the sinusoid in the 1 second window because, when you plot, you wont

be able to see the sinusoidal nature.

o Create the time vector:

>> t = linspace(start, finish, step)

where start is the start time (choose 0), finish is how long you want in seconds, and

step is how many ‘steps’ between start and finish

o Now create the sinusoid:

>> s = sin(2*pi*f*t)

where f is the frequency you want the sinusoid to be (in Hz) and t is the driving time

vector you just created (in seconds)

o Wanna see it? Me too…type: >> plot(t,x)

NOTE: If you wanted to remain clean from the clutches of coding, then I offer an apology (albeit, a

hollow one). Despite your gripes, MATLAB is the cheapest and quickest way to get a virtually

unlimited assortment of wacky signals. That and MATLAB is the greatest thing since sliced bread.

o Send the sinusoid you created in MATLAB to the function generator using the >>

writefunc(.) MATLAB function we’ve made especially for you. To figure out how to

connect everything and use this function, read the ‘Instrument Connectivity’ guide on my

website (found under Resources).

MATLAB IS BETTER

Page 9: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 9

o Observe the composite signal’s spectrum using the oscilloscope as before and vary the

sinusoids’ frequencies to see the changes. You may (and should) play with the sinusoid’s

parameters: frequency, duration, and amplitude. Amplitude of a signal can be changed by

multiplying it by a scalar. You want to be careful here since the function generator ONLY

wants amplitudes less than +/- 1. To play it safe, adjust amplitude by multiplying the signal

by a value less than 1.

Part 2 – Arm: Record: Play Instruments

- In this section, you will record (using the microphone, the FireBox audio interface, and Reaper) audio

clips of the following instruments (list may vary based on availability and student participation):

o Flute

Which looks like this:

o Trumpet

o Clean Guitar

o Distorted Guitar

Page 10: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 10

o Clarinet

o Snare Drum (or equivalent)

Recording Setup Here is a guide for recording audio onto your computer. Be sure to follow all steps:

- You must first connect the microphone to the MIC input (1 or 2) of the FireBox using a microphone

cable as shown below:

Page 11: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 11

- Now connect the other end of the microphone cable to the mic:

- Turn down all volumes on the FireBox, then connect the headphones to the ‘PHONES’ output on the

front of the FireBox:

Page 12: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 12

- Install the FireBox driver onto your computer. When prompted, connect one end of the Firewire

Cable to the FireBox and the other to your computer. The light on the FireBox should turn from RED

to BLUE. If it is RED, then there is no connectivity to your computer and the interface will not work.

- Now open Reaper on the host machine (if it is not installed, install it first, then reconnect the

FireBox). Click ‘File>New Project’. Now click on ‘Options>Preferences>Device’ under the Audio

heading. The Audio System should be ASIO and the ASIO driver should be ‘FireBox ASIO Driver’ or

something similar. The ‘Enable Inputs’ box should be checked. This is tiring, how about a picture

instead:

Page 13: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 13

- Now click on ‘Track>New Track’ (or Right Click on the track pane or just hit Ctrl-T). Now click on the

Record Arm ‘R’ Button on the channel strip and then the little speaker icon (circled below):

- Now set the FireBox’ ‘MAIN LEVEL’ Knob to the halfway point. Set the channel gain to about halfway,

then slowly increase the PHONES volume, while LIGHTLY tapping on the microphone or talking into it.

If it is faint, increase the channel gain. Monitor the VU meters in Reaper. If it is in the RED, turn the

gain down:

- TIP: Be sure the recorded audio is not clipping (especially with loud instruments). Clipping is when

the amplitude limits of the transducer (the microphone), the ADC (interface), and/or the DAW are

exceeded. This is BAD and the original signal cannot be recovered, furthermore, it will sound really

bad. Fortunately, all you have to worry about are the gain controls on the interface and in the

software. Make sure the meters on both the interface and the DAW are ‘not in the red’ and you’ll be

good.

Page 14: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 14

- Now you are ready to record audio! All you need to do now is click on the Main Record Button in the

transport. You stop it by clicking it again, or the stop button. You should get something that looks

like this:

- You can play back your recording by hitting the Play button, or by using the spacebar.

- Record each of the above instruments on a new track. The instrument should be playing a standard

concert A (440Hz) or some octave of A for about 5 seconds. For the snare drum a steady roll may

work well. BE SURE to mute and disarm the record button on all other tracks when you are recording

a new track. You should only have one record arm button armed at a time.

PART 3 – CREATE YOUR OWN SYNTH!

- Do this:

o Run the recorded audio sample of the recorded instruments through the FFT/Spectrum

Analyzer of the oscilloscope. You can do this by connecting the PHONES output of the

FireBox to the oscilloscope input and playing the file (loop it) OR playing the .wav file in a

media player (VLC works well) and taking the output of the PC soundcard, inputted to the

oscilloscope. If you use the latter method, you do not need the FireBox.

o At some point where the signal looks good (i.e. NOT when the loop is restarting!), press the

run/stop button on the oscilloscope then perform your screen capture. Be sure to press run

again when gathering new data.

- Analyze and compare the harmonic content of each of these signals by viewing their spectra. Be sure

to store all of these figures for later analysis! Listen closely to how each of these signals sound and

what each sound looks like in the frequency domain.

This is the audio

Page 15: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 15

- Using only MATLAB and the arbitrary function generator, try and recreate synthesized signals that

sound similar to the actual recorded instruments using ONLY basic sinusoids. You can combine or

‘mix’ multiple signals in MATLAB with a simple ‘+’ operation. Download the example MATLAB

synthesis m-file off my website for examples. This file shows how to create various basic signals using

just pure sinusoids.

- Why do sounds of the same pitch sound different? See the lab title! For now, you can ignore any

envelope parameters of your synthesizer such as attack and sustain.

o Be sure to compare the spectrum of both the audio signals you are attempting to synthesize

and your own created signals. You will be required to explain your findings.

DELIVERABLES - Formal Lab Report (click here for a template) including:

o MATLAB plots for time domain signals created in MATLAB with descriptions.

o Screen captures/plots of spectrum analysis for all waveforms with descriptions.

o Why is the frequency domain representation (or spectrum) of a time domain signal useful?

o Comment on each of the signals’ harmonic content and how the partials contribute to the

timbre of the sound.

o Why can you create any signal from only simple sinusoids (what makes this possible)?

o Explain your process to develop your own synthesized instruments from the obtained

instrument spectra. Offer suggestions for improvements that could make the synthesized

instrument sound more realistic (ONE HINT: ADSR).

o If Concert A is 440Hz, how to we find all octaves of this A? What are their frequencies?

o Brief list of contributions by each team member and out-of-class meeting time(s).

Be sure to spend ample time discussing both results and the solutions with your entire team. Be thorough

and precise in your statements. If you have any questions, please ask.

Page 16: Lab 3 In the Harmonics - Rowan Universityusers.rowan.edu/~mease/courses/frclinicf09/Lab_3.pdf · 2009-10-21 · Lab 3 – “In the Harmonics” FRESHMAN CLINIC – FALL 2009 CREATED

P.Mease 2009 | Freshman Clinic – Fall 2009 | Lab 3 16

SAFETY & LAB PROTOCOL - Be sure to turn down any headphone volumes BEFORE putting them on your head!

- Return all cabling neatly to the racks

- Clean your workspace when finished your experiment

- No food or drink allowed in the lab

- Take extreme care handling the instruments

- Do not stare directly at Tiny Tim:

RESOURCES Course webpage: http://users.rowan.edu/~mease/courses/frclinicf09/frclinicf09.html

Instrument connectivity: http://users.rowan.edu/~mease/resources/instrconn.html

REFERENCES [1] Image source: http://www.sacredpatterns.com/moreHyperStuff.htm

[2] Image source: http://upload.wikimedia.org/wikipedia/commons/4/4f/Moodswingerscale.jpg


Recommended