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

Term 2 review

Week 21 · Review: Term 2 · 3 lessons
2

Loops and music

Computing 4: Units 5–8, pp. 62–122
GoalTrace a Scratch music program with a repeat block, a volume change and a repeat until block.
New words
repeat · a block that runs the blocks inside it a fixed number of timesrepeat until · a block that checks a condition at the start of every round and stops when it is truevolume · how loud a sound is, from 0 to 100beat · the unit of time in music: at tempo 60 one beat lasts one second
Explanation

A loop saves blocks. The repeat block runs its blocks a number of times. The repeat until block checks its condition at the start of each round. If the condition is false, it does one more round. If it is true, it stops. So a round that has begun always finishes. Volume goes from 0 to 100. The block set volume sets it, and change volume by adds to it. The volume can never go above 100. When we trace music, we write each note and its volume in a table. At tempo 60, one beat is one second.

when this sprite clickedset volume to50%play note62for1beatschange volume by25repeat3
Worked examples
RoundVolume of the noteVolume after the change
15075
275100
3100100 (125 is too high)
The frog pond tune. The volume is set first. Each round plays one note and then raises the volume by 25. Volume cannot go over 100.
when this sprite clickedplay note55for1beatsrest for1beatsrepeat untilkeyqpressed?
A tune that stops when a key is pressed. The player presses and holds the q key 3 seconds after the start. Each round takes 2 seconds. Round 1 is from 0 s to 2 s. Round 2 starts at 2 s, and the check at 4 s sees the key and stops. The note is played in 2 rounds.
Without a loopwhenclickedplay note60for1beatsplay note60for1beatsplay note60for1beatsplay note60for1beatsWith a loopwhenclickedplay note60for1beatsrepeat4
A repeat block can replace many copies. These two scripts play the same music, but the second needs fewer blocks.
Class activity

Body music (with family): a person claps once for each beat while another says the volume of the clap as a number, starting at 40 and adding 20 each time. Stop at 100: the loudest clap can only stay at 100. Then play a game of repeat until: keep clapping a 2-beat pattern, clap and rest, until someone taps the table. The pattern in progress must always be finished first. How many patterns did you clap?

Practice
1
A script uses set volume to 20 and then repeat 4: play a note, change volume by 30. Write the volume of each note.
set volume to20%play note60for1beatschange volume by30repeat4
2
How many beats does this script play, and how many seconds does it last at tempo 60?
whenclickedplay note64for1beatsrest for1beatsrepeat3
3
A repeat until block waits for the key m. The key is pressed in the middle of round 3 and held down. How many rounds are played?
4
Change the script in question 1 so that it plays 6 notes with the same volume change. What must change? What are the volumes now?