CSI Lab 09

Tuesday, March 24th


Structure Details

I want to try something different this week.

For this week's lab you are encouraged, although not required, to work with a partner.  The advantage of working with a partner is that two heads are better than one, and you can benefit from discussing the problems with a partner. 

Before you begin, decide between yourselves who will be Partner A and who will be Partner B.  Please notice as the lab goes on that you will change roles several times.  Sometimes you will be the "coder" - the person in charge of the keyboard - and sometimes you will be the "supervisor" - the person in charge of telling the coder what to write.  In order to make this activity work, it is important that you change these roles a couple of times during the class.

You may feel free to turn in ONE signed form for the team, just include the names of BOTH team members on the form.


Introduction

In this week's lab you will be looking at how to play with sound using the materials presented in chapters 6 and 7 in your textbook. 

For this week's lab, you will need to have the following sound file downloaded onto your computer and placed in the mediasources folder where we have been placing your picture files.


Activity A : Creating a Sound "Negative"

[Partner A - coder :  Partner B - supervisor]

Yesterday in class we talked about different things that you could do to a Picture file and we started looking at which ones had "compliments" when dealing with Sound files.  In class we looked at the concept of increaseRed() vs. increaseVolume() and we looked at different versions of posterize() by creating sound whose values were only multiples of 100 and then a sound with only max and min sound sample values.

One of the Picture techniques that we talked about was the creation of a photo negative.

A photo negative is an image where every pixel has been replaced with it's "opposite" value.  In the case of a pixel, an opposite color is one where each of the  Red, Green, and Blue values have been moved to the opposite end of the spectrum.  Thus, the "opposite" of  pure Red (255,0,0) is Cyan(0,255,255).  Similarly, the opposite of a purplish color (250, 12, 232) would be a mostly green color (5, 243, 23).

[Q1]  Run this method on the bassoon sound that you downloaded above.  Does the result sound any different?

[Q2]  Run this method on the preamble sound that you downloaded.  Does the result sound any different?

[SIG 1] : Demonstrate soundNegative() for a TA.


Activity B : Increase the Volume, and then Decrease the Volume- The Specialized Version

[Partner B - coder :  Partner A - supervisor]

Up until now our Sound methods have focussed on "filters" - methods that worked on every sound sample regardless of position in the sound.  But as we discussed in class yesterday, there are a whole variety of actions that require us to understand the position of the sample within the sound.  Let's introduce the concept of sound by considering some simple code from your book.

Program 57 on page 169 of your textbook is a method called increaseAndDecrease().  Enter this program into your Sound class.  Test the method on one of the sound files provided, or one of your choice.

sound1 = makeSound( "preamble.wav" )
increaseAndDecrease(sound1)
play(sound1) 

[SIG 2] : Demonstrate the specialized version of  increaseAndDecrease() for a TA.


Activity C : Increase the Volume, and then Decrease the Volume- The Generalized Version

[Partner A - coder :  Partner B - supervisor]

The code you wrote in Activity B is good, but it is very specific.  You can only make half "loud" and then half "soft."   A more generalized method would be one that makes some part loud and then the remaining part soft.  This activity creates that generalized version.

Create a version called  increaseThenDecrease() .  This version should take a sound and a single int as parameters.  It can be assumed that this is a number between 0 and 100 inclusive.  This number should indicate what percentage of the sound clip should be increased in volume.  The remaining part should then have its volume decreased.  

In other words

sound1 = makesSound( "preamble.wav" )
increaseThenDecrease(sound1,50)
play(sound1) 

should sound exactly the same as the sound you produced in the previous activity. 

While

sound1 = makesSound( "preamble.wav" )
increaseThenDecrease(sound1,20)
play(sound1) 

should get quiet much sooner.

[SIG 3] : Demonstrate  increaseThenDecrease() for a TA.


Activity D : Mirroring a Sound

[Partner B - coder :  Partner A - supervisor]

Now that you understand a bit about working with sounds based on a sample's position in the sound, let's see if you can apply this to another program from scratch.

One of the Picture methods we discussed yesterday was the concept of a mirror.  For example, Recipe 19 on page 77 mirrored a picture from left to right (the results are in figure 4.2 on page 78).

[Q3]  Run this method on the preamble sound that you downloaded.  What do you "observe"?

[Q4]  Run this method on the bassoon sound that you downloaded.  What do you "observe"?

[SIG 4] : Demonstrate the generalized mirrorSound() for a TA


Activity E : Mystery Method

[Partner A - coder :  Partner B - supervisor]

Consider the method below:

[Q5]  What do you think the programmer expected this method would do to a sound?

[Q6]  Type it into JES and run this method using the preamble as an input sound.  What do you hear? (Note, if you are "typical" what you expected in Q5 and what you observed here should be very different)

[Q7]  Why do you think that you produced the affect you observed in Q6?

Fix this piece of code so that it does what you EXPECTED it to do in [Q5]






[SIG 5] : Demonstrate the FIXED version of mysteryMethod() for a TA.