========================= QUICK EXERCISE: Exam 1 Question 5 ExamPicture q = new ExamPicture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ) q.problemFive(); q.show(); q.write( "/Users/wallingf/Desktop/wallingf-problemFived.jpg" ); q = new ExamPicture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ) q.problemFiveOneIf(); q.show(); q = new ExamPicture( "/Users/wallingf/Desktop/wallingf-250x328.jpg" ) q.problemFiveAverage(); q.show(); ========================= TASK: chromakey on blue Picture blueMark = new Picture( "/Users/wallingf/Desktop/blue-mark.jpg" ); blueMark.show(); Picture background = new Picture( "/Users/wallingf/Desktop/movie-background.jpg" ); background.show(); blueMark.chromakeyOnBlue( background ); blueMark.repaint(); ----- pattern: "method for design choices" ========================= SLIDES: sound encoding ========================= DEMO: working with sound > Sound preamble = new Sound( "/Users/wallingf/Desktop/preamble.wav" ); > preamble Sound file: /Users/wallingf/Desktop/preamble.wav number of samples: 421110 > preamble.play(); > SoundSample[] samples = preamble.getSamples(); > samples.length 421110 > samples[0] Sample at index 0 has value 36 > samples[10] Sample at index 10 has value 46 > samples[100] Sample at index 100 has value 24 > samples[1000] Sample at index 1000 has value -2 > samples[10000] Sample at index 10000 has value 416 > samples[100000] Sample at index 100000 has value 4 > samples[1000000] ArrayIndexOutOfBoundsException: at java.lang.reflect.Array.get(Native Method) > preamble.displaySamples( 10 ); // I wrote this method Sample at index 0 has value 36 Sample at index 1 has value 29 Sample at index 2 has value 22 Sample at index 3 has value 18 Sample at index 4 has value 10 Sample at index 5 has value 31 Sample at index 6 has value 34 Sample at index 7 has value 34 Sample at index 8 has value 40 Sample at index 9 has value 45 > preamble.getLength() 421110 > preamble.getSamplingRate() 22050.0 > preamble.explore() > preamble.getSampleValueAt( 1 ) 29 > preamble.getSampleValueAt( 10 ) 46 > preamble.getSampleValueAt( 100 ) 24 ... > preamble.getSampleValueAt( 1000000 ) You are trying to access the sample at index: 1000000, but the last valid index is at 421109 That index 1000000, does not exist. The last valid index is 421109 The index 1000000 isn't valid for this sound 0 ----- what about a *real* audio file? > Sound sweetDreams = new Sound( "/Users/wallingf/Desktop/SweetDreams.aiff" ); > sweetDreams Sound file: /Users/wallingf/Desktop/SweetDreams.aiff number of samples: 9436032 > sweetDreams.getSampleValueAt( 100 ) 0 > sweetDreams.getSampleValueAt( 100000 ) 1138 ----- how about a real for loop? > preamble.amplify( 0.5 ); // I wrote this method > preamble.play(); // ... and it's louder!