This lab will have you prompt the user for an amount to change the volume of a sound file. You are to prompt the user for a percent value using the getIntNumber() method of the SimpleInput class. You are to then multiply every sample in the sound file by this percent value. The basic calculation is to first multiply by the value entered by the user, then divide the result by 100. Note that if the user enters in a value between 0 and 99, the volume of the sound file will be decreased. If the user enters a value greater than 100, the volume will be increased. If the user enters 100, the volume will be unchanged.
Note you will want to check out the sample Lect1103b.java. This code doubles the volume in a sound file by multipling the value at every sample by 2.
Also, remember range of valid sample values is from -32,768 to +32,767. For this lab, you must also check to see if the sample value falls out of this range after the multiplication is done. If the sample value becomes greater than +32,767, set the value to +32,767. If the sample value becomes less -32,768, set the value to -32,768. This is simply done by use of two if statements. One of these if statements is as follows:
if (sampVal > 32767) { sampVal = 32767; }
Here are some sample sound files that can be used for this lab:
The method in the Sound class of getSamples() will allow you to access an array of SoundSamples which will allow access to the sound. The methods in the SoundSample class of
Create a Java program that will:
Here are some example sound files you can use with this assignment.