Download presentation
Presentation is loading. Please wait.
Published byJean Bradford Modified over 9 years ago
1
CS 102 Computers In Context (Multimedia) 03 / 30 / 2009 Instructor: Michael Eckmann
2
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Today’s Topics Questions/comments? Chapter 6 –Sound Physics of sound How digital sound is encoded How to read/manipulate sound w/ JES
3
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Sound Sounds are waves of air pressure. –think of ripples in water Waves have amplitude and frequency. –Amplitude is the distance from 0 to highest pressure (measured in force per area (N/m 2 )) Range in human hearing is 0.0002 N/m 2 - 200 N/m 2 –Frequency is the number of cycles per unit time (measured in Hz = cycles per second) Range in human hearing is 2 Hz – 22,000 Hz Amplitude affects our perception of volume. Frequency affects our perception of pitch.
4
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Sound encoding Analog sounds need to be sampled to be digitized. To be able to accurately convert back the digital to analog, we sample at 2 times the highest frequency in the sound. For example, CD quality audio is sampled at 44100 samples per second (which is about twice as much as the highest frequency that humans can hear.) CD quality sound encodes each sample in 16 bits. Unlike images, these sample values need both negative and positive values. One can store 2 16 different values in 16 bits. This is 65536 different values. The range w/ positive and negatives is: -32768 to 32767.
5
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 JES functions for sound filename = pickAFile() sound = makeSound(filename) samples = getSamples(sound) Does this look familiar at all?
6
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 JES functions for sound filename = pickAFile() sound = makeSound(filename) samples = getSamples(sound) Does this look familiar at all? filename = pickAFile() picture = makePicture(filename) pixels = getPixels(picture)
7
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 JES functions for sound We can get the length of the sound w/ getLength(____). This returns the number of samples in the sound. We can get a particular sample w/ getSampleValueAt(____, ____). This returns the 16 bit value of one sample. We can set a particular sample value w/ setSampleValueAt(_,_,_). We can save a sound w/ writeSoundTo(____,____). We can get the sampling rate of a sound w/ getSamplingRate(___). This is the number of samples per second. Also, getSample and setSample. Consider relationships to the image functions.
8
Michael Eckmann - Skidmore College - CS 102 - Spring 2009 Manipulating sound filename = pickAFile() sound = makeSound(filename) for sample in getSamples(sound): sampleVal = getSample(sample) setSample(sample, sampleVal*2) # this code will increase the volume of the sound by doubling # the amplitude
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.