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)

Slides:



Advertisements
Similar presentations
Georgia Institute of Technology Introduction to Processing Digital Sounds.
Advertisements

Templated Functions. Overloading vs Templating  Overloaded functions allow multiple functions with the same name.
ManipulatingPictures-Mod6-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology.
Intro-Sound-part31 Introduction to Processing Digital Sounds part 3 Barb Ericson Georgia Institute of Technology Oct 2009.
Peer Instruction for the First Time: Experiences of a First Time User in Computer Science Beth Simon Computer Science and Engineering University of California,
Workshop on Peer Instruction: Making Good Clicker Questions Beth Simon Computer Science and Engineering University of California, San Diego Credits: Sara.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
CS 106 Introduction to Computer Science I 02 / 22 / 2008 Instructor: Michael Eckmann.
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.
ECE122 L13: Arrays of Objects March 15, 2007 ECE 122 Engineering Problem Solving with Java Lecture 13 Arrays of Objects.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
2.3 Cool features in C# academy.zariba.com 1. Lecture Content 1.Extension Methods 2.Anonymous Types 3.Delegates 4.Action and Func 5.Events 6.Lambda Expressions.
CS 106 Introduction to Computer Science I 02 / 19 / 2007 Instructor: Michael Eckmann.
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)
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Week 7 - Wednesday.  What did we talk about last time?  Introduction to arrays  Lab 6.
Iteration. Adding CDs to Vic Stack In many of the programs you write, you would like to have a CD on the stack before the program runs. To do this, you.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CS 106 Introduction to Computer Science I 03 / 19 / 2007 Instructor: Michael Eckmann.
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.
Copyright © 2009 Curt Hill The Picture Object Getting and displaying.
CSE8A Lecture3 TODO: –Finish PSA1 individually (no partner!) and turn it in with the bundlePSA1 command GET AN INTERVIEW for PSA1 from a tutor See tutor.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
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.
UsingSoundRanges-part21 Processing Sound Ranges part 2 Barb Ericson Georgia Institute of Technology Oct 2009.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
CSE 8A Lecture 8 Reading for next class: PSA4: Collage and Picture Flip, DON’T WAIT (it’s longer than the previous PSAs)
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
CPSC1301 Computer Science 1 Chapter 8 Introduction to Processing Digital Sounds part 3.
Intro-Sound-part1 Introduction to Processing Digital Sounds part 1 Barb Ericson Georgia Institute of Technology Oct 2009.
Georgia Institute of Technology What is new in Java 5.0 (1.5)? Barb Ericson Georgia Institute of Technology June 2006.
Arrays. Collections We would like to be able to keep lots of information at once Example: Keep all the students in the class Grade each one without writing.
Composition When one class contains an instance variable whose type is another class, this is called composition. Instead of inheritance, which is based.
Creative Commons Attribution Non-Commercial Share Alike License sa/3.0/
Week 10 - Wednesday.  What did we talk about last time?  Method example  Roulette simulation  Types in Java.
Week 10 - Friday.  What did we talk about last time?  References and primitive types  Started review.
Searching CSE 103 Lecture 20 Wednesday, October 16, 2002 prepared by Doug Hogan.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 12 GEORGE KOUTSOGIANNAKIS 1 Copyright: 2015 Illinois Institute of Technology_ George Koutsogiannakis.
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.
1 CSE 142 Final Exam Review Problems. 2 Question Types expressions array mystery inheritance mystery file processing array programming Critters classes.
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/
VG101 RECITATION 5 By TAs. CONTENTS How to read Vg101Class.h Samples about graphics About assignment 5 Array.
1 Good Questions Spark discussion Motivate a topic Address a common misconception Help students “speak” in the language of your discipline Foster reflection.
CSE 8A Lecture 17 Reading for next class: None (interm exam 4)
Week 7 - Wednesday CS 121.
Georgia Institute of Technology
Processing Sound Ranges part 3
CS 177 Week 15 Recitation Slides
Introduction to Processing Digital Sounds part 2
Defining New Types of Objects, part 3
CSE 8A Lecture 6 Reading for next class:
Processing Sound Ranges part 1
Barb Ericson Georgia Institute of Technology June 2006
Introduction to Processing Digital Sounds part 3
Introduction to Processing Digital Sounds
Processing Sound Ranges part 2
Processing Sound Ranges
Creative Commons Attribution Non-Commercial Share Alike License
Processing Sound Ranges part 3
CS1315: Introduction to Media Computation
Presentation transcript:

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) BRING HEADPHONES TO LAB THIS WEEK

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

The Sample Rate that the Sound class ASSUMES is 22 KHz: How long is a SoundSample[] in a Sound object of 1 second? A.22 elements B.11,000 elements C.22,000 elements D.44,000 elements E.We can’t tell from the data provided

Write code that reduces the value of the second half of the SoundsSample array by half String fileName = FileChooser.pickAFile(); Sound noise = new Sound(fileName); SoundSample[] noiseArray = noise.getSamples(); >> for (SoundSample sample: noiseArray) { int val = sample.getValue(); sample.setValue(val/2); } for (int i = noiseArray.length/2; i < noiseArray.length; i++) { SoundSample sample = noiseArray[i]; int val = sample.getValue(); sample.setValue(val/2); } int i = 0; while (i < noiseArray.length) { SoundSample sample = noiseArray[i]; int val = sample.getValue(); sample.setValue(val/2); i++; } 1)Solo: 45 sec) 2)Discuss: (2 min) 3)Group: (20 sec) 3700 noiseArray

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

What’s printed by this code? (assume calling object as shown) A.0,9 B.60,0 C.90,5 D.100,4 E.None of the above 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) public void guess() { SoundSample[] noiseArray = this.getSamples(); int a = 0, b = 0; for (int i=0;i<noiseArray.length;i++) { SoundSample sample = noiseArray[i]; int foo = sample.getValue(); if (foo > a) { a = foo; b = i; } System.out.println(a + "," + b); }

What does this code do? 1)2 min group … int a=0, b=0; for (int i=0; i<noiseArray.length; i++) { SoundSample sample = noiseArray[i]; int foo = sample.getValue(); if (foo > a) { a = foo; b = i; }

Why would we do that?: Normalizing… public void normalize() { SoundSample[] noiseArray = this.getSamples(); int maxVal, maxIndex = 0; for (int i=0; i<noiseArray.length; i++) { SoundSample sample = noiseArray[i]; int val = sample.getValue(); if (val > maxVal) { maxVal = val; maxIndex = i; } double factor = / maxVal; for (int i = 0; i < noiseArray.length; i++) { SoundSample sample = noiseArray[i]; sample.setValue((int) (sample.getValue() * factor)); }

CS Concept: Refactoring public void normalize() { SoundSample[] noiseArray = this.getSamples(); int maxVal, maxIndex = 0; for (int i=0; i<noiseArray.length; i++) { SoundSample sample = noiseArray[i]; int val = sample.getValue(); if (val > maxVal) { maxVal = val; maxIndex = i; } double factor = / maxVal; for (int i = 0; i < noiseArray.length; i++) { SoundSample sample = noiseArray[i]; sample.setValue((int) (sample.getValue() * factor)); } Find the maximum value normalize

CS Concept: Refactoring public int findMax( SoundSample[] noiseArray ) { int maxVal; for (int i=0; i<noiseArray.length; i++) { SoundSample sample = noiseArray[i]; int val = sample.getValue(); if (val > maxVal) { maxVal = val; } return maxVal; } public void normalize() { SoundSample[] noiseArray = this.getSamples(); int maxVal = findMax( noiseArray ); double factor = / maxVal; for (int i = 0; i < noiseArray.length; i++) { SoundSample sample = noiseArray[i]; sample.setValue((int) (sample.getValue() * factor)); }

Changing Pitch of a Sound Play a recording of someone reading a sentence Now play it so that it sounds “high pitched” –How long does it take to play the sound high pitched, compared to how long the original takes? Now play it so that it sounds “low pitched” –How long does it take to play the sound low pitched, compared to how long the original takes?

Raise the pitch of a Sound Take only every nth sample from the original sound The length of the sound sample is 1/n of the original, and all frequencies in the sound have been increased by a factor of n Example, with n==2:

Options to raisePitch Create new Sound –V1) Of exact length needed for higher pitched sound –V2) Of same length as original with “silence” at end

V1: Raise pitch by 2 and return a new sound half as long 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) Write a method as part of the Sound class that returns a new Sound object whose pitch is double the calling object and whose length is half as long. Create the new sound by taking every other sample from the calling object. What is the method header for this method? A.public void raisePitch( Sound s ) B.public void raisePitch() C.public Sound raisePitch() D.public Sound raisePitch( Sound s )

A start on raisePitch 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) public Sound raisePitch() { SoundSample[] original = this.getSamples(); Sound highP = new Sound( original.length / 2 ); SoundSample[] higher = highP.getSamples(); int newPlace = 0; for (int origI = 0; origI < original.length; origI+=2) { What object will this method return? A.this B.highP C.original D.higher E.void

A start on raisePitch 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) public Sound raisePitch() { SoundSample[] original = this.getSamples(); Sound highP = new Sound( original.length / 2 ); SoundSample[] higher = highP.getSamples(); int newPlace = 0; for (int origI = 0; origI < original.length; origI+=2) { What do you think newPlace should be used for ? A.As an index into the original sample array B.As an index into the higher sample array C.To store the value to be copied from original D.To store the length of the higher sample array

Complete the raisePitch method 1)Solo: (60 sec) 2)Discuss: (2 min) 3)Group: (20 sec) public Sound raisePitch() { SoundSample[] original = this.getSamples(); Sound highP = new Sound( original.length / 2 ); SoundSample[] higher = highP.getSamples(); int newPlace = 0; for (int origI = 0; origI < original.length; origI+=2) {

Complete V2: Create new sound of same length with 0 at end public Sound raiseP() { Sound highP = new Sound(this); SoundSample[] original = this.getSamples(); SoundSample[] higher = highP.getSamples(); int newPlace = 0; for (int origI = 0; origI < original.length; origI+=2) {

Concept Summary When you want to create a “new” object… –Call a “constructor” with new. –Look in the file of that class to find out what constructors are available What parameters you can send Don’t forget to return the object you created with a return statement! When working with 2 (multiple) arrays –Sometimes you will want 2 index variables (to index into them) moving independently –If you are indexing “in synchrony” then use one index variable– it’s easier to understand!

Exam 3 practice problem Write a method in the Picture class that draws a 10x10 red square in the center of the calling object.

Exam 3 practice problem Write a method in the Picture class that takes a threshold value for green (an int). It then creates a new Picture and copies into this new Picture only those pixels whose green value is above the threshold. It leaves the rest of the Pixels in the new Pictures blank. It returns the new Picture.

Exam 3 practice problem Write a method in the Picture class that takes a target Picture object and copies the calling object’s picture upside down onto the target picture. Can you handle the case where the target is smaller than then calling object? How about where the target is larger?

TODO Reading for next class: None Study for exam 3 Start on PSA7 (Bring headphones to lab!)