Lecture 11
Representing Sound
Mark Horowitz
Stanford University
horowitz@ee.stanford.edu
Copyright © 2015 by Mark Horowitz
M. Horowitz
E40M Lecture 11
1
Learning Objectives
M. Horowitz
E40M Lecture 11
2
PREVIOUSLY IN E40M
M. Horowitz
E40M Lecture 11
3
We Constructed Our Plane
• We have an 6 x 6 array
– Logically looks like:
– Physically it is different
• Need to drive it
– To light up the lights
• For independent light control
– Either only one + wire high
– Or only one - wire low
– Max of 6 LEDs on at once
M. Horowitz
E40M Lecture 11
4
What is Sound Anyway?
• It is a pressure wave that moves in air
– Created by voice, instruments, speakers
http://www.mediacollege.com/audio/01/sound-waves.html
M. Horowitz
E40M Lecture 11
5
How Does a Speaker Create Sound?
• All speakers (and headphones) create sound the same way
• http://electronics.howstuffworks.com/speaker6.htm
• Power
– 100W stereo, Speakers are 8 Ω
• Vi =100; i=V/R V2 = 800
• V swing > +/- 30V
• So we represent sound by voltage
– Which varies in time
M. Horowitz
E40M Lecture 11
6
REPRESENTING SOUND
M. Horowitz
E40M Lecture 11
7
Natural Way To Represent Sound
• We create pressure waves by moving a speaker
– Larger voltage causes more deflection
• Sound both pushes and pulls the speaker cone
– Voltages are both + and –
• Represent sound by voltage vs. time
• On computers
– Sample voltage at 44K/sec
– Digitize the voltage
• Into 15 bit integer (signed)
– Raw = .wav; compressed .mp3
M. Horowitz
E40M Lecture 11
8
Analog Input into Arduino
• Connecting a voltage to an analog input to Arduino
• Arduino converter 0-5V signal into 10-bit digital value
• Value ranges from 0-1023
M. Horowitz
E40M Lecture 11
9
Seeing Sound (Demo)
M. Horowitz
E40M Lecture 11
10
Equalizers
• I think we have all seen this type of display
• What information does it represent?
M. Horowitz
E40M Lecture 11
11
Setting An Equalizer
• You might have even played with setting levels
• Ever think about what you are really doing here?
– The music is a set of voltages vs. time.
M. Horowitz
E40M Lecture 11
12
FREQUENCY SPECTRUM
M. Horowitz
E40M Lecture 11
13
Representing Signals In Different Ways
• While we can represent sound as a string of numbers
– Which represent voltage at different times
– Our brain doesn’t process sound that way
• We think and talk about sound/music as combinations of tones
– Summation of different sinewaves
– And you can represent sound this way too
• All signals can be represented in two ways
– Voltages in time
– Sum of tones of different amplitudes and frequencies
M. Horowitz
E40M Lecture 11
14
Demo
• Java applet from:
– http://www.falstad.com/fourier/index.htm
– But most browsers won’t run it any more (security issues)
– So it is posted with lecture notes fourier.jar
• Allows you to create waveform and see tones
– Or add tones and see waveform
M. Horowitz
E40M Lecture 11
15
Relating Voltage to Sinewaves
M. Horowitz
E40M Lecture 11
16
Viewed In Terms of Sine-waves
• So you can take the music and look sinewaves in a block of time
– Then repeat that for another block of time
– This analysis plots frequency vs. time – a spectrogram
M. Horowitz
E40M Lecture 11
17
FOURIER SERIES
M. Horowitz
E40M Lecture 11
18
Fourier Series
• The formal name for this alternative representation
• Officially it only works for repetitive signals
– Since sine-waves repeat
• There is an extension for non repetitive signals
– It is called the Fourier Transform
• Many people use Fourier series for a block of data
– And just assume that the block of data repeats
– That is what the java demo does
M. Horowitz
E40M Lecture 11
19
Formal Definition
•
M. Horowitz
E40M Lecture 11
20
Equation For A Square Wave
•
M. Horowitz
E40M Lecture 11
21
Why Worry About Frequency Domain Analysis?
• Sure it can make interesting light displays
– But really …
• Turns out it will be very helpful to understand circuits
– With Capacitors and Inductors in them
M. Horowitz
E40M Lecture 11
22