cs101 lecture 14: audio encoding - computer science · cs101 lecture 14: audio encoding sampling...
TRANSCRIPT
-
2/25/13
1
Computer Science
CS101 Lecture 14: Audio Encoding
Sampling Quantizing Aaron Stevens ([email protected]) with special guest Wayne Snyder ([email protected]) 25 February 2013
Computer Science
2
What You’ll Learn Today
How do we “hear” sounds? How can audio information (sounds) be stored on
a computer? How to reproduce the sounds from the binary
data?
-
2/25/13
2
Computer Science
3
Hearing
We “hear” sound when a series of air compressions vibrate a membrane in our ear. The inner ear sends signals to our brain. The rate of this vibration is measured in Hertz, and the human ear can hear sounds in the range of roughly 20Hz - 20KHz.
Computer Science
4
Sound Wave Properties
Wavelength: distance between waves (affects pitch -- high or low sounds)
Amplitude: strength of power of waves (volume)
Frequency: the number of times a wave occurs in a second – measured in Hertz.
-
2/25/13
3
Computer Science
Music Concepts
Pitch is the human perception of sounds as musical notes
Computer Science
6
Microphones and Speakers
Microphones convert acoustical energy (sound waves) into electrical energy (the audio signal).
Speakers do the same thing in reverse: convert electrical energy into acoustical energy.
-
2/25/13
4
Computer Science
7
Audio Playback
A stereo sends an electrical signal to a speaker to produce sound.
This signal is an analog representation of the sound wave. The voltage in the signal varies in direct proportion to the sound wave.
Computer Science
8
Important Note about Electronic Signals
An analog signal continually fluctuates in voltage up and down.
A digital signal has only a high or low state, which we model as binary digits.
-
2/25/13
5
Computer Science
Recall: Digitizing an Image
Sampling: Taking measurements (of color) at discrete locations within the image. Sampling rate: 16 samples per inch (in each direction)
Computer Science
Recall: Digitizing an Image
Sampling: Measure the color for each pixel, and record that color. 16 pixels per inch
Quantization: determine a discrete value for each pixel.
-
2/25/13
6
Computer Science
11
Digitizing Audio Information
How can we store this continuous information in a finite machine? Digitize the signal by sampling:
periodically measure the voltage record the numeric value
Computer Science
12
Sampling Audio Information
Sampling: periodically measure the voltage and record the numeric value. Some data is lost, but a reasonable sound is reproduced.
-
2/25/13
7
Computer Science
13
From Sound Wave to Sample
In this case, we are measuring the amplitude of the sound wave with 3 bits of precision (8 possible values, Y axis), at a sampling rate determined along the X axis. We record the values for each sample.
Computer Science
14
Sampling: 3-bit depth
For each sample, we need to select a discrete value for the amplitude. These values are recorded in 3 bits (right hand side).
-
2/25/13
8
Computer Science
15
From Sample to Sound Wave
Using the recorded information, the computer must re-recreate the sound wave. Some of the original information was lost by the sampling process!
Computer Science
16
Increasing Quality
To increate the quality of the recording, we can change 2 dimensions (independently): 1 - increase the sample rate (more points of measurement on X/time axis) 2 - increase the bit depth (more discrete levels of measurement on Y/amplitude axis).
-
2/25/13
9
Computer Science How Good is Good Enough? How would you determine the required: Sampling rate Bit depth (quantization of sound wave)
to recreate the best sensory audio experience?
Computer Science
Choosing a Sampling Rate
Consider this waveform. What sampling rate should we choose?
-
2/25/13
10
Computer Science
Choosing a Sampling Rate
How about this sampling rate? (6 samples)
Computer Science
Choosing a Sampling Rate
How about this sampling rate? (11 samples)
-
2/25/13
11
Computer Science
Choosing a Sampling Rate
How about this sampling rate? (21 samples)
Computer Science
Choosing a Sampling Rate
Consider this waveform, and these two sampling strategies. What’s going on here? A. B.
-
2/25/13
12
Computer Science
Nyquist Theorem
The Nyquist Theorem states that the sampling rate must be greater than twice the value of the highest frequency component of the analog signal.
Consider this waveform and sampling rate:
Computer Science
Waveform Audio File Format (.WAV Files)
These files store a bitstream of the audio samples: compatible with Window, MAC, Linux typically uncompressed
What are the benefits of an uncompressed format?
What are the drawbacks?
-
2/25/13
13
Computer Science
Recording a .WAV file.
Example: using Audacity to record a .WAV file. Recall: a speaker has an electromagnet, just like a microphone…
Computer Science
26
Representing Audio Information Compact Disc audio is encoded by sampling:
44,100 samples per second 16 bits per sample per channel (2 channels) thus: 44,100 * 16 * 2 = 1,411,200 bps Or about 10,600,000 bytes per minute
CD Audio uses about 10 megabytes of data per minute of audio.
-
2/25/13
14
Computer Science
27
Addendum to last time….
Computer Science
28
What You Learned Today
Hearing Sound waves Sampling, Sampling Rates Quantizing, Bit Depth Data storage requirements
-
2/25/13
15
Computer Science
29
Announcements and To Do
Readings: Wong ch 4, pp 102-117 (this week) YouTube: History of Sony music technology
http://www.youtube.com/watch?v=V5I41PdAK0Y (6 minutes)
Homework 6 due Wednesday 2/27