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

Build a band program

Week 15 · Unit 6: Be a musician · 3 lessons
1

From tune to algorithm

Computing 4: Unit 6, pp. 74–89
GoalWrite a tune as a list of notes and beats, find the part that repeats and turn it into an algorithm.
New words
pitch · how high or low a note soundsbeat · a unit of time in music: at tempo 60 one beat lasts one secondrest · a pause in the musictempo · how fast the beats go
Explanation

To code a tune, first write it as a list of notes and beats. Then look for parts that repeat. Write each repeated part only once and add a repeat step. A rest is a pause, and Scratch has a “rest for” block. The notes C, D, E, F, G, A and B have the numbers shown below. At tempo 60, one beat takes one second, so half a beat takes half a second. When you write “repeat steps 2 to 4 one more time”, check the step numbers carefully. They must match the steps that you want to play again.

NoteCDEFGAB
Number60626465676971
Worked examples
PartNotes and beats
Part 1E 0.5, E 0.5, G 1
Part 2E 0.5, E 0.5, G 1
Part 3A 1, G 2
The kite tune has three parts. Part 1 and Part 2 are exactly the same, so we can repeat them. The numbers after the notes are beats.
StepInstruction
1Start program when the green flag is clicked
2Play note 64 (E) for 0.5 beats
3Play note 64 (E) for 0.5 beats
4Play note 67 (G) for 1 beat
5Repeat steps 2 to 4 one more time
6Play note 69 (A) for 1 beat
7Play note 67 (G) for 2 beats
8Stop program
The algorithm for the kite tune writes Part 1 once. Steps 2 to 4 are repeated one more time. The program plays E, E, G, E, E, G, A, G. The whole tune lasts (0.5 + 0.5 + 1) × 2 + 1 + 2 = 7 beats.
whenclickedplay note64for0.5beatsplay note64for0.5beatsplay note67for1beatsrepeat2play note69for1beatsplay note67for2beats
The same algorithm as a Scratch program. The repeat (2) block plays Part 1 two times in all.
Class activity

Rhythm writer (with family): make a rhythm with claps (1 beat), table taps (half a beat) and rests (1 beat). For example: clap, tap, tap, rest, clap, tap, tap, rest, tap, tap. Write the rhythm down, one action on each line. Find the part that repeats. Write an algorithm that uses a repeat step. Ask someone to perform your rhythm using only your algorithm. Did they play it as you planned?

Practice
1
The wave tune plays C for 1 beat, E for 1 beat, G for 0.5 beats and G for 0.5 beats. It plays this 3 times. Complete steps 4 to 6 of the algorithm and say how long the tune takes.
StepInstruction
1Start program when the green flag is clicked
2Play note 60 (C) for 1 beat
3Play note 64 (E) for 1 beat
4?
5?
6?
7Stop program
2
How many beats does the kite tune have in all? How many seconds does it take at tempo 60?
3
Write the Scratch block that plays the note F for 2 beats.
4
This program should play C, D and E. Which block is wrong and what should it say?
whenclickedplay note60for1beatsplay note62for1beatsplay note67for1beats