How sound works: Acoustics, the physics of sound

Slides:



Advertisements
Similar presentations
Introduction to Digital Audio
Advertisements

Georgia Institute of Technology Introduction to Processing Digital Sounds.
ITEC 109 Lecture 25 Sound.
Digital Signal Processing
Sound, Part 3. Multiple Echoes Here is a recipe to create multiple echoes: def echoes(sndfile, delay, num): s1 = makeSound(sndfile) ends1 = getLength(s1)
A Media Computation Cookbook Manipulating Images and Sounds for Use in Alice Part 1: Image Manipulations Part 2: Advanced Image Manipulations, e.g., changing.
Digital Audio.
Image and Sound Editing Raed S. Rasheed Sound What is sound? How is sound recorded? How is sound recorded digitally ? How does audio get digitized.
W2D1. JPEG images Representing avg. pixel colour for large vs. small blocks Idea behind the Fourier transform: Pixel values:
Computer Science 101 Introduction to Programming with Sounds.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 6: Modifying Sounds Using Loops.
Introduction to Sound Sounds are vibrations that travel though the air or some other medium A sound wave is an audible vibration that travels through.
Digital audio. In digital audio, the purpose of binary numbers is to express the values of samples that represent analog sound. (contrasted to MIDI binary.
Introduction to Interactive Media 10: Audio in Interactive Digital Media.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 7: Modifying Samples in a Range.
Lecture # 22 Audition, Audacity & Sound Editing Sound Representation.
DTC 354 Digital Storytelling Rebecca Goodrich. Wave made up of changes in air pressure by an object vibrating in a medium—water or air.
CompSci Today’s topics Sound Upcoming ä Intellectual property ä Network analysis ä Security Reading.
Computing with Digital Media: A Study of Humans and Technology Mark Guzdial, School of Interactive Computing.
COMP Representing Sound in a ComputerSound Course book - pages
Lecture 5: Signal Processing II EEN 112: Introduction to Electrical and Computer Engineering Professor Eric Rozier, 2/20/13.
Computer Some basic concepts. Binary number Why binary? Look at a decimal number: 3511 Look at a binary number: 1011 counting decimal binary
CompSci Today’s topics Sound Upcoming ä Sound splicing ä Intellectual property ä Network analysis Reading Introduction to Computing & Programming.
Basics of Digital Audio Outline  Introduction  Digitization of Sound  MIDI: Musical Instrument Digital Interface.
COSC 1P02 Introduction to Computer Science 4.1 Cosc 1P02 Week 4 Lecture slides “Programs are meant to be read by humans and only incidentally for computers.
Sound on the Web. Using Sound on a Web Site Conveying information  pronounce a word or describe a product Set a mood  music to match the web page scene.
Overview of Multimedia A multimedia presentation might contain: –Text –Animation –Digital Sound Effects –Voices –Video Clips –Photographic Stills –Music.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 8: Making Sounds by Combining Pieces.
Introduction to SOUND.
More Meaningful Jargon Or, All You Need to Know to Speak Like a Geek Sound.
Chapter 7: Modifying Samples in a Range. Chapter Objectives.
Georgia Institute of Technology Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Sept 2005.
Georgia Institute of Technology Processing Sound Ranges Barb Ericson Georgia Institute of Technology July 2005.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 7: Modifying Samples in a Range.
Properties of Sound Making Waves. Sound Waves ■Sound is created by vibrations.
Encoding and Simple Manipulation
CS 102 Computers In Context (Multimedia)‏ 03 / 30 / 2009 Instructor: Michael Eckmann.
Sound in Multimedia Psychology of sound what do you use it for? what techniques for its communication exist? Science of sound why does it exist? how it.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 6: Modifying Sounds Using Loops.
Intro-Sound-part1 Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Oct 2009.
CS1315: Introduction to Media Computation Sound Encoding and Manipulation.
Chapter 8: Modifying Samples in a Range. Chapter Objectives.
Multimedia Sound. What is Sound? Sound, sound wave, acoustics Sound is a continuous wave that travels through a medium Sound wave: energy causes disturbance.
1 CS 177 Week 8 Recitation Slides JES Sound functions and Modifying Sounds Increasing/Decreasing Volume Maximizing (Normalizing) Splicing Reversing Mirroring.
Session 18 The physics of sound and the manipulation of digital sounds.
1 CS 177 Week 7 Recitation Slides Modifying Sounds using Loops + Discussion of some Exam Questions.
Working with Sounds Barb Ericson College of Computing Georgia Institute of Technology
Introduction to Digital Audio
Fourier Analysis Patrice Koehl Department of Biological Sciences National University of Singapore
Data representation – Sound.
The Physics of Sound.
Learning Objectives Be able to explain how sound can be sampled and stored in digital form. Understand how sampling rate affects digital audio quality.
Chapter 8: Making Sounds by Combining Pieces
Lesson Objectives Explain how sound can be sampled and stored in digital form Explain how sampling intervals and other considerations affect the size of.
Multimedia Systems and Applications
Introduction to Digital Audio
Processing Sound Ranges part 3
Chapter 6: Modifying Sounds Using Loops
Chapter 7: Modifying Samples in a Range
Bits and Pieces November 6, 2007.
Introduction to Digital Audio
Introduction to Digital Audio
Chapter 7: Modifying Samples in a Range
Introduction to Digital Audio
Introduction to Processing Digital Sounds
ITEC2110, Digital Media Chapter 1 Background & Fundamentals
Processing Sound Ranges
Processing Sound Ranges part 3
Introduction to Digital Audio
CS1315: Introduction to Media Computation
Presentation transcript:

How sound works: Acoustics, the physics of sound Sounds are waves of air pressure Sound comes in cycles The ______________ of a wave is the number of cycles per second (cps), or Hertz The _________________ is the maximum height of the wave

Volume and pitch: Psychoacoustics, the psychology of sound Our perception of volume is related (logarithmically) to changes in amplitude If the amplitude doubles, it’s about a 6 decibel (dB) change Normal speech ~60dB. Shouted speech ~80dB

Volume and pitch: Psychoacoustics, the psychology of sound Our perception of pitch is related (logarithmically) to changes in frequency Higher frequencies are perceived as higher pitches We can hear between 5 Hz and 20,000 Hz (20 kHz) A above middle C is 440 Hz 1 2 3 4 time (secs)

Demonstrating Audacity Fourier transform (FFT) I usually bring in a couple musical instruments (harmonica, thumb piano, ukelele, flute) to show how they have different FFT “signature” (different spikes).

Digitizing Sound: How do we get that into numbers? Analog-to-digital conversion (ADC) will give us the amplitude at an instant as a number: a sample

Digitizing Sounds: Arrays A sound is just a long ordered list of numbers (samples), each of which is a measure of amplitude at regular intervals over time. Samples are stored in memory in an array, a sequence of bytes right next to one another in memory.

Digitizing sound: Sample Size Each sample stored as a number in two bytes What’s the min and max amplitude we can represent with 2 bytes? 2 bytes = _______ bits which can represent 2______ = _______________ values But we need both positive and negative amplitudes Use one bit to indicate positive (0) or negative (1) That leaves us with 15 bits 15 bits, 215 = 32,768 Sample values are between -32768 and 32767

Nyquist Theorem We need twice as many samples as the maximum frequency in order to represent (and recreate, later) the original sound. The number of samples recorded per second is the sampling rate If we capture 8000 samples per second, the highest frequency we can capture is __________________ Hz That’s how phones work If we capture more than 44,000 samples per second, we capture everything that we can hear (max 22,000 Hz) CD quality is 44,100 samples per second

Recording Sounds Using Audacity and Using Sounds in Python Demonstrate how to record and export sounds using Audacity Make sure sampling rate is 44100 (lower left) Save only left audio stream (middle left) Manipulating sounds in Python >>> s = makeSound( pickAFile() ) >>> play( s ) >>> getSamplingRate( s ) >>> getLength( s ) >>> explore( s ) NOTE TO TEACHERS! You must only save the left audio stream in Audacity for this reason: The sample functions in JES (like setSampleValueAt) only affect the left audio stream, not the right audio stream. So in the hands-on activities, if you save both streams and then try to erase (for example) the middle section of the sound by setting the amplitudes to 0s, it will zero out only the left audio stream but the right audio stream will remain in tack. So then when you play the resulting sound, what you get is both streams playing for the first ¼ of the sound, only the right stream playing for the middle, and then both streams playing for the last ¼ of the sound. It took me over an hour to figure out that this was why it wasn’t erasing! The wav files in the MediaSources folders only have a left stream (or at least this was true of the ones I checked), which is why they work fine. – Robin

Manipulating a Sample Value getSampleValueAt(sound, index)  returns the value of the sample at the index setSampleValueAt(sound, index, value)  sets the value of the >>> s = makeSound( pickAFile() ) >>> v = getSampleValueAt( s, 215 ) >>> print v >>> setSampleValueAt( s, 215, 30000 )

Recipe to Increase the Volume def increaseVolume(sound): for index in range(0, getLength(sound)): value = getSampleValueAt(sound, index) setSampleValueAt(sound, index, value*2) Using it: >>> s = makeSound(pickAFile()) >>> increaseVolume(s) >>> play(s)

3 8 10 7 How Did That Work? def increaseVolume(sound): for index in range(0, getLength(sound)): value = getSampleValueAt(sound, index) setSampleValueAt(sound, index, value*2) index value 3 8 10 7

Two useful functions: copy, clip copy (sourceSound, targetSound, startPosition) copies the source sound into the target sound starting at the startPosition targetSound must be large enough to hold sourceSound sourceSound is unchanged targetSound is changed this function does NOT return a sound, it changes the targetSound!! shortS = clip (sound, startPosition, endPosition) makes a new sound that is a clip of the sound from startPosition to endPosition sound is unchanged this function DOES return a sound – the shorter sound!

How clip works s: shortS = clip(s, 1, 7) shortS: 100 2000 -4500 1500 30000 -10500 5250 -4004 -20 1 2 3 4 5 6 7 8 9 1 2 3 4 5

How copy works s: s1: copy(s1, s, 2) 100 2000 -4500 1500 30000 -10500 5250 -4004 -20 1 2 3 4 5 6 7 8 9 500 -500 1000 1 2 3 4

Copy and clip Not going to trace them at this time Need to understand the difference and how to use them Last page is an excellent reference to remember how to use them

Making an empty sound Reasons you may need this How do you do this? reverse a sound join two sounds together put part of one sound in another sound others… How do you do this? newS = makeEmptySound(lengthOfNewSound, sampleRate)

Splicing two sounds Use copy (sourceSound, targetSound, startPosition) Example: to splice two sounds s1 and s2 into one: newS = makeEmptySound( ) copy (s1, , ) copy ( , , ) explore (newS) # to see what it did!

Do you need to make empty sound to reverse a sound?? 1500 200 -500 3400 2500 1000 -400 52 64 -20 1 2 3 4 5 6 7 8 9 Why can’t you do this? def reverse (sound): revIndex = getLength(sound) - 1 for index in range (0, getLength(target)): revValue = getSampleValueAt (sound, revIndex) setSampleValueAt (sound, index, revValue) revIndex = revIndex - 1

How we need to do reverse def reverse (source): target = makeEmptySound (getLength(source),44100) sourceIndex = getLength(source) - 1 for targetIndex in range (0, getLength(target)): sourceValue = getSampleValueAt (source, sourceIndex) setSampleValueAt (target, targetIndex, sourceValue) sourceIndex = sourceIndex - 1 return (target) 1500 200 -500 3400 2500 1000 -400 52 64 -20 1 2 3 4 5 6 7 8 9 1500 200 -500 3400 2500 1000 -400 52 64 -20