/** * 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 Lect420b { public static void main (String[] args) { String fname = FileChooser.pickAFile(); //System.out.println (fname); Sound s = new Sound (fname); Sound s2; System.out.println ("Number of samples in the sound: " + s.getLength()); System.out.println ("Number of samples per second: " + s.getSamplingRate()); double lengthInSeconds = s.getLength() / s.getSamplingRate(); System.out.println ("The length in seconds of the sound: " + lengthInSeconds); s2 = increasePitch(s); s2.explore(); } // the pitch will increase as we remove every othere sample // from the sound public static Sound increasePitch (Sound s) { SoundSample sampArr[] = s.getSamples(); int index; int modifiedIndex; int sampVal; Sound newSound = new Sound (s.getLength()/2); SoundSample sampArr2[] = newSound.getSamples(); System.out.println ("Number of samples in the sound: " + sampArr.length); for ( index = 0 ; index < sampArr2.length ; index++ ) { modifiedIndex = index * 2; sampVal = sampArr[modifiedIndex].getValue(); sampArr2[index].setValue(sampVal); } return newSound; } } // end of class