Setting and Changing Tempo

The last three looks blocks provided by Scratch are shown in Figure 11.10. Using these blocks you can set, change, and report on the tempo at which drum beats and musical notes are played.

Figure 11.10. These code blocks allow you to modify and report on the tempo used by a sprite to play beats and notes.


The first code block shown in Figure 11.10 changes the tempo used to play a drum or note. Tempo is a measurement of the speed, in beats per minute, at which a drum or note is played. The larger the tempo value, the faster the drum or note is played. The second code block lets you set the tempo used to play a drum or note to a specific number of beats per second. Using the third code block, you can retrieve a sprite’s currently assigned tempo and optionally display this value in a monitor on the stage.

The following script demonstrates how to set and modify a sprite’s tempo when playing musical notes:

Here, the tempo used to play notes is set to 60 beats per minute, and then, after a one-second pause, a C note is played five times in a row, each time for a half a beat. After another one-second pause, the sprite’s tempo is slowed down by 20 beats per minute, and another C note is played five times.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.69.49