/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ import java.awt.Color; // Note the name of the class in the following line MUST // match the name of the file. public class Lect1118f { public static void main (String[] args) { String fname = FileChooser.pickAFile(); //System.out.println (fname); Sound s1 = new Sound (fname); System.out.println ("Number of samples in the sound: " + s1.getLength()); System.out.println ("Number of samples per second: " + s1.getSamplingRate()); double lengthInSeconds = s1.getLength() / s1.getSamplingRate(); System.out.println ("The length in seconds of the sound: " + lengthInSeconds); Sound s3; s3 = reverseSound (s1); s3.explore(); } public static Sound reverseSound (Sound s1) { SoundSample sampArr1[] = s1.getSamples(); SoundSample samp1; int index; int sampVal1; int index2; System.out.println ("Number of samples in the sound: " + sampArr1.length); for ( index = 0 ; index < (sampArr1.length / 2) ; index++ ) { index2 = sampArr1.length - index - 1; swap (sampArr1[index], sampArr1[index2]); } return s1; } public static void swap (SoundSample samp1, SoundSample samp2) { int temp = samp1.getValue(); samp1.setValue ( samp2.getValue() ); samp2.setValue ( temp ); } } // end of class