|
|
COMP2720 — Lab 3 —
Week 7 (4th and 5th September 2008)
Sound manipulation
Draft — Slight changes and corrections
might be done in the next few days.
If you have headphones please bring them along
to this lab in order to reduce the sound level in the lab room.
Objectives
Learn about how sounds are manipulated using loops, how to access
and manipulate parts of sounds, and how to combine sounds.
Marks and submission
- You will get one mark if you attend this lab, and another mark
when you show and demonstrate your working to your tutor.
- The mark for your lab workings will only be awarded in the lab. You
can show your workings in this lab as well as the following lab
4 in week 8 (after the semester break). You will not receive a mark
for this lab if you show it to your tutor after the lab in week 8,
unless you have a medical certificate (or similar document) stating
that you were unable to attend the normal lab.
- Please do NOT e-mail your lab workings to your tutor — we will
NOT mark e-mailed lab workings. You can only get the mark for
workings in the labs.
Preliminaries
- Once logged onto a computer, create a sub-folder called
lab3 in your folder comp2720.
- Download the lab-template.txt
and save it in your lab3 folder under the name
lab-3-diary.txt.
Please only save your lab diary as simple text file, not in RTF
or DOC format (as you will have to include your lab diaries into
your portfolio, and we will not be looking at RTF or DOC files
when assessing your
portfolio).
- Open this file lab-3-diary.txt with a text editor, and
complete the header with your details. Keep this file open and
continue writing down your workings and paste your programs
into it.
- Now copy the following files into your lab3 folder:
Part 1: Normalising and playing sounds backwards
You should spend around 20 minutes on this part of the lab.
- Open the program normalise.py (from the Sounds-2
lecture) into the JES editor, read through it and then run it
on several of the provided sounds (play the sounds before you
normalise them, and afterwards). Inspect the sounds in the JES
MediaTools before and after the normalisation. Describe
your observations into your lab diary.
- Note that some sounds have 1-byte (8 bits) per sample, while
others have 2- bytes (16 bits) per sample. Can you normalise both
1-byte sounds and 2-bytes sounds with the same normalise
function? If not, change this function appropriately. The 1-byte
samples should have a largest sample value in the normalisation
of 127. Write into your lab diary how you changed the
normalise function, and which of the sounds you normalised
were 1-byte and which were 2-bytes.
- Next, open the program playBackward into JES, read it
and run it on several sounds (including the
elliot-hello.wav sound).
- Now combine the two programs normalise and
playBackward into one new program called
normaliseBackward.py, which takes as input a sound,
normalises it, and then turns it around (backwards) before
returning the normalised backwards sound. Test the
results using different sounds and visualise it in the
MediaTools. Once you're happy with your program describe
it (for example by adding appropriate comments) and copy it
into your lab diary.
Part 2: Extract and play a section of a sound
You should spend around 30 minutes on this part of the lab.
In this part you should design a program that does the following
(these are the requirements):
- Write a Python/JES function called playSection which takes
as input
- a sound,
- the beginning of a selection in seconds (as a floating-point
number, for example 0.1 = 100 milli-seconds; one
second contains 1,000 milli-seconds), and
- the end of a selection in seconds (as a floating-point
number).
- Your program should calculate the starting and end sample number
according to the beginning and end times given as input.
- The program should then print this starting and end sample number.
- Next, your program should create a new sound, which only contains
this selection of the original sound. You can use the empty
(i.e. silent) sounds sec1silence.wav or sec3silence.wav
from the
COMP2720
examples Web page for this. Your program should basically copy the
selection into the beginning of the silent sound.
- Then your program should play this selection sound.
- Finally, your program should return this selection sound.
As discussed in lecture Design-1, you can approach this part of
lab 3 using either a top-down or bottom-up approach. You
should describe your approach, and the process of how you developed your
program, in your lab diary. Please also write down what you think of
the approach you choose - was it a good choice?
Part 3: Create a sound collage
You should spend around 40 minutes on this part of the lab.
- Write a program soundCollage.py with loads at least three
different (short) sounds, and then creates a new sound which is
at least 3 seconds long (use the silent sound sec3silence.wav
for this). Various short sounds are provided on the
COMP2720
examples Web page, but you might search the Web for more,
or even digitise your own sounds on your computer.
- You can also use your playSection.py program from part 2 above
to extract short sections out of longer sounds, so that you can use
them for your sound collage (you might have to add the function that
writes a sound into a file to your playSection.py
program).
- Now copy the short sounds into the long collage sound in a
repetitive pattern - so that the final collage contains a
rhythm made of the short sounds.
- You might want to normalise all the sounds you are using first, so
they all have the same loudness.
- In the final step your program should play the rhythm collage
sound and then return it.
Part 4: Show your workings to your tutor
You should spend around 10 minutes on this part of the lab.
- Explain and show to your tutor what you have done in parts 1,
2 and 3 of the lab, play the resulting sounds created, and the
programs you have developed.
- Please also show your tutor your lab diary.
Further programming ideas
|
In each lab we will provide a last section that contains ideas
for people who want to dig deeper, who are hooked on
Python or media programming. This section is not part
of the assessable lab material, but rather provides some more
problems for students who love a programming 'challenge'.
|
- Develop two function fadeIn and fadeOut which
modify a given input sound so that it's being faded in (i.e.
set the volume to zero at the beginning of the sound and then
slowly increasing it) or faded out (volume is decreased at the
end of a sound towards zero). A possible input parameter to
these functions could be the fading time in seconds.
You then have to calculate the number of samples the fading
process corresponds to (according to the sampling rate).
- A related function would allow you merge or blend
sounds by overlapping them for a certain time period, and fading
the first sound out while fading the second sound in.
Last modified: 4/08/2008, 23:40
|