/** * 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 Lect1116d { 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 length3; length3 = sampArr1.length; Sound s3 = new Sound(length3); SoundSample sampArr3[] = s3.getSamples(); SoundSample samp3; int sampVal3; System.out.println ("Number of samples in the sound: " + sampArr3.length + ", " + length3); for ( index = 0 ; index < sampArr3.length ; index++ ) { samp1 = sampArr1[index]; sampVal1 = samp1.getValue(); sampVal3 = sampVal1; // store the new sample value into the array for s3 samp3 = sampArr3[sampArr3.length - index - 1]; samp3.setValue(sampVal3); //sampArr3[index] = samp3; } return s3; } } // end of class