Lab 11
THis lab will have you combine two sound files to add a "background"
soundtrack to a foreground sound. The following files of the
Gettysburg Address and the Preamble of the U.S. Constitution are
great foreground sound files.
To combine two sound files, you simply just add the sample values together.
The only problem occurs if the
resulting value goes above 32,767 or below -32,768. A simple solution
is to use an if statement to check for this. Two simple
if statements can check for this and correct the problem if it
occurs. To correct this, just set the value to either 32,767 if
the value was greater than 32,767 or set the value to -32768. if
the value was less than -32,768.
The functions of
are useful for getting the sample values.
Lab Assignment 11
Due: Thursday 11/13/2008 by 11:59 pm
Create a Java program that will:
- Contain a comment indicating
- your Name,
- Net-ID,
- Course Name,
- Assignment Name and
- a short description of
the assignment
- Contain the main() method that will
- Prompt the user for the "Foreground" sound file and make a sound object
from this file.
- Prompt the user for the "Background" sound file and make a sound object
from this file.
- Add the background sound file to the foreground sound file, but the
volume of the background sound should be one-third of the sound from its
original file. To do this, first divide the background sound sample
values by 3 before adding the two values together.
- check for and correct any "clipping" that may result from the resulting
value being greater than 32,767 or less than -32,768.
- Note: if the background sound file is shorter than the foreground
sound file, stop combining the two sounds once you run out of background
sound samples.
- play (or explore) the resulting sound and prompt the user to save it in a file
Here are some example sound files you can use with this assignment.
Submittal of the Lab Assignment
- When saving your program, use a meaningful name like lab11.java.
- You are also to submit the Java file
electronically by
using the UNIX turnin command.
- You are also required to submit the image that you selected the
x-start, y-start, x-end and y-end values.
To use the UNIX turnin command to electronically hand-in your
html file using the project name of lab11. To submit the files in
lab11.java and BlendIn.jpg for lab11, the turnin command is entered as:
turnin -c cs101 -p lab11 lab11.java BlendIn.jpg
To verify what you submitted using the turnin command type:
turnin -c cs101 -p lab11 -v