AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Predict the sound

Week 18 · Unit 8: Be a musician · 3 lessons
3

Volume and sound blocks

Computing 3: Unit 8, pp. 119–134
GoalUse the music blocks to set the volume, play a sound and start a melody.
New words
volume · how loud or quiet a sound ismelody · a short tunemillisecond · a thousandth of a second, so 1000 milliseconds is 1 second
Explanation

The Music group has blocks for sound. The “set volume” block sets how loud sounds are, from 0 to 255. 0 means silence and 255 is the loudest. The “play sound until done” block lets you choose a sound from a list, such as giggle, twinkle or yawn. The program waits until the sound ends. The “start melody” block lets you choose a tune from a list, and you decide whether it repeats once or forever. A volume block only changes the sounds that come after it, so it must come before the sound.

Music blocksset volume60play soundtwinkleuntil donestart melodybirthdayrepeatingoncestop all sounds
Worked examples
VolumeWhat you hear
0no sound at all
60quiet
127medium
255the loudest
The volume number goes from 0 to 255. Here is a rough guide.
Quiet soundon buttonApressedset volume30play soundspringuntil doneToo lateon buttonApressedplay soundspringuntil doneset volume30
The order of blocks matters. In the first program the volume is set to 30 before the sound, so the sound is quiet. In the second program the sound plays first at the old volume. Then the volume is set, but it is too late for that sound.
PauseSeconds
500 mshalf a second
1000 ms1 second
2000 ms2 seconds
5000 ms5 seconds
The pause block counts in milliseconds. Pausing for 1000 milliseconds is the same as 1 second. Here is how some pauses are written.
Class activity

Volume dial (with a friend): draw a half-circle dial with 0 on the left and 255 on the right, and 127 in the middle. A friend points to a number and you hum on one note at that loudness: silent for 0, a whisper for 60, normal for 127 and strong (never shouting) for 255. Then the friend predicts which number you used. Which numbers were hard to tell apart? Why do we use numbers and not words like “loud”?

Practice
1
What does the block “set volume (0)” do to the sounds after it?
set volume0
2
Which program plays the sound at volume 200? Why?
Aon buttonApressedplay soundgiggleuntil doneset volume200Bon buttonApressedset volume200play soundgiggleuntil done
3
How many milliseconds are 3 seconds?
4
A melody is set to repeat forever. What happens when you press the button?
on buttonApressedstart melodychaserepeatingforever