- Learnt28 min · two lists in step, one loop
- Basic24 min · a verse and a chorus
- Challenge 1–327 min · backwards, a key change, a round
- Extrabonus · a recorder
Review — notes and instruments 5 min
- Every key has a number. 60 is middle C.
- Each sprite has its own instrument. The tempo is shared.
- Our
singblock plays a note and shows its letter.
Quick-fire
Last week the Studio Theme was 16 blocks. You want to change the sixth note. How do you find it?
Reveal the answer
You count down the script, block by block — and a rest is a block too. Today the sixth note is simply item 6 of a list.
Today’s Topic 3 min
- Two lists kept in step:
notesandbeats - One loop, with
iwalking down both lists - A 0 in the notes list means a rest
- Changing the tempo between a verse and a chorus
Learning outcome
By the end of this lesson you will be able to:
- Store a song as two lists that line up row by row.
- Play any song in those lists with one loop.
- Change a song by changing the lists, not the script.
Learnt — a song in two lists 28 min
1 · Two lists, in step
A note needs two things: which key, and how long. So we keep two lists. Row 1 of notes goes with row 1 of beats, row 2 with row 2, all the way down. That is what in step means.
| Row | notes | beats | What you hear |
|---|---|---|---|
| 1 | 60 | 0.5 | C, short |
| 2 | 64 | 0.5 | E, short |
| 8 | 0 | 0.5 | a rest |
| 15 | 60 | 1 | C, long |
A 0 in notes means “rest here”. Nobody plays key 0 in a song.
2 · Fill the lists
- Make two lists,
notesandbeats, for all sprites. Their boxes appear on the Stage. - Click the + at the bottom of the notes box. Type 60 and press Enter.
- Keep typing. Enter makes the next row.
- Do the same in the beats box, so both lists have the same number of rows.
3 · One loop plays it all
A variable called i says which row we are on. It starts at 1, and goes up by one after every note.
set [i v] to (1)
repeat (length of [notes v])
if <(item (i) of [notes v]) = (0)> then
hide
rest for (item (i) of [beats v]) beats
else
sing (item (i) of [notes v]) (item (i) of [beats v]) :: custom
end
change [i v] by (1)
end
if catches the rests; everything else is sung.How to use this: Click the green flag. Nothing else to press — watch the i box count down the rows as the letter plays them.
4 · A new song is new lists
Change the numbers in the boxes and run it again. The script did not change at all, but you hear a different tune.
How to use this: Click the green flag. Nothing else to press — the same loop plays a different tune on the vibraphone.
Basic — a verse and a chorus 24 min
Songs often play the same part twice — slowly first, then faster. You are going to play the Studio Theme as a slow verse and a fast chorus.
Step 1 — the lists
- Use your letter sprite and sing block from last lesson.
- Make
notesandbeats. Fill them with the Studio Theme: the table from Lesson 10, with 0 for the rest. - Check both boxes say length 15.
Step 2 — a play song block
- Make a Block called
play song. - Put the loop from the Learnt under its define hat.
Step 3 — verse, then chorus
- Make a variable
bpm. Under the green flag, set it to 90 and set the tempo to it. say [Verse] for (1) seconds, thenplay song :: custom.- Set bpm to 140 and the tempo to it.
show,say [Chorus!] for (1) seconds, then play song again.
define play song
set [i v] to (1)
repeat (length of [notes v])
if <(item (i) of [notes v]) = (0)> then
hide
rest for (item (i) of [beats v]) beats
else
sing (item (i) of [notes v]) (item (i) of [beats v]) :: custom
end
change [i v] by (1)
end
when flag clicked
set instrument to [(1) Piano v]
set [bpm v] to (90)
set tempo to (bpm)
say [Verse] for (1) seconds
play song :: custom
set [bpm v] to (140)
set tempo to (bpm)
show
say [Chorus!] for (1) seconds
play song :: custom
How to use this: Click the green flag. Nothing else to press — the verse plays at 90, then the chorus at 140.
The chorus plays nothing.
i is still 16 from the verse. Check set [i v] to (1) is inside the play song block, not under the green flag.
The chorus is no faster than the verse.
Changing bpm does not change the music by itself. Put set tempo to (bpm) straight after you set bpm to 140.
Some notes are far too long.
The beats list is out of step — a row was missed or typed twice. Compare the two boxes row by row.
Backwards
Play the song from the last note to the first.
- Do not change the lists.
istarts at the length of the list and goes down by one.
How to use this: Click the green flag. Nothing else to press — watch the i box count down from 15.
Teacher reveal
set [i v] to (length of [notes v])
repeat (length of [notes v])
if <(item (i) of [notes v]) = (0)> then
hide
rest for (item (i) of [beats v]) beats
else
sing (item (i) of [notes v]) (item (i) of [beats v]) :: custom
end
change [i v] by (-1)
end
Two numbers change: where i starts, and the −1.
A key change
Pop songs often finish higher than they started. Make yours do it.
- The song plays once as it is.
- Then it plays again with every note 5 keys higher.
- A shift box on the Stage shows 0, then 5.
How to use this: Click the green flag. Nothing else to press — listen for the jump up, and watch the letters change.
Teacher reveal
Use the shift sing block from Lesson 10’s Challenge 1. The script sets shift to 0, plays the song, sets it to 5, and plays the song again. The lists are never touched — the shift is added as each note is played.
A round
In a round, a second singer starts the same song a little later. Two singers, one pair of lists.
- Duplicate the letter sprite. Call it
Note 2and give it a colour effect and the Flute. - Both sprites play the same lists, starting on one broadcast.
- Note 2 says “wait...” and starts 2 beats later.
- Neither singer skips a note.
How to use this: Click the green flag. Nothing else to press — watch the second letter follow the first, 2 beats behind.
Teacher reveal
The trap is i. If it is “for all sprites”, both singers add 1 to the same box, and each plays only every other note. Make i for this sprite only — delete it and make it again with that choice — and each singer keeps its own place.
when I receive [go v]
set [color v] effect to (100)
set instrument to [(12) Flute v]
say [wait...]
rest for (2) beats
say []
play song :: custom
A recorder
Join last week’s keyboard to this week’s lists. Whatever you play is saved, so you can play it back.
- The green flag empties both lists.
- A to K play C to C, and add the note and 0.5 to the lists.
- The space bar plays the recording back with the play song block.
- C empties the lists so you can start again.
How to use this: Click the green flag, then click the stage once and press A, S, D, F, G, H, J or K to record notes. Press the space bar to play them back, or C to clear.
Teacher reveal
when flag clicked
delete all of [notes v]
delete all of [beats v]
set tempo to (120)
say [Press A to K to record. Space plays it back.]
when [a v] key pressed
say []
add (60) to [notes v]
add (0.5) to [beats v]
sing (60) (0.5) :: custom
when [space v] key pressed
say []
play song :: custom
Eight key scripts like the A one. Recording every note as half a beat keeps it simple; a pupil who wants real lengths can try the timer.
Summary 5 min
- A song can live in two lists kept in step: notes and beats.
- One loop with
iwalks down both and plays every row. - A 0 in notes is a rest.
- A new song is new lists. The script stays the same.
- Two sprites reading the same lists each need their own i.
- In step
- Two lists where row 1 goes with row 1, row 2 with row 2, and so on.
- Verse and chorus
- Two parts of a song. Here they are the same notes at two tempos.
- Key change
- Playing the whole song a few keys higher or lower.
- Round
- The same song sung by two voices, one starting later.
Hand in
Save your song. Next lesson the lists become a grid of pads you click — a beat machine, and the end of the arc.