The objective of this mini-lab is to practice working with sound in JES.
Create a new function called
changeVolume that allows us to
increase or decrease the volume of a sound by any factor. This function
should take a sound and a factor as parameters. It should duplicate the
sound, and then change the sample values of the new sound appropriately
so that the volume changes. At the end of the function, the new sound
should be returned.
Test your new function to see that it can increase or decrease the volume of the sound. Remember to use a .wav file when you select a sound to use. If you need some sounds to pratice with, there are some available in the Media Sources directory.
increaseAndDecreasethat doubles the volume of the first half of a sound and decreases the volume of the second half of a sound by 40%. Type in this function (or copy and paste it) and test it with several different sounds. Do you hear how the volume changes?
decreaseAndIncreasethat decreases the volume by 50% in the first half of a sound, and increases the volume by 50% in the second half of the sound. This function should take a sound as a parameter, should duplicate the sound, make changes to the new sound, and then return the new sound. Think about how this function may be similar/different from the
gradualDecreasethat decreases the volume of the first third of a sound by 30%, then decreases the volume of the second third of a sound by 60%, and finally decreases the last third of a sound by 90%. Think about what the starting and ending values of your ranges will be.
normalize. This function increases the volume of a sound as much as possible without introducing any clipping. Type in this function and test it with several sounds.