## Lab 13

In this lab you will take a sound file and adjust parts of its volume to have the sound increase in volume over the first 3 seconds of the sound and then have it decrease in volume over the last 3 seconds of the of sound.

Assume a sound is X seconds long, then:

• the first second of the sound (time 0 seconds to time 1 second) is to be played at 1/4 of the original volume
• the second second of the sound (time 1 second to time 2 seconds) is to be played at 1/2 of the original volume
• the third second of the sound (time 2 seconds to time 3 seconds) is to be played at 3/4 of the original volume
• the next x - 6 seconds of the of the sound (time 3 seconds to time x-3 seconds) is to be played at the original volume
• the next second of the sound (time x-3 seconds to time x-2 seconds) is to be played at 3/4 of the original volume
• the next second of the sound (time x-2 seconds to time x-1 seconds) is to be played at 1/2 of the original volume
• the last second of the sound (time x-1 second to time x seconds) is to be played at 1/4 of the original volume
Remember that to determine the proper number of samples per second, we can use the getSamplingRate () method of the Sound object. So to determine how to break the sound into the various parts you need to know the sample numbers where these breaks occur. Thus to determine the proper sample values for the various times required for this project, we will need to get the sampling rate and the length of the sound.
• Time 0 is at sample number: 0
• Time 1 is at sample number: 1 * samplingRate
• Time 2 is at sample number: 2 * samplingRate
• Time 3 is at sample number: 3 * samplingRate
• Time x-3 is at sample number: length - (3 * samplingRate)
• Time x-2 is at sample number: length - (2 * samplingRate)
• Time x-1 is at sample number: length - (2 * samplingRate)
• Time x is at sample number: length
To divide the sound into the various pieces you should use a method similar to the "make sound byte" method that was written in class in example Lect1124c.java.

To modify the sound of each pieces, you should use a method similar to the "modify sound" method that was written in class in example Lect1105c.java.

To join the sound pieces back to gether you should use a method similar to the "join sound" method that was written in class in example Lect1119a.java.

### Lab Assignment 13

Due: Wednesday 12/2/2015 by 11:59 pm

Create a Java program that will be written using good programming style, which includes using:

• Multiple Methods
• Meaningful variable names
• In-line commenting
• Proper indentation of program statements
• Use of blank lines to separate blocks of code
• Header Block Commenting for the entire program
• Header Block Commenting for each method
Your header block comment for the program must include the following:
• Net-ID,
• Course Name,
• Assignment Name,
• Day and time of the CS 111 lab section (i.e. Monday at 11:00 am)
• A short description of the assignment
Your header block comments for each method must include the following:
• A description of the purpose of the method
• A listing of the name, type, and purpose of every parameter
• A description of the return value and its type
Required Methods for the Lab Assignment:
• Your program is to contain the main() method that will:
• Prompt the user for one sound file to be used for input for this lab.
• Diesplay an error and quit the program is the sound file is less than 6 seconds long.
• Call the "make sound byte" method multiple times to create the 7 different sound pieces.
• Call the "modify volume" method multiple times to change the volume of the a sound.
• Call the "join sounds" method multiple times to put all of the sound pieces together into on sound.
• Play (or explore) the sound.
• Prompt the user for a name and save it.

• Your program is to contain a method "make sound byte" that will
• Take 3 parameters
1. The first parameter will be a Sound object
2. The second parameter will be an integer value specifying a starting index
3. The third parameter will be an integer value specifying an ending index
• Return a newly create sound object that will contain only the samples from the index given by the second parameter up to the index given by the third parameter

• Your program is to contain a method "modify volume" that will
• Take two parameters:
1. The first parameter will be a Sound object.
2. The second parameter will be an integer value.
• Modify the volume of the sound using the amount given by the second parameter. The amount is to be considered as a percent value. Thus a value of 100 keeps the volume unchanged. A value greater than 100 increased the volume, whilea value between 0 and 100 lowers the volume.
• check for and correct any "clipping" that may result from the resulting value being greater than 32,767 or less than -32,768.

• Your program is to contain a method "join sounds" that will:
• take two sound objects as parameters and
• return a newly created sound object.
• The newly created sound object will contain the first sound object followed by the second sound object. (This is similar to the makeCollage() methods we created for pictures.)
You are also to submit the Java file electronically via the assignment link for Lab 13 in BLackboard.

-- Main.troy - 2015-11-29

Topic revision: r1 - 2015-11-29 - 22:19:19 - Main.troy

 Copyright 2016 The Board of Trustees of the University of Illinois.webmaster@cs.uic.edu WISESTHelping Women Faculty AdvanceFunded by NSF