CS116      Lab 6 - Sounds

Objectives:

  1. Before starting this lab you should have read chapters 8, 9 and 10 in your text.
     
  2. Open DrJava and the Sound class.
     
  3. Take a look at the Sound class.  We can open a sound file with the FileChooser and then use the play method to play a sound.  (It would be appreciated if you bring headphones to class so that all of you can experiment with sounds easily).
     

  4.  

    Assignment:
    Write a method
      public Sound taperEnd(int num)
    which returns a new sound that is the same as the calling sound except that the last num samples taper off to zero volume at a constant rate.

    Hint:  Consider the ration (num-i) / num.  When i is 0 this ratio will be 1 and when i is num it will be 0.  If we have a loop with i ranging from 0 to num we will get the desired taper value factor from this ratio.  The index into the array is not i so you will need to figure out what index you will need.


     

  5. We can combine two sounds together simply by adding their values.

    Assignment:
    Write a method
      public Sound add(int start, Sound overlaySound)
    which creates a new sound of the appropriate length.  It contains all parts of both sounds.  The calling sound is copied to the new sound and then starting at the sample indicated by start, the overlaySound will also be played (both at the same time).  If the overlay sound extends beyond the length of the calling sound, then be sure your combined sound is long enough.


     


  6.  

    Assignment:
    Write a method
      public Sound stutter(int start, int end, int numRepeats)
    which creates a new sound that is the same as the calling sound except that the portion of the calling sound between start and end (inclusive) is now repeated numRepeats times.


     


  7.  

    Assignment:
    Write a program Audio which creates an audio collage.  Your collage should contain multiple sounds that are transformed in several different ways.  You may use the methods we wrote here, those which are contained in the text, or any others that you devise.  The result of the program should be a single audio file containing your collage.


     

  8. Send your modified Sound.java, Audio.java, and your resulting audio collage file to me using GoucherLearn.