Sunteți pe pagina 1din 11

12/26/2017

Analog and Digital - Analog

Analog and Digital - Analog

< CS101

The words analog and digital are used a lot, but what do they mean? Here we'll look at those two worlds which you use every day.

Signals

We are surrounded by signalsWhat does that mean? A signal is a varying wave over time e.g. sound as

What does that mean?We are surrounded by signals A signal is a varying wave over time e.g. sound as

A signal is a varying wave over time signal is a varying wave over time

e.g. sound as a running example hereWe are surrounded by signals What does that mean? A signal is a varying wave over

A signal is a varying wave, typically carrying information we care about. Sound is a great example

of a signal, and we'll use that as a running example today.

a signal, and we'll use that as a running example today. How Does Sound Work? Sound

How Does Sound Work?

Sound is vibrations, small waves of pressure in the aire.g. violin: 1. Strings vibrate under the bow, pulling on their ends, a signal 2.

e.g. violin:Sound is vibrations, small waves of pressure in the air 1. Strings vibrate under the bow,

1. Strings vibrate under the bow, pulling on their ends, a signal

2. the wooden violin top flexes in and out (same signal)

3. The wood flex creates pressure waves in the air (same

signal)

4. The waves travel through the air, ultimately pushing on the

eardrum, recreating the signal

12/26/2017

Analog and Digital - Analog

12/26/2017 Analog and Digital - Analog Analog Process The violin sequence is an example of an

Analog Process

The violin sequence is an example of an analog process -Have a continuously varying signal -Transfers from one medium to the next -Keeping analog process -Have a continuously varying signal -Transfers from one medium to the next -Keeping its basic shape

Great moments in etymology:from one medium to the next -Keeping its basic shape - analogy is a related word

-analogy is a related word

Many old technologies are analog (pre-computer)to the next -Keeping its basic shape Great moments in etymology: - analogy is a related

Why is digital better?its basic shape Great moments in etymology: - analogy is a related word Many old technologies

Sound is vibrations in the air over time -- essentially small changes in air pressure over time. When a violin plays, the wood top and back of the instrument flex in and out, producing little ripples of air pressure which flow out from the violin, like ripples in a pond. When the ripples hit an ear drum, it vibrates back and forth with the pressure changes, translating them into something your brain can sense. Your brain can easily distinguish the sound of a violin or voice or pipe organ playing the same note, but it is hard to put the differences into words. This is a very analog sequence -- the signal goes from one medium to the next, keeping its basic shape.

Oscilloscope

An oscilloscope really embodies the idea of analog. An oscilloscope connects to wires, looks at the electrical signal varying over time, and draws that signal on its screen in real time. Voltage is on the vertical axis, and time is the horizontal axis. So the oscilloscope takes in something pretty abstract -- signal varying over time -- and makes it visual.

12/26/2017

Analog and Digital - Analog

12/26/2017 Analog and Digital - Analog Sound Demo -- Synthesizer and Oscilloscope For this demo, I

Sound Demo -- Synthesizer and Oscilloscope

For this demo, I have a music synthesizer hooked up to speakers, and also hooked up to an oscilloscope so we can see the signal at the same time that we hear it. Demo: musical synthesizer, oscilloscope, notes, frequency, amplitude, timbre.

DemoScreen is 1/100 of a sec across Signal is drawn over itself See: frequency, amplitude,

Screen is 1/100 of a sec acrossDemo Signal is drawn over itself See: frequency, amplitude, timbre

Signal is drawn over itselfDemo Screen is 1/100 of a sec across See: frequency, amplitude, timbre

See: frequency, amplitude, timbreDemo Screen is 1/100 of a sec across Signal is drawn over itself

Frequency, Amplitude, Timbre

Sound often as a repeated up/down patternIf waves are a consistent width peak to peak, e.g. 1/400th of a second, we

If waves are a consistent width peak to peak, e.g. 1/400th of a second, we hear a "note"Sound often as a repeated up/down pattern Amplitude -- how high/low the wave goes, higher amplitude

Amplitude -- how high/low the wave goes, higher amplitude = louder -- how high/low the wave goes, higher amplitude = louder

Frequency is how often the wave repeats per second "higher" note = more cycles per second is how often the wave repeats per second "higher" note = more cycles per second --Middle "A" on the piano -- 440 cycles --Higher "A" note, one octave up -- 880 cycles (exactly 2x) --Even higher "A", another octave up, 1760 cycles (2x again)

All these "A" notes sound alike, but octaves apart"A", another octave up, 1760 cycles (2x again) An eerie relationship in our brains between music

An eerie relationship in our brains between music and mathAll these "A" notes sound alike, but octaves apart Timbre -- the shape of the wave

Timbre -- the shape of the wave sounds different --Sine wave pure tone, vs. flute playing -- the shape of the wave sounds different --Sine wave pure tone, vs. flute playing the same note

Below are oscilloscope screenshots for various notes. The width of the oscilloscope screen here is 1/100th of a second. The little random jags are just random noise from the cheesy, duct-tape way I wired this all together. The horizontal green line in the screenshots is an unimportant artifact of the oscilloscope. It represents a height value for which the oscilloscope tries to freeze the wave, hitting the y axis right at that value.

12/26/2017

Low C note, sine wave:

Analog and Digital - Analog

12/26/2017 Low C note, sine wave: Analog and Digital - Analog C note, one octave higher

C note, one octave higher (double the cycles per second):

C note, one octave higher (double the cycles per second): https://web.stanford.edu/class/cs101/analog-digital-1.html

12/26/2017

Analog and Digital - Analog

Same C note as above, but now a flute timbre (shape) instead of sine wave:

above, but now a flute timbre (shape) instead of sine wave: Very often the sound --

Very often the sound -- or "signal" -- has a repetitive up/down pattern, with the peaks of the curves hitting at a regular interval, such as every 400th of a second. We hear a regular, repeating cycle like this as a musical "note". If the repeating pattern is a mathematically smooth sine wave, we hear it as a very pure, bell-like sound.

Frequency -- suppose a signal repeats 100 times per second, also known as 100 "cycles" per

second, that's a frequency of 100. If the signal repeats more rapidly, we hear that as a "higher" note. An "octave" in music corresponds exactly to a doubling in frequency (i.e. twice as many up/down cycles in the same amount of time). The musical tuning standard is that A above middle C on a piano keyboard is 440 cycles per second. Going up to the next higher A note (about one hand's width on the piano) is 880 cycles per second (double the frequency). These two "A" notes sound similar to us, but one is higher. And of course there's next higher A at 1760 cycles, and

higher still

each time doubling the frequency.

Amplitude is the word for the height and depth that the signal makes on each cycle, corresponding to loudness. Big vertical swings are loud, small vertical swings are quiet. Or phrased as air pressure, bigger changes in air pressure sound louder. The timbre of the sound is the fine pattern of shapes and wiggles that can seen on the signal. So a flute "A" note has a timbre, varying a little around the basic 440 cycle pattern, and a trumpet playing that same note has a different timbre on the basic 440 cycle pattern.

There's Just One Air - Sum

There is just one body of air that fills a room. All of our ears are in it. A sound (vibrations) in this body of air, travels out to all our ears almost instantaneously at about 1000 feet/second. So what happens when multiple sounds are going into the air at once? The sound signals add, making a "sum" signal. The sum signal goes to your ears, and somehow your ear and brain are able to pull out and hear the component sounds.

12/26/2017

Here again is the low-C note:

Analog and Digital - Analog

Here again is the low-C note: Analog and Digital - Analog Here is a high-C note,

Here is a high-C note, 3 octaves above the low-C. You can see that the frequency is much higher many more cycles per second.

the frequency is much higher many more cycles per second. What Goes In Your Ear -

What Goes In Your Ear - Sum

What happens to the air if the low-C and high-C sounds are playing at the same time? The two signals add together in the air. Here is the combination of low-c and high-c playing simultaneously. You can see how the high note is added on top of the more slow changing low note. Your ear takes in this signal, and pulls it apart so you hear both the low note and the high note. It's impressive

12/26/2017

Analog and Digital - Analog

that the ear can take in this jumbled signal, and pull out and hear the constituents.

this jumbled signal, and pull out and hear the constituents. As another example, here is low-C

As another example, here is low-C and the C note one octave higher:

example, here is low-C and the C note one octave higher: https://web.stanford.edu/class/cs101/analog-digital-1.html

12/26/2017

Analog and Digital - Analog

12/26/2017 Analog and Digital - Analog What does the sum of the above two look like?

What does the sum of the above two look like? To convince yourself of the sum behavior, you can draw the two signals on graph paper, manually measure the heights and do the addition, to verify that the sum indeed looks like this:

the addition, to verify that the sum indeed looks like this: Noise-Cancelling Headphones This "sum" idea

Noise-Cancelling Headphones

This "sum" idea is how noise-cancelling headphones work -- detecting the ambient sound and creating an exactly opposite sound (multiplying by -1) to feed into your ear, so they cancel out leaving silence.

When Chords Sound Good - Harmony - Discord - Math!

12/26/2017

Analog and Digital - Analog

A chord is 2 or more notes playing at once

A

chord is 2 or more notes playing at once

Chords sound good when the peaks/valleys match up regularly - harmony

Chords sound good when the peaks/valleys match up regularly - harmony

e.g. a a note played with the note at 2x the frequency (i.e. up one

e.g. a a note played with the note at 2x the frequency (i.e. up one octave) -a ratio of 1:2 -Every other wave, the peaks will match up

A perfect-5th chord, the waves are in the ratio 3:2, so every

A

perfect-5th chord, the waves are in the ratio 3:2, so every

3rd peak will match

When ratios are slightly off, the chord sounds terrible - discord -e.g. 3:1.9 instead of

When ratios are slightly off, the chord sounds terrible - discord -e.g. 3:1.9 instead of 3:2 -e.g. 3:1.9 the peaks almost never match up

Neat: when the math is "even" the chord sounds good

Neat: when the math is "even" the chord sounds good

There is a theory that music connects to our brains more deeply than words

There is a theory that music connects to our brains more deeply than words

Like if an alien visited the earth:

Like if an alien visited the earth:

We explain discord makes us uncomfortable but harmony we

like

Alien would conclude a deep relationship between sound and our brains

Signal Sum Discord Demo

Try making chord/discord combinationsWe see the "sum" wave of both notes added together 1:2 3:2 chords sound good

We see the "sum" wave of both notes added togetherTry making chord/discord combinations 1:2 3:2 chords sound good ("harmony") But 3:1.9 sounds bad Peaks not

1:2 3:2 chords sound good ("harmony")We see the "sum" wave of both notes added together But 3:1.9 sounds bad Peaks not

But 3:1.9 sounds badboth notes added together 1:2 3:2 chords sound good ("harmony") Peaks not matching up! Somehow this

Peaks not matching up!of both notes added together 1:2 3:2 chords sound good ("harmony") But 3:1.9 sounds bad Somehow

Somehow this is in our DNAof both notes added together 1:2 3:2 chords sound good ("harmony") But 3:1.9 sounds bad Peaks

Analog Technology

Analog is the pre-digital way of transmitting or storing a signal. Examples:

Analog: Original Phone System

The first telephone was very analog, and in fact the wired phone in your house still works this way (an example of network effect inertia). Follow the trail of the sound signal.

12/26/2017

Analog and Digital - Analog

At the other phone, speaker has magnets connected to a paper cone -- converts the incoming electrical wave back into sound wavesAnalog! Desired signal keeps its shape, moves across mediums

Analog!cone -- converts the incoming electrical wave back into sound waves Desired signal keeps its shape,

Desired signal keeps its shape, moves across mediumsspeaker has magnets connected to a paper cone -- converts the incoming electrical wave back into

Desired signal keeps its shape, moves across mediums A person talks into the phone receiver. Their

A person talks into the phone receiver. Their voice is vibrations in the air -- a signal.Desired signal keeps its shape, moves across mediums The phone receiver contains a microphone where the

The phone receiver contains a microphone where the vibrations in the air move a tiny coil of wire. The movement of the wires sets up tiny electrical flow that is in one-to-one correspondence withreceiver. Their voice is vibrations in the air -- a signal. the air vibrations. Essentially we

the air vibrations. Essentially we translate a signal in the air, to an analogous signal of electricity in wires.

The electrical signal travels out of the house to the phone company, gets amplified etc. and is eventually delivered to the phone at the other end,.in the air, to an analogous signal of electricity in wires. There the electricity goes into

There the electricity goes into a speaker -- a speaker is just an arrangement of wires and magnets to translate electrical variations back to sound (the reverse of the microphone).and is eventually delivered to the phone at the other end,. The key feature of analog

The key feature of analog signaling is 1-1 correspondencevariations back to sound (the reverse of the microphone). variations (a signal) in one medium such

variations (a signal) in one medium

such as sound in the air, are translated to variations in some other domain like electricity in wires. The signals in the different domains are in 1-1 correspondence -- one goes up, the other goes up.

Analog - LP Records

Analog LP recordSound wave is recorded as hills and valleys in the plastic groove Playback needle rides

Sound wave is recorded as hills and valleys in the plastic grooveAnalog LP record Playback needle rides in the groove, jiggles up and down, makes a little

Playback needle rides in the groove, jiggles up and down, makes a little electrical signalAnalog LP record Sound wave is recorded as hills and valleys in the plastic groove

The old LP record format is totally analog. The sound signal is recorded as little hills and valleys in the plastic groove that runs around the record. For playback, a needle sits in the groove, the record spins, and the hills and valleys make tiny up and down movements of the needle. The needle is hooked up, in essence, to a microphone-like device which translates the up-down movement of the needle to an electrical signal, which eventually is sent to the speakers to translate the signal back into sound.

Analog: AM and FM Radio

Examples of analog technology you may still use. FM is more noise-resistant, but still analog.

Analog and Noise -- Hiss

12/26/2017

Analog and Digital - Analog

Signal does not go through microphones, wires, magnets, etc. perfectlyEach step -- the wires, the magnets, etc. can introduce little errors "Noise" like little

Each step -- the wires, the magnets, etc. can introduce little errorsnot go through microphones, wires, magnets, etc. perfectly "Noise" like little random wiggles around the true

"Noise"-- the wires, the magnets, etc. can introduce little errors like little random wiggles around the

like little random wiggles around the true signal (+

there are other error forms)

Noise can sound like "hiss"like little random wiggles around the true signal (+ there are other error forms) e.g. AM

e.g. AM radio, cassette tapes

Pure signal, e.g. put into one end of the phone

tapes Pure signal, e.g. put into one end of the phone Signal + noise as it

Signal + noise as it comes out of the other end of the phone

Signal + noise as it comes out of the other end of the phone What do

What do "errors" look like in an analog system? The signal you care about is translated from sound to electricity and so on. With each translation step, little errors creep in. The microphone has a little stiffness, the wires don't carry the signal perfectly, and so on. The errors are called "noise" -- you can imagine the pure sound signal you wanted but it's been distorted by little up/down errors -- like fuzzy variations around the true signal.

This is the "hiss" you hear on the phone line or an AM radio or a cassette tape technologies. Why do digital translations of music sound so much better?

all analog