Difference between revisions of "CS110:Lab09"

From IPRE Wiki
Jump to: navigation, search
('''Sound''')
('''Sound''')
Line 35: Line 35:
  
  
Do This: Program the Scribbler to create a siren by repeating two
+
'''Do This:''' Program your Scribbler to create a siren by repeating two
 
different tones. You will have to experiment
 
different tones. You will have to experiment
 
with different pairs of frequencies (they may be close together or far apart) to
 
with different pairs of frequencies (they may be close together or far apart) to
 
produce a realistic sounding siren. Write your program to play the siren for 15
 
produce a realistic sounding siren. Write your program to play the siren for 15
seconds.The louder the better!
+
seconds. The louder the better!
 
You can also have Myro make a beep directly out of your computer, rather
 
You can also have Myro make a beep directly out of your computer, rather
 
than the robot, with the command:
 
than the robot, with the command:

Revision as of 05:28, 4 November 2009

Lab 09: Exploring Music

Objective

  • Learn some fundamentals of sound and music
  • Create musical compositions

Sound

Having explored and used many of the robot commands by now, you have seen that your robot make beeps when you call the beep() function. For instance, if you execute the following command:

beep(3, 880)

This command tells your robot to play a tone at 880 Hertz for 3 seconds. Hertz is a unit that measures frequency.

1Hertz = 1cycle / second

Therefore, a beep at 880 Hz represents 880 complete cycles per second. Humans can hear frequencies in the 20 Hz to 20000 Hz (or 20 Kilo Hertz) range and are able to distinguish sounds that differ only by a few Hertz (as little as 1 Hz). This ability varies from person to person.

Try the following commands and see if you can distinguish between the two tones:

beep(1, 440)
beep(1, 450)

To make the tones more distinctive, place the commands above in a loop so that you can repeatedly hear the alternating tones.


Do This: Program your Scribbler to create a siren by repeating two different tones. You will have to experiment with different pairs of frequencies (they may be close together or far apart) to produce a realistic sounding siren. Write your program to play the siren for 15 seconds. The louder the better! You can also have Myro make a beep directly out of your computer, rather than the robot, with the command:

computer.beep(1, 440)

Assignment 09

Links to Course-Related Pages