========================= QUICK EXERCISE: amplify by fixed amount > Sound s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.play(); > s.amplify( 5 ); > s.play(); > s.amplify( 1500 ); > s.play(); * recall the range of values [-32768..32767] * perhaps we need a bigger value to notice a change > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.amplify( 20000 ); > s.play(); * no change? > s.displaySamples( 10 ); Sample at index 0 has value 20059 Sample at index 1 has value 20039 Sample at index 2 has value 20016 Sample at index 3 has value 20010 Sample at index 4 has value 19999 Sample at index 5 has value 20007 Sample at index 6 has value 19988 Sample at index 7 has value 19993 Sample at index 8 has value 20010 Sample at index 9 has value 20025 > s.explore(); * ah, a _shift_ * how about _this_ > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.amplifyNotShift( 10000 ); > s.play(); > s.explore(); ========================= REVIEW: encoding of sound * only one value, not three * two bytes, not 1 or 3 ========================= EXERCISE: invert a sound * like the negative of an image?? > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.explore(); > s.invert(); > s.explore(); * is this a problem with us playing the "original sound? > s.write( "/Users/wallingf/Desktop/gettysburg10-inverted.wav" ); > s = new Sound( "/Users/wallingf/Desktop/gettysburg10-inverted.wav" ); > s.play() * no! > s.amplify( 0.5 ); > s.explore(); * what might a real negative of a sound look like?? * save this for later... ========================= TASK: normalize a sound * see slides first... > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.maximumAbsoluteValue() 11312 > s.explore() * a little helpful output might help us... > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.maximumAbsoluteValue() Index: 10 value: 61 Index: 15 value: 73 Index: 16 value: 76 Index: 65 value: 83 Index: 66 value: 86 ... Index: 12754 value: 10276 Index: 12755 value: 10364 Index: 12756 value: 10462 Index: 12913 value: 10884 Index: 12914 value: 11312 11312 > s.explore() * then take the helper print statements out!? > s = new Sound( "/Users/wallingf/Desktop/gettysburg10.wav" ); > s.normalize(); > s.explore(); > s.maximumAbsoluteValue() 32767