UsingSoundRanges-part21 Processing Sound Ranges part 2 Barb Ericson Georgia Institute of Technology Oct 2009.

Slides:



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

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.
Georgia Institute of Technology Movies part 3 Barb Ericson Georgia Institute of Technology April 2006.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech June 2011.
Extending the Pong Example Barb Ericson Georgia Tech June 2011.
Intro-Sound-part21 Introduction to Processing Digital Sounds part 2 Barb Ericson Georgia Institute of Technology Oct 2009.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 6 Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-part31 Nested Loops – part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
Introduction to Computing and Programming in Python: A Multimedia Approach Chapter 7: Modifying Samples in a Range.
Georgia Institute of Technology Speed part 3 Barb Ericson Georgia Institute of Technology May 2006.
How to use the Java class libraries Brief documentation of how to do this all with Java.
NestedLoops-part11 Nested Loops – part 1 Barb Ericson Georgia Institute of Technology Nov 2009.
CSC1401 Viewing a picture as a 2D image - 1. Review from the last week We used a getPixels() to get all of the pixels of a picture But this has been somewhat.
02-RangesInPictures1 Barb Ericson Georgia Institute of Technology Oct 2010 Working with ranges in pictures.
Chapter 7: Modifying Samples in a Range. Chapter Objectives.
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.
Georgia Institute of Technology Manipulating Pictures, Arrays, and Loops Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-Mod7-part31 Two-Dimensional Arrays and Nested Loops – part 3 Bugs in the garden Originally by Barb Ericson Georgia Institute of Technology.
ManipulatingPictures-Mod6-part61 Manipulating Pictures, Arrays, and Loops: Eliminating color, Inversion, grey scale and adjusting for luminance Barb Ericson.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 5 Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-part41 Nested Loops – part 4 Barb Ericson Georgia Institute of Technology Nov 2009.
NestedLoops-Mody7-part51 Two-Dimensional Arrays and Nested Loops – part 5 Rotations Barb Ericson Georgia Institute of Technology May 2007.
Georgia Institute of Technology More on Creating Classes part 2 Barb Ericson Georgia Institute of Technology Oct 2005.
CPSC1301 Computer Science 1 Chapter 8 Introduction to Processing Digital Sounds part 3.
Georgia Institute of Technology Creating Classes part 4 Barb Ericson Georgia Institute of Technology May 2006.
Georgia Institute of Technology Movies part 4 Barb Ericson Georgia Institute of Technology April 2006.
Georgia Institute of Technology Speed part 4 Barb Ericson Georgia Institute of Technology May 2006.
Georgia Institute of Technology What is new in Java 5.0 (1.5)? Barb Ericson Georgia Institute of Technology June 2006.
Chapter 8: Modifying Samples in a Range. Chapter Objectives.
NestedLoops-part21 Nested Loops – part 2 Barb Ericson Georgia Institute of Technology Nov 2009.
1 CS 177 Week 8 Recitation Slides JES Sound functions and Modifying Sounds Increasing/Decreasing Volume Maximizing (Normalizing) Splicing Reversing Mirroring.
Intro-Sound-Mod10-part31 Introduction to Processing Digital Sounds part 3 while loop, tracing, for loop, parameters Barb Ericson Georgia Institute of Technology.
ManipulatingPictures-part31 Manipulating Pictures, Arrays, and Loops part 3 Barb Ericson Georgia Institute of Technology Nov 2009.
04-ManipulatingPictures-part21 Manipulating Pictures, Arrays, and Loops part 2 Barb Ericson Georgia Institute of Technology June 2008.
Madlib-Input, Strings, and Lists in Scratch Barb Ericson Georgia Tech.
Georgia Institute of Technology Two-Dimensional Arrays and Nested Loops – part 2 Barb Ericson Georgia Institute of Technology August 2005.
NestedLoops-Mod7-part61 Two-Dimensional Arrays and Nested Loops – part 6 Enlarge Barb Ericson Georgia Institute of Technology August 2005.
Manipulating Pictures, Arrays, and Loops part 2
Madlib-Input, Strings, and Lists in Scratch
Georgia Institute of Technology
Processing Sound Ranges part 1
Processing Sound Ranges part 3
Manipulating Pictures, Arrays, and Loops
Chapter 7: Modifying Samples in a Range
Introduction to Processing Digital Sounds part 2
Manipulating Pictures, Arrays, and Loops part 5
Two-Dimensional Arrays and Nested Loops – part 2
Arrays versus ArrayList
Gray Scale picture def pixBW(pixel): # given a pixel, change to BW
Processing Sound Ranges part 1
Chapter 7: Modifying Samples in a Range
Introduction to Processing Digital Sounds part 3
Two-Dimensional Arrays and Nested Loops – part 6
Two-Dimensional Arrays and Nested Loops – part 2
Manipulating Pictures, Arrays, and Loops
Manipulating Pictures, Arrays, and Loops
Two-Dimensional Arrays and Nested Loops – part 6
Manipulating Pictures, Arrays, and Loops
Introduction to Processing Digital Sounds
Processing Sound Ranges part 2
Manipulating Pictures, Arrays, and Loops part 6
Processing Sound Ranges
Two-Dimensional Arrays and Nested Loops – part 6
Manipulating Pictures, Arrays, and Loops
Processing Sound Ranges part 3
Creating and Modifying Text part 3
Manipulating Pictures, Arrays, and Loops part 6
Creating Sounds and MIDI
Presentation transcript:

UsingSoundRanges-part21 Processing Sound Ranges part 2 Barb Ericson Georgia Institute of Technology Oct 2009

UsingSoundRanges-part22 Learning Goals Processing ranges of Sound values –Reverse a sound –Mirroring a sound –Blending sounds Computing concepts –Looping through a range –Returning a value from a method –Change more than one variable in a for loop

UsingSoundRanges-part23 Reversing a Sound To reverse a sound –Create a copy of the original sound Sound orig = new Sound(this.getFileName()); –Then loop starting the sourceIndex at the last index in the source and the targetIndex at the first index in the target Decrement the sourceIndex each time Increment the targetIndex each time 500 | 400 | 300 | 200 | | 200 | 300 | 400 | 500 sourceIndex targetIndex

UsingSoundRanges-part24 Reversing Method public void reverse() { Sound orig = new Sound(this.getFileName()); int length = this.getLength(); // loop through the samples for (int targetIndex = 0, sourceIndex = length - 1; targetIndex = 0; targetIndex++, sourceIndex--) this.setSampleValueAt(targetIndex, orig.getSampleValueAt(sourceIndex)); }

UsingSoundRanges-part25 Testing the Reverse Method String file = FileChooser.getMediaPath( "thisisatest.wav"); Sound s = new Sound(file); s.explore(); s.reverse(); s.explore();

UsingSoundRanges-part26 Challenge Reverse just the second half of a sound –Start the targetIndex at the length / 2 –Start the sourceIndex at the length – 1 –Loop while the targetIndex < length 100 | 200 | 500 | 400 | | 200 | 300 | 400 | 500 sourceIndex targetIndex

UsingSoundRanges-part27 Mirror a Sound Copy the first half of the sound to the second half –And reverse the sounds in the second half Calculate the midpoint (length / 2) Start the source index at 0 and copy from index to length – index -1 While index < midpoint 100 | 200 | 300 | 400 | | 200 | 300 | 200 | 100 midpoint

UsingSoundRanges-part28 Mirror Sound Method public void mirrorFrontToBack() { int length = this.getLength(); // save the length int mirrorPoint = length / 2; // mirror around this int value = 0; // hold the current value // loop from 1 to mirrorPoint for (int i = 0; i < mirrorPoint; i++) { value = this.getSampleValueAt(i); this.setSampleValueAt(length – i - 1,value); }

UsingSoundRanges-part29 Testing Mirror Method Sound s = new Sound(FileChooser.getMediaPath( "croak.wav")); s.explore(); s.mirrorFrontToBack(); s.explore();

UsingSoundRanges-part210 Challenge Write a method to mirror from the back to the front –Copy the back half of the sound reversed to the front 100 | 200 | 300 | 400 | | 400 | 300 | 400 | 500 midpoint

UsingSoundRanges-part211 Blend Sounds Like blending pictures we can blend two sounds: –Copy the first 20,000 values of sound1 –Copy from both by adding.5 * sound1 value and.5 * sound2 value –Copy the next 20,000 values of sound 2

UsingSoundRanges-part212 Blend Sounds Method public void blendSounds() { Sound sound1 = new Sound(FileChooser.getMediaPath("aah.wav")); Sound sound2 = new Sound(FileChooser.getMediaPath("bassoon- c4.wav")); int value = 0; // copy the first 20,000 samples from sound1 into target for (int index=0; index < 20000; index++) this.setSampleValueAt(index, sound1.getSampleValueAt(index));

UsingSoundRanges-part213 Blend Sounds - Continued // copy the next 20,000 samples from sound1 and blend that // with the first 20,000 samples from sound2 for (int index = 0; index < 20000; index++) { value = (int) ((sound1.getSampleValueAt(index ) * 0.5) + (sound2.getSampleValueAt(index) * 0.5)); this.setSampleValueAt(index ,value); } // copy the next 20,000 samples from sound2 into the target for (int index=20000; index < 40000; index++) this.setSampleValueAt(index , sound2.getSampleValueAt(index)); }

UsingSoundRanges-part214 Testing Blend Sounds String fileName = FileChooser.getMediaPath( "sec3silence.wav"); Sound target = new Sound(fileName); target.explore(); target.blendSounds() target.explore();

Challenge Write a method to blend two sounds together –Start with 10,000 samples from sound1 –Then add 0.75 of sound1 to 0.25 of sound2 for 10,000 samples –Then do 0.5 times sound1 plus 0.5 times sound2 for 10,000 samples –Then do 0.25 times sound1 plus 0.75 of sound2 for 10,000 samples –Then have 10,000 samples from sound2 UsingSoundRanges-part215

UsingSoundRanges-part216 Summary You can splice sounds together using more than one loop in a method You can mirror sounds just like you mirrored a picture You can blend sounds just like you blended two pictures