## Lab 12

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 () function from the JES library. 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 function similar to the "make sound byte" function that was written in class in example lect0411b.py.

To modify the sound of each pieces, you should use a method similar to the "increase volume" function that was written in class in example lect0328d.py.

To join the sound pieces back to gether you should use a function similar to the "join sound" functionthat was written in class in example lect0411a.py.

### Lab Assignment 12

Due: Wednesday 04/19/2017 by 11:59 pm

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

• Multiple Functions
• 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 function
• 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
• A description of the purpose of the function
• A listing of the name, type, and purpose of every parameter
• A description of the return value and its type
Required functions for the Lab Assignment:
• Your program is to contain the main() function that will:
• Prompt the user for one sound file to be used for input for this lab.
• Display an error and quit the program is the sound file is less than 6 seconds long.
• Call the "make sound byte" function multiple times to create the 7 different sound pieces.
• Call the "modify volume" function multiple times to change the volume of the a sound.
• Call the "join sounds" function 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 function "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 function "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, while a 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 function "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() functions we created for pictures.)
You are also to submit the Python program file electronically via the assignment link for Lab 12 in Blackboard.
Topic revision: r1 - 2017-04-17 - 13:17:01 - Main.troy

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