CSE 8A Lecture 13 Reading for next class: Chapter 9 Today’s topics: –Sounds! Finish PSA 6: Chromakey! DUE TUESDAY Interm exam 3 next Thursday.

Slides:



Advertisements
Similar presentations
Bandwidth part 1 What does it mean? Different things to different people.
Advertisements

Procedural Programming in C# Chapters Objectives You will be able to: Describe the most important data types available in C#. Read numeric values.
Georgia Institute of Technology Introduction to Processing Digital Sounds.
ITEC 109 Lecture 25 Sound.
ManipulatingPictures-Mod6-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology.
Eee116j1 1 Digital Information Engineering Science EEE116J1 Prof Paul Maguire w.
Week 7 - Friday.  What did we talk about last time?  Array examples.
Motivation Application driven -- VoD, Information on Demand (WWW), education, telemedicine, videoconference, videophone Storage capacity Large capacity.
IT-101 Section 001 Lecture #8 Introduction to Information Technology.
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.
Week 8: Audio Processing 1.  Light and sound are both transmitted in waves 2.
Digital Audio Multimedia Systems (Module 1 Lesson 1)
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 6: Modifying Sounds Using Loops.
Intro-Sound-part21 Introduction to Processing Digital Sounds part 2 Barb Ericson Georgia Institute of Technology Oct 2009.
CSE 8A Lecture 8 Reading for next class: None Prepare for In-term exam 2 PSA4: Collage and Picture Flip, DON’T WAIT (it’s longer than the previous PSAs)
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.
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.
COMP Representing Sound in a ComputerSound Course book - pages
Multimedia def. Many forms Multimedia Text Hyperlinks Images Audio Animation Video Text Hyperlinks Images Audio Animation Video.
CSC361/661 Digital Media Spring 2002
Digital Media Dr. Jim Rowan ITEC Monday, August 27.
Digital Media Dr. Jim Rowan ITEC Monday, August 27.
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.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
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.
Week 6 - Wednesday.  What did we talk about last time?  Exam 1 post-mortem  Recursive running time.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Introduction to SOUND.
Georgia Institute of Technology Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Sept 2005.
1 Introduction to Information Technology LECTURE 6 AUDIO AS INFORMATION IT 101 – Section 3 Spring, 2005.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CPSC1301 Computer Science 1 Chapter 8 Introduction to Processing Digital Sounds part 3.
CS 102 Computers In Context (Multimedia)‏ 03 / 30 / 2009 Instructor: Michael Eckmann.
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.
TOPIC 10 THE IF STATEMENT 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
CS1315: Introduction to Media Computation Sound Encoding and Manipulation.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Georgia Institute of Technology What is new in Java 5.0 (1.5)? Barb Ericson Georgia Institute of Technology June 2006.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
CSE 8A Lecture 14 Reading for next class: None (INTERM EXAM #3) Today’s topics: –More Sounds! PSA 6 due tonight PSA 7 (sounds) due next Monday (11/19)
Session 18 The physics of sound and the manipulation of digital sounds.
CSE8A Lecture 5 TODO: –FINISH PSA2 WITH YOUR PARTNER! Read next class: Section 5.1. PLAY WITH CODE! –Get stuck, then figure out how to get unstuck – it’s.
COSC 1P02 Introduction to Computer Science 5.1 Cosc 1P02 Week 5 Lecture slides Psychiatrist to patient "You have nothing to worry about - anyone who can.
Intro-Sound-Mod10-part31 Introduction to Processing Digital Sounds part 3 while loop, tracing, for loop, parameters Barb Ericson Georgia Institute of Technology.
1 CS 177 Week 7 Recitation Slides Modifying Sounds using Loops + Discussion of some Exam Questions.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Data representation – Sound.
CSE 8A Lecture 17 Reading for next class: None (interm exam 4)
Week 7 - Wednesday CS 121.
Multimedia Systems and Applications
Processing Sound Ranges part 3
CS 177 Week 15 Recitation Slides
Introduction to Processing Digital Sounds part 2
CSE 8A Lecture 6 Reading for next class:
Introduction to Processing Digital Sounds
ITEC2110, Digital Media Chapter 1 Background & Fundamentals
Creative Commons Attribution Non-Commercial Share Alike License
CS1315: Introduction to Media Computation
WJEC GCSE Computer Science
Presentation transcript:

CSE 8A Lecture 13 Reading for next class: Chapter 9 Today’s topics: –Sounds! Finish PSA 6: Chromakey! DUE TUESDAY Interm exam 3 next Thursday

if ( absValZ < 2.0 ) { return true; } else { return false; } Which of the following is equivalent to the above code? A.return absValZ; B.return absValZ < 2.0; C.return absValZ >= 2.0; D.None of these CS Concept: Booleans are values

public static boolean inMset( double real, double imag ) { double zReal = 0; double zImag = 0; double realUpdate; int numIter = 0; double absValZ = Math.sqrt(zReal*zReal + zImag*zImag); while ( absValZ < 2.0 && numIter < 25 ) { realUpdate = zReal*zReal-zImag*zImag + real; zImag = zReal*zImag*2+ imag; zReal = realUpdate; absValZ = Math.sqrt(zReal*zReal + zImag*zImag); numIter++; } if ( absValZ < 2.0 ) { return true; } else { return false; } Magic Numbers!! (BAD)

public static boolean inMset( double real, double imag ) { final double zLimit = 2.0; final int maxIter = 25; double zReal, zImag, realUpdate; zReal = zImag = 0; int numIter = 0; double absValZ = Math.sqrt(zReal*zReal + zImag*zImag); while ( absValZ < zLimit && numIter < maxIter ) { realUpdate = zReal*zReal-zImag*zImag + real; zImag = zReal*zImag*2+ imag; zReal = realUpdate; absValZ = Math.sqrt(zReal*zReal + zImag*zImag); numIter++; } return ( absValZ < zLimit ); } final ly, no Magic Numbers Variables declared with the keyword final are constant. i.e. they can’t be modified once they are set.

Chromakey: Visit strange new places 1)Solo: (30 sec) 2)Discuss: (2 min) 3)Group: (20 sec) background person (before) person (after) In order to create modify the person picture so that it looks like the after picture, from which pictures to you take the pixels in the boxes? A.Box 1 (yellow) from background, box 2 (green) from person B.Box 1 from background, box 2 from background C.Box 1 from person, box 2 from person D.Box 1 from person, box 2 from background E.None of the above 1 2

How will you know which part (yellow box or green) you are in? A.Condition on the Pixel coordinates (not the color) B.Condition on the Pixel colors in background C.Depends on the Pixel colors in person D.Depends on the Pixel colors in background, compared to those at the same coordinates in person 1)Solo: (30 sec) 2)Discuss: (30 sec) 3)Group: (20 sec) 1 2 background person (before)

Your chromakey Call two chromakey methods: –One to replace background –One to replace tShirt –If there 2 or more people in the picture, you can call more methods – one to replace each tShirt with a different background if you like public void chromaKeyBlue(Picture newPicToReplaceBlue, int blueThreshold) for (int x = 0; x < this.getWidth(); x++) for (int y = 0; y < this.getHeight(); y++) { //Do some stuff } OK to edit pictures before the code runs

Modified from the lab 5 quiz A.This code changes any pure red pixels in the top-right quarter of the picture to black. B.This code modifies the top-right quarter of the picture. C.This code loops over pixels in the top half of the array and, if the x coordinate is greater than half the width, checks if the red component is 255 and the blue is 0 and the green is 0, and, if so, sets the pixel to black. for (int x = 0; x < getWidth(); x++) { for (int y = 0; y < getHeight() / 2; y++) { Pixel p = getPixel(x, y); if (x > getWidth() / 2) { if (p.getRed() == 255 && p.getBlue() == 0 && p.getGreen() == 0) { p.setColor(Color.BLACK); }

What are we doing next? Chapters 8,9,10: Sound! Continue with computational basics from Picture work: –Iteration/looping, if statements, arrays –Emphasis on deeper understanding –Emphasis on Java terminology, features, mental “model” of how code is represented in the execution on the machine When working with Sound/SoundSample, compare and contrast to Picture/Pixel examples.

Chapter 8: Sound!

Sounds Sound is a quasiperiodic pattern of waves of air pressure –Increase in air pressure is a compression –Decrease in air pressure is a rarefaction The strength of the compression and rarefaction is the amplitude of the sound The number of compression/rarefaction cycles per second is the frequency of the sound

Digitizing Sounds To process sounds in a computer, sound must be digitized A microphone converts instantaneous sound pressure level into voltage (+ voltage for compression, - voltage for rarefaction) Then the amplitude of the voltage can be converted to bits (digital integers) with an Analog-to-Digital converter (ADC)

Digital Sample Rate versus Sample Size Size determines max (and min) amplitude –CD audio: 16 bits per sample (per stereo channel) –Min: -32,768; Max: 32,767 Rate is “how often we record an amplitude” –CD audio: 44,100 samples per second –A.k.a KHz sample rate

If the following sound were modified to be louder it would A.Have lower frequency and stronger compressions/rarefactions B.Have smaller amplitude and stronger compressions/rarefactions C.Have higher frequency and stronger compressions/rarefactions D.Have larger amplitude and stronger compressions/rarefactions E.None of the above 1)Solo: (30 sec) 2)Discuss: (2 min) 3)Group: (20 sec)

If higher pitch? 1)Solo: (30 sec) 2)Discuss: (2 min) 3)Group: (20 sec)

Making bad music: What’s wrong with these decisions? 1)Discuss: (3 min) I’ve decided that I don’t like the sampling rate and sample size provided by the book authors. Comment on my decision to use… Sampling Rate Sample Size Explanation 5,000Hz4 bits 100,000Hz32 bits

Our Representation of Sound String fileName = FileChooser.pickAFile(); Sound noise = new Sound(fileName); SoundSample[] noiseArray = noise.getSamples(); noiseArray[3].setValue(0); int foo = noiseArray[2].getValue(); noiseArray SoundSample objects

Our Representation of Sound (Shorthand) String fileName = FileChooser.pickAFile(); Sound noise = new Sound(fileName); SoundSample[] noiseArray = noise.getSamples(); noiseArray[3].setValue(0); int foo = noiseArray[2].getValue(); noiseArray

How would we fill in this SampleSound[] 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec)

How would we fill in this SampleSound[] 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) 6

According to Nyquist’s Theorem what is the minimum sampling rate? 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) A.1.5Hz B.3Hz C.6Hz D.10,000Hz E.20,000Hz

Write code which makes the following changes Here’s a Sound String fileName = FileChooser.pickAFile(); Sound noise = new Sound(fileName); SoundSample[] noiseArray = noise.getSamples(); >> for (SoundSample sample: noiseArray) { int foo = sample.getValue(); sample.setValue(foo/2); } for (int i = noiseArray.length/2; i < noiseArray.length) { SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2); } int i = 0; while (i < noiseArray.length) { SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2); } 1)Solo: 45 sec) 2)Discuss: (2 min) 3)Group: (20 sec)

What does that code do A.Makes a lower pitched sound during first half of play B.Makes a quieter sound during first half of play C.Makes a lower pitched sound during second half of play D.Makes a quieter sound during second half of play E.For each SoundSample element in the second half of the array it gets the Value and stores that in an int and then sets the Value with something that is half that

For you to practice Write code that reduces the volume of every other SoundSample. –What does that really sound like?

Summary of Concepts Digital representations of sounds Manipulating sounds using loops

TODO Reading for next class: Chapter 9 –Read more about Sounds. Finish PSA6