Lab 12
Reminder
The program Jython Environment for Students (or JES) is the
development environment that we will use for this lab.
In the ACCC Labs that have JES, it can be found by:
- Clicking on Start
- Then click on All Programs
- Then click on Class Applications
- Then click on Engineering
- Finally click on Jython Environment for Students
Combine Sounds
For this lab assignment, we will convert a high resolution
sound file with a sampling rate of 44,100 samples per second
to a low resolution sound file with a sampling rate of 22,050
sample per second. You may wish to refer back to
lab10 for another assignment that worked with the sampling
rate of a file.
You will find the following functions useful for this assignent.
getSamplingRate
|
getSamplingRate(sound):
sound: A Sound, the sound you want to get the sampling rate from.
returns: An Integer representing the number of samples per second.
Takes a sound as input and returns the number representing the number of samples in each second for the sound
|
getLength
|
getLength(sound):
sound: the sound you want to find the length of.
returns: the number of samples in sound.
Takes a sound as input and returns the number of samples in that sound.
|
makeEmptySound |
makeEmptySound(duration):
duration: An integer, time in seconds for duration of sound
returns: An Empty Sound.
Takes a duration in secounds as sinput and returns the empty sound.
|
getSampleObjectAt
|
getSampleObjectAt(sound, index):
sound: A Sound, the sound you want to get the sample from.
index: An Integer, the index value of the sample you want to get.
returns: The sample object at that index.
Takes a sound and an index (an integer value), and returns the Sample object at that index
|
setSampleValueAt
|
setSampleValueAt(sound, index, value):
sound: A Sound, the sound you want to change a sample in.
index: An Integer, the index of the sample you want to set.
value: An Integer, the new value of the sample you want to set.
Takes a sound, an index, and a value (should be between -32000 and 32000), and sets the value of the sample at the given index in the given sound to the given value.
|
Lab Assignment 12
Due: Tuesday 4/17/2007 by 11:59 pm
Create a file using JES that will:
- Contain a comment indicating
- your Name,
- Net-ID,
- Course Name,
- Assignment Name and
- a short description of
the assignment
- Contain a JES function called convertToLowRes () that will
- Take a sound object as its parameter.
- Check to see if the sampling rate is already at low resolution
(22,050 samples per second). If so, print a message stating the sound
object is already at
low resolution and the return the sound object given as the parameter.
- Determine the length in seconds of the sound object given as the
parameter. This is done by dividing the total number of samples
in the sound object by the sampling rate.
- Create a new low resolution sound object that that will contain
the low resolution version of the sound object given as the parameter.
Use the JES function of makeEmptySound () to do this. The
sampling rate of the sound object created by makeEmptySound ()
is 22,050 samples per second.
If original sound object's
length is not an exact multiple of 1 second, increase the length to the
next full second. For example, if the original sound object is 74.38 seconds
long, the new sound object should be 75 seconds long. This is needed
because makeEmptySound () can only create sounds that are
exact multiples of 1 second.
- Copy every other sample from the original sound object to the new
sound object.
- Return the new sound object.
- Contain a JES driver function called lab12 () that will
- Prompt the user to open a sound file using pickAFile().
- Make a sound object from the file.
- Call converToLowRes () with this sound object.
- Store the sound object returned by convertToLowRes ()
is a file selected by the using using pickAFile ().
- Play the low resolution sound object.
These functions may call other functions that are built-in to JES or
that you have written.
Look for sample high resolution sound files inside of Blackboard
under Assignments.
Submittal of the Lab Assignment
- You are submit your program electronically by placing it in the
digital drop box in blackboard.
- Programs that are correct and
submitted by noon on the Wednesday
the lab assignment is discussed will receive an extra 10% on the
score of the lab.
- When saving your program, use a meaningful name like lab12.py.
- When submitting your lab assignment, place all of the needed files it in a
zippped folder (even if you are only submitting one file) with the name
of yournetid_labNum and submit that zipped folder to the digital
drop box. For instance, if your net id is
abc32 then the folder name should be abc32_lab12.
Comments on the ACCC Labs
On the computers in the ACCC Labs there should an H: drive.
This drive is actually a networked connection to your own file space
maintained by the ACCC. No matter what machine you use or what lab
you are in, the H: drive will access the same file space. This means
that you can save a file on the H: drive on a computer in one lab and
access that same file on a computer in another lab. This can be very
helpful. It is suggested that you store your python program files
on your H: drive.