Mini-Lab: Changing Volume

 


Introduction

The objective of this mini-lab is to practice working with sound in JES.


Changing Volume

  1. In the Volume reading you saw a function that increases the volume of a sound by multiplying the sample values by a factor of 2. What would the factor be if we wanted to decrease the volume by a factor of 2? Would that be the only difference between increasing and decreasing volume?

    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.

Variations of Changing Volume

  1. In the Sound Manipulations reading, there is a function called increaseAndDecrease that 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?

  2. Write a new function called decreaseAndIncrease that 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 increaseAndDecrease function.
  3. Test this new function with several different sounds. Save the results of this function into a variable. Using the Media Tools -> Sound Tool in JES, open up the original sound and the new sound. Do you see what you would expect?
  4. Write a new function called gradualDecrease that 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.

  5. Test this function with several sounds. Open it up in Media Tools to see that it is doing what it should be doing.
  6. In the Sound Manipulations reading, there is a function called 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.

Submit your results

  1. Submit the file you created in this mini-lab via .

Post your results

  1. Create a new web page for this mini-lab. On this new page, post one original sound along with two variations of volume changes. (You can add sounds to your web page the same way that you add links.) Be sure to add some text to describe what is on your page.