In this lab, you will take a single sound file and have it fade in (increase) from silence to full volume and then fade out (decrease) into silence again. Program 71 from the book will be a very helpful method to use in this lab! You can find sample soundtrack files to use for this lab here.
Also, this code might help you out as well.
Think about what happens when you are increasing the volume of a sound. Say I have a sound that I divide into 10 sections. Each sections is 1/10th of entire sound. At the end of the sound I want to have full volume, yet at the beginning I want to have silence. I can do this by first finding the number of SoundSamples in each of the 10 sections (i.e. total number of samples divided by 10). That means that I can break my sound into 10 sections, where on each section I increase my volume by an additional 10%. By the time I have reached the end of the song, I will have been at full volume. Note that is is different than what was done during class with example Lect412d.java.
I will do the same for when I decrease a sound, only this time it is the reverse.
You may have to use doubles when you step up to the next interval. Because you will increase each sample by a percentage, you will have to use a double. However, you may recast this value to an int when you set the SampleValue in the new sound file.
The result will be a file that increases in "steps", but for the purposes of this exercise this is OK. Hopefully you will not notice it!
This lab will require three methods. The first method will take in the first half of the sound and increase the volume from silence to 100%. The second method will take in the second half of the sound and decrease the volume from 100% to silence. Finally, a third method will put these two parts back together again.
You should also have code to save the sound on the hard drive.
Create a Java program that will:
Your header block comment for the program must include the following:
Header block comments for each method must include the following:
Here are some example sound files you can use with this assignment.