Problems


[Page 308 (continued)]

9.1

What does each of the following mean:

  • Clip

  • Splice

  • Reverse

  • Mirror

9.2

What will be output from the following code:

public void test1() {   for (int x = 5; x > 0; x)   {     System.out.println(x);   } }


9.3

What will be output from the following code:

public void test2() {   for (int x = 0; x < 10; x = x + 2)   {     System.out.println(x);   } }


9.4

What will be output from the following code:

public void test3() {   for (int x = 1; x < 10; x = x + 2)   {      System.out.println(x);   } }



[Page 309]
9.5

Would this compile? If not, what change do you need to make so that it will compile?

public void test() {    System.out.println("In Test"); }


9.6

Would this compile? If not, what change do you need to make so that it will compile?

public int test2(int x) {    System.out.println("In Test2"); }


9.7

Would this compile? If not, what change do you need to make so that it will compile?

public void test3(int x) {    return "In Test3"; }


9.8

Would this compile? If not, what change do you need to make so that it will compile?

public String test4(int x) {    return x * 4; }


9.9

How many times will this loop execute?

for (int i = 5; i <= 10; i++)    System.out.println(i);


9.10

How many times will this loop execute?

for (int i = 1; i <= 10; i++)    System.out.println(i);


9.11

How many times will this loop execute?

for (int i = 0; i < 10; i++)    System.out.println(i);


9.12

Rewrite Program 71 (page 294) so that two input values are provided to the method: the sound, and a percentage of how far into the sound to go before dropping the volume.

9.13

Rewrite Program 71 (page 294) so that you normalize the first second of a sound, then slowly decrease the sound in steps of 1/5 for each following second. (How many samples are in a second? getSamplingRate() is the number of samples per second for the given sound.)


[Page 310]
9.14

Try rewriting Program 71 (page 294) so that you have a linear increase in volume to halfway through the sound, then linearly decrease the volume down to zero in the second half.

9.15

I think that if we're going to say "We the UNITED people" in the splice method (Program 74 (page 300)), the "UNITED" should be emphasizedit should be really loud. Change the method so that the word "united" is maximally loud (normalized) in the phrase "united people."

9.16

Try using a stopwatch to time the execution of the methods in this chapter. Time from hitting return on the command until the next prompt appears. What is the relationship between execution time and the length of the sound? Is it a linear relationship, i.e., longer sounds take longer to process and shorter sounds take less time to process? Or is it something else? Compare the individual methods. Does normalizing a sound take longer than raising (or lowering) the amplitude a constant amount? How much longer? Does it matter if the sound is longer or shorter?

9.17

Make an audio collage. Make it at least five seconds long, and include at least two different sounds (e.g., sounds from different files). Make a copy of one of those different sounds and modify it using any of the techniques described in this chapter (e.g., mirroring, splicing, and volume manipulations). Splice together the original two sounds and the modified sound to make the complete collage.

9.18

Compose a sentence that no one ever said, by combining words from other sounds into a grammatically correct new sound. Write a method named audioSentence to generate a sentence out of individual words. Use at least three words in your sentence! You can use the words in the mediasources folder on your CD or record your own words. Be sure to include a tenth (1/10) of a second pause between the words. (Hint 1: Remember that zeroes for the sample values generate silence or pause.) (Hint 2: Remember that the sampling rate is the number of samples per second. From there, you should be able to figure out how many samples need to set to zero to generate a 1/10 of a second pause.) Be sure to access your sounds in your Media Folder using getMediaPath so that it will work for users of your program as long as they first execute setMediaPath.

9.19

Write a method called erasePart to set all the samples in the 2nd second of "thisisatest.wav" to 0'sessentially making the 2nd second go silent. (Hint: Remember that getSamplingRate() tells you the number of samples in a single second in a sound.) Play and return the partially erased sound.

9.20

We've seen a method that reverses a sound and a method that can process samples by index number. Write a method called reverseLastHalf that reverses just the second half of the current sound. For example, if the sound said "MarkBark" the returned sound should say "MarkkraB."

9.21

Write a method similar to Program 79 (page 306) that mirrors from back to front.



Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
Introduction to Computing & Programming Algebra in Java(c) A Multimedia Approach
ISBN: N/A
EAN: N/A
Year: 2007
Pages: 191

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net