Prelab 5: Exploring Sound
1. Review background reading
2. Record sounds on your iPod
Using your iPod and the microphone, record a number of sound files. See the
online
instructions for help using the voice recorder. These
recordings should include:
- High-pitched sound
- Low-pitched sound
- Sound with low maximum amplitude
- Sound with high maximum amplitude (i.e. quiet)
- Music
- Same music as above but recorded over the phone
- Electronic sound (e.g. buzzer, beeping, alarm)
- Human-generated version of above sound
3. Set up your iPod
Set up your iPod so that disk use is enabled. See the Duke Digital
Initiative for instructions on using your iPod as a hard disk.
4. Review loops
Below is a method from the class notes, increaseVolume, that will be added to
the Sound class.
1 public void increaseVolume()
{
2 SoundSample[] sampleArray = this.getSamples(); // get array
3 int index = 0; // starting index
4 SoundSample sample = null; // current sample obj
5 int value = 0; // value at sample
// loop through SoundSample objects
6 while (index < sampleArray.length)
{
7 sample = sampleArray[index]; // get current obj
8 value = sample.getValue(); // get the value
9 sample.setValue(value * 2); // set the value
10 index = index + 1; // increment index
}
}
Answer the following questions
- What is
sampleArray? For a particular Sound, what does
sampleArray.length represent?
- What do the lines 7-9 do for a particular sample?
- The method is called increaseVolume. How does it do that?
Jeffrey R.N. Forbes
Last modified: Sun Oct 2 01:51:03 EDT 2005