Week 7 - Friday.  What did we talk about last time?  Array examples.

Slides:



Advertisements
Similar presentations
Introduction to Digital Audio
Advertisements

Dale & Lewis Chapter 3 Data Representation Analog and digital information The real world is continuous and finite, data on computers are finite  need.
Part A Multimedia Production Rico Yu. Part A Multimedia Production Ch.1 Text Ch.2 Graphics Ch.3 Sound Ch.4 Animations Ch.5 Video.
Chapter 4: Representation of data in computer systems: Sound OCR Computing for GCSE © Hodder Education 2011.
Int 2 Multimedia Revision. Digitised Sound Analogue sound recorded from person, or real instruments.
CMPS1371 Introduction to Computing for Engineers PROCESSING SOUNDS.
Music and Mathematics are they related?. What is Sound? Sound consists of vibrations of the air. In the air there are a large number of molecules moving.
The frequency spectrum
Properties of Waves EQ: How do I describe the basic properties of waves and how a wave’s speed is related to its wavelength and frequency?
Chapter 6 (Sections ) Sound. The speed of sound in a substance depends on: the mass of its constituent atoms, and the strength of the forces between.
Digital audio recording Kimmo Tukiainen. My background playing music since I was five first time in a studio at fourteen recording on my own for six months.
1 CS 177 Week 15 Recitation Slides Review. Announcements Final Exam on Sat. May 8th  PHY 112 from 8-10 AM Complete your online review of your classes.
Working with Sound CSC 161: The Art of Programming Prof. Henry Kautz 11/11/2009.
Week 8: Audio Processing 1.  Light and sound are both transmitted in waves 2.
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.
Representation of Data in Computer Systems
Introduction to Interactive Media 10: Audio in Interactive Digital Media.
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Computing with Digital Media: A Study of Humans and Technology Mark Guzdial, School of Interactive Computing.
ACOUSTICS AND THE ELEMENTS OF MUSIC Is your name and today’s date at the top of the worksheet now?
COMP Representing Sound in a ComputerSound Course book - pages
Sound and Music A Deliciously Delightful Discussion of Resonance, Harmonics, Beats, and Periods and Frequencies Presented by Giuliano Godorecci, Lisa Schalk,
Harmonics. Introduction Harmonic is obtained by a method of playing stringed instruments - playing the instrument while holding a finger against the string,
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.
Sound Part 2 Sound and how to make it. What is Sound? Sound is a compression wave.
Chapter 15 Recording and Editing Sound. 2Practical PC 5 th Edition Chapter 15 Getting Started In this Chapter, you will learn: − How sound capability.
Sound and Waves.
More Meaningful Jargon Or, All You Need to Know to Speak Like a Geek Sound.
Georgia Institute of Technology Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Sept 2005.
Properties of Waves EQ: How do I describe the basic properties of waves? How is a wave’s speed related to its wavelength and frequency?
The of SOUND What is it? There are two ingredients for sound. First, we need a VIBRATION, then a MEDIUM.
Chapter 21 Musical Sounds.
Intro-Sound-part1 Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Oct 2009.
Binary! Objectives How sound is stored in digital format What is meant by “sample interval” and how it affects quality The trade off between file size.
Week 7 - Friday.  What did we talk about last time?  Array examples  Sound.
Sound “A sound man…”. Frequency The frequency of a sound wave is perceived as the pitch (note) –High frequency → high pitch → high note –“Middle C” has.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Week 10 - Friday.  What did we talk about last time?  References and primitive types  Started review.
12-3 Harmonics.
The Physics of Music Why Music Sounds the Way it Does, and Other Important Bits of Information.
Physics Mrs. Dimler SOUND.  Every sound wave begins with a vibrating object, such as the vibrating prong of a tuning fork. Tuning fork and air molecules.
Musical Instruments. Notes  Different musical notes correspond to different frequencies  The equally tempered scaled is set up off of 440 A  meaning.
Physical characteristics of sound Amplitude – The measure of displacement of the air pressure wave Frequency – Represents the number of periods.
Chapter 15 Recording and Editing Sound
Week 7 - Friday CS 121.
Week 7 - Wednesday CS 121.
Wave Properties 7SCIENCE.
What type of wave is this?
Sound and Waves.
Week 15 – Wednesday CS 121.
Introduction to Digital Audio
Processing Sound Ranges part 3
Pitch.
Sound and Waves.
CS 177 Week 15 Recitation Slides
Introduction to Digital Audio
Introduction to Digital Audio
Week 9 – Audio Processing
Introduction to Digital Audio
Chapter 4: Representing sound
Intensity Waves and Sound
Sound and Waves.
Processing Sound Ranges part 3
Introduction to Digital Audio
Sound.
Sound and Waves.
Sound and Waves.
Creating Sounds and MIDI
Presentation transcript:

Week 7 - Friday

 What did we talk about last time?  Array examples

 Like light, sound is a wave  For those physics buffs here, sound is usually transmitted as a compression wave  In contrast, light is a transverse wave  It doesn’t really matter, we can pretend that sound is a transverse wave

 The human ear can hear between about 12 Hz and 20,000 Hz  The higher the frequency of the wave, the higher the frequency of the note  Note (ha, ha) that the A an octave above A440 has twice the frequency  Each half-step is an increase in the frequency by a factor of about 1.06 NoteFrequency A440 B C D E F G A880

 We can take a sound:  And reproduce that sound at double the frequency:  Notice that we have to add twice as much information to have the sound fill the same amount of time

 The amplitude of a wave is the distance from the trough of a wave to its peak  In sound, amplitude is a measure of volume  The larger the amplitude, the louder the sound Amplitude

 We can take a sound:  And make the sound with half the amplitude:  The frequency is exactly the same, but the sound is half is loud

 Something that looks like a sine wave is called a pure tone  No real instruments play anything like that  Even the purest real sound has overtones and harmonics  Real sound is the result of many messy waves added together:

 On a computer, we cannot record a wave form directly  As usual, we have to figure out a way to store a wave as a series of numbers  We are going to use these numbers to approximate the heights of the wave at various points

 As we all know by now, Hertz (Hz) is a unit that means a number of times per second  Equivalent to Hz is s -1  We are going to break down the wave into lots of slices  We are going to have 44,100 slices in a second  Thus, we are slicing at 44,100 Hz

 We slice up a wave and record the height of the wave  Each height value is called a sample  By getting 44,100 samples per second, we get a pretty accurate picture of the wave

 There are many different formats for sampling audio  In our system, each sample will be recorded as a double  The minimum value of a sample will be -1.0 and the maximum value of a sample is 1.0  A series of samples with value 0.0 represents silence  Our samples will be stored in an array

 Audio data on Windows machines is sometimes stored in a WAV file  A WAV file is much simpler than an MP3 because it has no compression  Even so, it contains two channels (for stereo) and can have many different sample rates and formats for recording sound  The StdAudio class lets you read and write a WAV file easily and always deal with a single array of sound, sampled at 44,100 Hz

 Everything you’d want to do with sound:  To do interesting things, you have to manipulate the array of samples  Make sure you added StdAudio.java to your project before trying to use it MethodUse double[] read(String file) Read a WAV file into an array of double s void save(String file, double[] input) Save an array of double s (samples) into a WAV file void play(String file) Play a WAV file void play(double[] input) Play an array of double s (samples)

 Let’s load a file into an array:  If the song has these samples:  Perhaps samples will contain: String file = "song.wav"; double[] samples = StdAudio.read(file); String file = "song.wav"; double[] samples = StdAudio.read(file);

 With the audio samples loaded into the array named samples, we can play them as follows: StdAudio.play(samples);

 Or, we could generate sound from scratch with StdAudio  This example from the book creates 1 second of the pitch A440: double[] sound = new double[StdAudio.SAMPLE_RATE + 1]; for( int i = 0; i < sound.length; i++ ) sound[i] = Math.sin(2 * Math.PI * i * 440 / StdAudio.SAMPLE_RATE); StdAudio.play(sound); double[] sound = new double[StdAudio.SAMPLE_RATE + 1]; for( int i = 0; i < sound.length; i++ ) sound[i] = Math.sin(2 * Math.PI * i * 440 / StdAudio.SAMPLE_RATE); StdAudio.play(sound);

 What if we wanted to play the second half of a sound followed by the first half?  I know, why would we want to do that? double[] samples = StdAudio.read(file); double[] switched = new double[samples.length]; for(int i = 0; i < samples.length/2; i++ ) switched[i + samples.length/2] = samples[i]; for(int i = samples.length/2; i < samples.length; i++ ) switched[i - samples.length/2] = samples[i]; StdAudio.play(switched); double[] samples = StdAudio.read(file); double[] switched = new double[samples.length]; for(int i = 0; i < samples.length/2; i++ ) switched[i + samples.length/2] = samples[i]; for(int i = samples.length/2; i < samples.length; i++ ) switched[i - samples.length/2] = samples[i]; StdAudio.play(switched);

 StdDraw

 Keep reading Chapter 6 of the textbook  Read Project 3 carefully  It's a harder project than the previous two!