1 / 16

Processing Sound Ranges part 2

Processing Sound Ranges part 2. Barb Ericson Georgia Institute of Technology Sept 2005. Learning Goals. Processing ranges of Sound values Splicing sounds together to create a sentence Mirroring a sound Blending sounds Computing concepts Looping through a range

jwhited
Download Presentation

Processing Sound Ranges part 2

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Processing Sound Rangespart 2 Barb Ericson Georgia Institute of Technology Sept 2005 Georgia Institute of Technology

  2. Learning Goals • Processing ranges of Sound values • Splicing sounds together to create a sentence • 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 • Identify algorithms that cross media boundaries Georgia Institute of Technology

  3. Create an Audio Sentence Exercise • Create a method that splices 3 sounds together to finish the sentence, “Guzdial is”. • Make sure that you don’t copy past the end of the current sound • Be sure to include silence between words • Can you make this method more general? • How about a method to splice a sound into the middle of another sound? • Take starting point in target for splice Georgia Institute of Technology

  4. 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 sourceIndex 100 | 200 | 300 | 400 | 500 500 | 400 | 300 | 200 | 100 targetIndex Georgia Institute of Technology

  5. 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 < length && sourceIndex >= 0; targetIndex++, sourceIndex--) this.setSampleValueAt(targetIndex, orig.getSampleValueAt(sourceIndex)); } Georgia Institute of Technology

  6. Testing the Reverse Method String file = FileChooser.getMediaPath( “thisisatest.wav”); Sound s = new Sound(file); s.explore(); s.reverse(); s.explore(); Georgia Institute of Technology

  7. Reverse Part of a Sound Exercise • 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 sourceIndex 100 | 200 | 300 | 400 | 500 100 | 200 | 500 | 400 | 300 targetIndex Georgia Institute of Technology

  8. Mirror a Sound • Copy the first half of the sound to the second half • And reverse the sounds in the second half • This is very similar to mirroring a picture • Calculate the midpoint (length / 2) • Start the source index at 0 and copy from index to length – index -1 • While index < midpoint midpoint 100 | 200 | 300 | 400 | 500 100 | 200 | 300 | 200 | 100 Georgia Institute of Technology

  9. 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); } } Georgia Institute of Technology

  10. Testing Mirror Method Sound s = new Sound(FileChooser.getMediaPath( "croak.wav")); s.explore(); s.mirrorFrontToBack(); s.explore(); Georgia Institute of Technology

  11. Mirror Back to Front Exercise • Write a method to mirror from the back to the front • Copy the back half of the sound reversed to the front midpoint 100 | 200 | 300 | 400 | 500 500 | 400 | 300 | 400 | 500 Georgia Institute of Technology

  12. 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 Georgia Institute of Technology

  13. 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)); Georgia Institute of Technology

  14. 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 + 20000) * 0.5) + (sound2.getSampleValueAt(index) * 0.5)); this.setSampleValueAt(index + 20000,value); } // copy the next 20,000 samples from sound2 into the target for (int index=20000; index < 40000; index++) this.setSampleValueAt(index + 20000, sound2.getSampleValueAt(index)); } Georgia Institute of Technology

  15. Testing Blend Sounds String fileName = FileChooser.getMediaPath( "sec3silence.wav"); Sound target = new Sound(fileName); target.explore(); target.blendSounds() target.explore(); Georgia Institute of Technology

  16. 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 Georgia Institute of Technology

More Related