/** * Class for creating a template for a simple Java program * * @author Pat Troy: troy AT uic DOT edu */ // Note the name of the class in the following line MUST // match the name of the file. public class Lect1115e { public static void main (String[] args) { System.out.println("Begin Java Exection"); System.out.println(""); // put your Java Program here String filename = FileChooser.pickAFile(); Sound s = new Sound (filename); System.out.println ("S1 Length: " + s.getLength()); System.out.println ("S1 Sampling Rate: " + s.getSamplingRate()); filename = FileChooser.pickAFile(); Sound s2 = new Sound (filename); System.out.println ("S2 Length: " + s2.getLength()); System.out.println ("S2 Sampling Rate: " + s2.getSamplingRate()); Sound s3; s3 = joinSounds (s, s2); System.out.println ("S3 length: " + s3.getLength()); s3.explore(); System.out.println(""); System.out.println("End Java Exection"); } public static Sound joinSounds (Sound s1, Sound s2) { int l1 = s1.getLength(); int l2 = s2.getLength(); int l3 = l1 + l2; Sound s3; s3 = new Sound (l3); SoundSample ssarray1[]; SoundSample ssarray2[]; SoundSample ssarray3[]; int largest; int value1; int value2; int value3; int i; double mult; ssarray1 = s1.getSamples(); ssarray2 = s2.getSamples(); ssarray3 = s3.getSamples(); for ( i = 0 ; i < l1 ; ++i ) { value1 = ssarray1[i].getValue(); ssarray3[i].setValue(value1); } for ( i = 0 ; i < l2 ; ++i ) { value2 = ssarray2[i].getValue(); ssarray3[i + l1].setValue(value2); } return s3; } } // end of Template class