========================= SET UP: prepare for media files > FileChooser.setMediaPath( "/Users/wallingf/home/teaching/cs1-media/intro-prog-java/mediaSources/" ) ========================= QUICK EXERCISE: guess the sound > Sound s = new Sound( 0 ); > s = s.makeSound( 2 ); // tried twice, for two different tests > s.explore(); > Sound s = Sound.makeSound( 2 ); // with makeSound as a CLASS METHOD > s.explore(); ----- Why not make reverse() a class method ? ========================= IDEA: adding two sounds > s = new Sound( FileChooser.getMediaPath( "and.wav" ) ); > s.explore(); > t = new Sound( FileChooser.getMediaPath( "great.wav" ) ); > t.explore(); > s.add( t ); > s.explore(); > s = new Sound( FileChooser.getMediaPath( "ew/fogleg20.wav" ) ); > s.explore(); > t = s.reverse(); > t.explore(); > s.add( t ); > s.explore(); ----- This doesn't do much for us ----- just adding arbitrary sounds, ----- but it gives us the raw material ----- for creating sound effects. ========================= IDEA: blending two sounds > String filename = FileChooser.getMediaPath( "sec3silence.wav"); > Sound target = new Sound( filename ); > target.explore(); > Sound s = new Sound( FileChooser.getMediaPath("aah.wav") ); > Sound t = new Sound( FileChooser.getMediaPath("bassoon-c4.wav") ); > target.blend( s, t ); > target.explore(); ----- perhaps better with two notes > target = new Sound( filename ); > s = new Sound( FileChooser.getMediaPath("bassoon-c4.wav") ); > t = new Sound( FileChooser.getMediaPath("bassoon-g4.wav") ); > target.blend( s, t ); > target.explore(); ----- which leads me to wonder... > s = new Sound( FileChooser.getMediaPath("bassoon-c4.wav") ); > t = new Sound( FileChooser.getMediaPath("bassoon-e4.wav") ); > u = new Sound( FileChooser.getMediaPath("bassoon-g4.wav") ); > s.add( t ); > s.add( u ); > s.explore(); ----- a C chord! ========================= QUICK EXERCISE: generate a blended chord > s.getLength() 55125 > t.getLength() 55125 > u.getLength() 55125 > 55125 * 5 / 3 91875 > Sound chord = Sound.blendedChord(); > chord.explore(); ========================= IDEA: echo, by adding after a delay > Sound voice = new Sound( FileChooser.getMediaPath("ew/the-voice-raw.aiff") ); > Sound backVoice = voice.reverse(); > backVoice.play(); > voice.echo( 20000 ); > voice.play(); > voice = new Sound( FileChooser.getMediaPath("ew/the-voice-raw.aiff") ); > voice.echo( 1000 ); > voice.play(); > voice = new Sound( FileChooser.getMediaPath("ew/the-voice-raw.aiff") ); > voice.echo( 1000 ); > voice.play(); ========================= IDEA: changing a sound's frequency > voice = new Sound( FileChooser.getMediaPath("ew/the-voice-clipped-and-pitched.aiff") ); > voice.changeFrequency( 22050.0 / 16000.0 ); // OOPS! wrong way > voice.play(); > voice = new Sound( FileChooser.getMediaPath("ew/the-voice-clipped-and-pitched.aiff") ); > voice.changeFrequency( 16000.0 / 22050.0 ); > voice.play(); ----- The frequency seems right now! ----- ... but the result sound is too short.