/** * 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 Lect1111b { public static void main (String[] args) { String fname = FileChooser.pickAFile(); //System.out.println (fname); Sound s = new Sound (fname); 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); increaseVolume (s); s.explore(); } public static void increaseVolume (Sound s) { SoundSample sampArr[] = s.getSamples(); SoundSample samp; int index; int sampVal; System.out.println ("Number of samples in the sound: " + sampArr.length); for ( index = 0 ; index < sampArr.length ; index++ ) { samp = sampArr[index]; sampVal = samp.getValue(); sampVal = sampVal + 100; // multiple by 2 to double the volume of the sound sample // check for clipping if ( sampVal > 32767 ) sampVal = 32767; if ( sampVal < -32768 ) sampVal = -32768; samp.setValue(sampVal); //sampArr[index] = samp; } } } // end of class