CS 111 - Introduction to Computing

Lab 12

In this lab, you will take the Sound File preamble.wav and create a new sentence from those words.

The sentence you are to create is:

We united justice to provide the perfect order of tranquility.

The entire text of the Preamble is:

We the People of the United States, in Order to form a more perfect Union, establish Justice, insure domestic Tranquility, provide for the common defence, promote the general Welfare, and secure the Blessings of Liberty to ourselves and our Posterity, do ordain and establish this Constitution for the United States of America.
The following words begin at the given sample numbers in the file:

  • 7519 We
  • 15235 the
  • 18742 people
  • 29767 of
  • 32457 the
  • 34045 United
  • 40527 States
  • 54838 in
  • 58653 order
  • 64386 to
  • 67561 form
  • ????? a - not sure if this was actually read
  • 74859 more
  • 78894 perfect
  • 86744 union
  • 101363 establish
  • 116027 justice
  • 132829 ensure
  • 142134 domestic
  • 152012 tranquility
  • 174240 provide
  • 185130 for
  • 189122 the
  • 189189 common
  • 196112 defense
  • 212000 promote
You will need to read in the sound file separate out the needed words and then join the word together into a single sound. The code to separate out the needed words can be found in Lect0416c.java, while the code to join them together is found in Lect0416b.java.

You may want to include some break/silence between the words of your newly created sentence.

To separate out a specify word from a longer sound:

  • First determine the starting and ending sample index of the needed word.
  • Next create a new sound of the length between the starting and ending indices. (Subtract the starting index from the ending index).
  • Copy the sample values from the starting index to the ending index place them in the new sound beginning at index position 0.
To join two sound objects together into a new sound:
  • First determine the length of the two original sound objects. The length of the new/joined sound object will be these two lengths added together.
  • Next copy all of the samples from first original sound object into the new/joined sound object (where the first original sound object's sample is placed into the first sample of the new/joind sound object).
  • Final copy all of the samples from the second original sound object into the new/joined sound object but the position needs to be shifted by the length of the first original sound object.

Lab Assignment 12

Due: Wednesday 4/22/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:
  • Your name,
  • 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 use for the sound file to be used for input for this lab.
    • Create each individual word needed by using multiple calls to the "make sound bite" method specified below.
    • Join those words into the required sentence using multiple calls to the join sound method specified below.
    • Play (or explore) the sound.
    • Prompt the user for a name and save it.

  • Your program is to contain a method called makeSoundByte() that will:
    • take a sound as its first parameter,
    • take two integer values as its second and third parameters
      • verify that the second and third parameters contain valid values:
      • the value of the second parameter is greater than or equal to zero
      • the value of the second parameter is less than or equal to the third parameter
      • the value of the third parameter is less than or eqaul to the length of the sound given as the first parameter.
    • create a newly created sound that contains only those samples found between the index posistions indicated by the integer values given as the second and third parameters
    • return the newly created sound from the method

  • Your program is to contain a method called join() 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 12 in BLackboard.

-- Main.troy - 2015-04-20

Topic revision: r2 - 2015-04-21 - 16:57:23 - Main.troy
Copyright 2016 The Board of Trustees
of the University of Illinois.webmaster@cs.uic.edu
Helping Women Faculty Advance
Funded by NSF