Music Extension: Beats and Play Drum
-
Prerequisite
Beat and Tempo
A beat is a very short time. We use beats to control how long a sound is played.
In the CreatiCode playground, 1 beat is equal to 0.25 (1/4) seconds. So, if you play a piece of music for 4 beats, it will last for exactly 1 second.
We can use tempo to define the length of one beat. Tempo is the number of beats in each minute. In CreatiCode, the default value of tempo is 240. For example, if you want to play some music at a slower speed, you can set the tempo to a smaller number.
Loudness
Loudness controls the volume of the sound.
Loudness has different levels, which are represented by letters “p” and “f”, where “p means quiet” and “f means loud or strong”.
The following are the loudness levels you can find in CreatiCode;
The Music Extension
The Music Extension is a group of blocks that allow you to play and create your own music. With these blocks, you can play drums and notes of different instruments, at different values of beats and tempo.
How to add the Music Extension?
To add a music extension to a project, click on the “Add Extension” button below the blocks categories, and then select “music” from the extension library.
Music Extension Blocks
The “Play drum () for () beats” Block
This block plays a specified drum sound for some number of beats. There are 18 different types of drums and instruments which you can choose from the drop-down menu.
The animation below shows how to play Snare Drum for 1 beat.
The animation below shows how to play Tambourine for 4 beats.
The “Play drum () for () beats loudness ()” Block
This block plays a drum sound for the given number of beats at the selected loudness level. You can change the loudness level from the drop-down menu.
Snare drum at loudness level mp:
Snare drum at loudness level ppp:
Snare drum at loudness level fff:
The “Set tempo to ()” Block
This block sets the tempo to a new value.
Note: The value of tempo affects all the blocks in the music extension. If the value of tempo is greater than or equal to 240, the “Play drum”, “Play notes” and “Rest for () beats” blocks will play faster. If the value of tempo is less than 240, those blocks will play sounds at a slower speed.
Tempo of 240:
Tempo of 350:
Tempo of 50:
“Change tempo by ()” Block
This block changes (increases or decreases) the value of tempo according to the given number.
Note: To increase the value of tempo, just type a number in the input box. To decrease the value of tempo, type a number with a minus sign before it.
Increase the value of tempo by 35.
Decrease the value of tempo by -35.
The “Tempo” Block
This is a reporter block that reports the current value of tempo. You can also use this block to display the value of tempo on stage.
“Rest for () beats” Block
This block pauses the sound of the blocks attached below it by the given number of beats.
Note: The value of beat is affected by the value of tempo. If the tempo is greater than or equal to 240, the “Rest” block pauses for a very short time. If the tempo is less than 240, then the “Rest” block will have a longer pause.
Rest for 1 beat at tempo=240
Rest for 1 beat at tempo=80