Week 8: Audio Processing 1.  Light and sound are both transmitted in waves 2.

Slides:



Advertisements
Similar presentations
Digital Signal Processing
Advertisements

Sound can make multimedia presentations dynamic and interesting.
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.
From Sound to Music CSC 161: The Art of Programming Prof. Henry Kautz 11/16/2009.
Int 2 Multimedia Revision. Digitised Sound Analogue sound recorded from person, or real instruments.
CMPS1371 Introduction to Computing for Engineers PROCESSING SOUNDS.
What makes a musical sound? Pitch n Hz * 2 = n + an octave n Hz * ( …) = n + a semitone The 12-note equal-tempered chromatic scale is customary,
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.
You are an acoustic engineer. You have recorded a pure note of music that is described mathematically as f ( t ) = 20 sin (880  t ), where t is time in.
Week 7 - Friday.  What did we talk about last time?  Array examples.
The frequency spectrum
Comp 1001: IT & Architecture - Joe Carthy 1 Review Floating point numbers are represented in scientific notation In binary: ± m x 2 exp There are different.
IT-101 Section 001 Lecture #8 Introduction to Information Technology.
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.
Spring 2002EECS150 - Lec13-proj Page 1 EECS150 - Digital Design Lecture 13 - Final Project Description March 7, 2002 John Wawrzynek.
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.
Harmonics and Overtones Waveforms / Wave Interaction Phase Concepts / Comb Filtering Beat Frequencies / Noise AUD202 Audio and Acoustics Theory.
Working with Sound CSC 161: The Art of Programming Prof. Henry Kautz 11/11/2009.
LOOK 8/19/2015Theatre Arts 1(T) Sound: Properties and Functions Theatre Arts 1(T)
Representation of Data in Computer Systems
 Continuous sequence of vibrations of air  (Why no sound in space? Contrary to Star Wars etc.)  Abstraction of an audio wave:  Ear translates vibrations.
Thursday 27 th September. Periods Music Technology A2.
Computer Science 121 Scientific Computing Winter 2014 Chapter 13 Sounds and Signals.
School of Informatics CG087 Time-based Multimedia Assets Sampling & SequencingDr Paul Vickers1 Sampling & Sequencing Combining MIDI and audio.
Lab #8 Follow-Up: Sounds and Signals* * Figures from Kaplan, D. (2003) Introduction to Scientific Computation and Programming CLI Engineering.
Using Technology and Music to Talk About Sinusoids Mike Thayer Summit High School, Summit, NJ 25 th Annual “Good Ideas in Teaching Precalculus And…” Conference.
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.
Lecture # 22 Audition, Audacity & Sound Editing Sound Representation.
Problem Solving with Data Structures using Java: A Multimedia Approach Chapter 5: Arrays: A Static Data Structure for Sounds.
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
Computer Some basic concepts. Binary number Why binary? Look at a decimal number: 3511 Look at a binary number: 1011 counting decimal binary
Announcements Chapter 11 for today No quiz this week Instructor got behind…. We'll be back in MGH389 on Friday.
Basics of Digital Audio Outline  Introduction  Digitization of Sound  MIDI: Musical Instrument Digital Interface.
Sound and audio. Table of Content 1.Introduction 2.Properties of sound 3.Characteristics of digital sound 4.Calculate audio data size 5.Benefits of using.
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 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.
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.
Fundamentals of Audio Production. Chapter 1 1 Fundamentals of Audio Production Chapter One: The Nature of Sound.
The Physics Of Sound Why do we hear what we hear?
Digital Recording. Digital recording is different from analog in that it doesn’t operate in a continuous way; it breaks a continuously varying waveform.
Introduction to Digital Media. What is it? Digital media is what computers use to; Store, transmit, receive and manipulate data Raw data are numbers,
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.
Week 7 - Friday.  What did we talk about last time?  Array examples  Sound.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
1/27/2016Tech I Lighting Unit1 Sound: Properties and Functions Technical Theatre I.
The Physics Of Sound Why do we hear what we hear? (Turn on your speakers)
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.
1 Section 5.4 Digital Sound Processing Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
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.
Pitch.
CS 177 Week 15 Recitation Slides
Week 9 – Audio Processing
Digital Music Scott Bennett 1/3/2019.
Processing Sound Ranges part 3
Creating Sounds and MIDI
Presentation transcript:

Week 8: Audio Processing 1

 Light and sound are both transmitted in waves 2

 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 that the A an octave above concert A (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 3

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

 The amplitude of a wave is the distance to its peak (measured by its y-value)  In sound, amplitude is a measure of volume  The larger the amplitude, the louder the sound 5

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

 Something that looks like a smooth 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: 7

 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 8

 Hertz (Hz) is a unit that means a number of times per second  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 9

 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 10

 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 11

 Audio data on computers 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 12

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

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

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

 Or, we could generate sound from scratch with StdAudio  This example from the book creates 1 second of the pitch A440:  StdAudio.SAMPLE_RATE is 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); 16

 The book provides a short program called Play That Tune (pp. 150 and 205) that will generate a sequence of notes according to an input file  It’s a sort of software synthesizer  If you know the notes for a song you’d like to play and their durations, you can create a file to play it with PlayThatTune.java  java PlayThatTune < song.txt 17

 As you can see, the file is just a list of numbers giving pitch and duration  Although ugly, this form of bookkeeping takes up virtually no space compared to WAV files  Drawbacks:  You can only play one note at a time  All notes have a pure tone with a little bit of harmonics  It takes forever to type out an input file  No dynamics (volume control) 18

 Remember, sound is a wave  We are going to start playing with the waveform now to get different effects  Phase is a property of a wave that can be determined by its starting position  You can think of phase as the alignment of the wave 19

 What happens if we invert a sound wave?  For example, we turn this wave:  Into this wave: 20

 How would we invert the phase of a wave in code?  And what does that crazy, upside-down sound sound like?  Exactly the same  The human ear is not sensitive to phase double[] sound = StdAudio.read( file ); for( int i = 0; i < sound.length; i++ ) sound[i] = -sound[i]; StdAudio.play(sound); 21

 Phase is still worth knowing about  If you hear two copies of the same sound, but one is 180° out of phase, the sounds will cancel each other out  This can happen if you hook up one of your stereo speakers backwards 22

 To reverse a sound, we simply send the wave form backwards  For example, we take this sound:  And turn it into this sound: 23

 How would we reverse a sound in code?  What does it sound like?  Sort of like a bizarre foreign language double[] sound = StdAudio.read( file ); int start = 0; int end = sound.length - 1; while( start < end ) { double temp = sound[start]; sound[start] = sound[end]; sound[end] = temp; start++; end--; } StdAudio.play(sound); 24

 Recall that the amplitude of a wave is the distance to its peak (measured by its y-value)  In sound, amplitude is a measure of volume  The larger the amplitude, the louder the sound 25

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

 How would we half the volume of a sound in code?  This is half the amplitude. Is this exactly half the volume?  No… this stuff gets complicated  Different frequencies with the same amplitude are actually perceived as different loudnesses  But, it’s close enough double[] sound = StdAudio.read( file ); for( int i = 0; i < sound.length; i++ ) sound[i] = 0.5*sound[i]; StdAudio.play(sound); 27

 How would we double the volume of a sound in code?  Be careful!  Remember that the max is 1.0 and the min is -1.0  If you go outside of that range, you should limit the values double[] sound = StdAudio.read( file ); for( int i = 0; i < sound.length; i++ ) { sound[i] = 2*sound[i]; if( sound[i] > 1.0 ) sound[i] = 1.0; else if( sound[i] < -1.0 ) sound[i] = -1.0; } StdAudio.play(sound); 28

 We can take a sound:  And shrink that sound in half the time (while also doubling its frequency): 29

 How would we double the speed of a sound in code?  We are just taking every other sample  We are throwing out half the information double[] sound = StdAudio.read( file ); double[] speed = new double[sound.length/2]; for( int i = 0; i < speed.length; i++ ) speed[i] = sound[2*i]; StdAudio.play(speed); 30

 We can take a sound:  And stretch that sound to double the time (while also cutting its frequency in half): 31

 How would we stretch that sound to double in code?  Often times, this can sound terrible  We are doubling the length of the sound, but we have no extra information  We are just filling in holes in the samples with copies double[] sound = StdAudio.read( file ); double[] slow = new double[sound.length*2]; for( int i = 0; i < slow.length; i++ ) slow[i] = sound[i/2]; StdAudio.play(slow); 32

 Integers are easy  You can apply the same ideas to non-integer speed-ups and slow-downs  Smarter algorithms, like the ones used by professionals, may do some averaging or other tricks to retain sound quality 33

 To add noise to a waveform, add small random numbers to the wave  Make sure that the random numbers are both positive and negative (with a mean of 0)  You can turn this wave:  Into this wave: 34

 How can we turn this wave…  Into this wave?  That is much harder! 35