- Learnt28 min · notes, instruments, a sing block
- Basic24 min · the Studio Theme
- Challenge 1–327 min · higher, two hands, a keyboard
- Extrabonus · the whole band
Review — drums and the beat 5 min
- Music blocks count in beats, not seconds.
- The tempo decides how long one beat is.
rest for (1) beatsis a beat of silence.
Quick-fire
The tempo is 120. A drum plays 4 times, each for 0.5 beats. How many seconds does that take?
Reveal the answer
1 second. Four halves make 2 beats, and at tempo 120 each beat is half a second.
Today’s Topic 3 min
play note (60) for (0.5) beats— notes have numbersset instrument to [(1) Piano v]- A
singMy Block that plays a note and shows it - Rests inside a tune
Learning outcome
By the end of this lesson you will be able to:
- Find a note’s number and play it for a number of beats.
- Change the instrument a sprite plays.
- Play a whole tune, with a rest in it, from one My Block.
Learnt — notes and instruments 28 min
1 · Play a note
- Open Music and drag out
play note (60) for (0.25) beats. - Click the white circle with 60 in it. A little piano pops up.
- Click a key. The number changes to that key’s number.
- Click the block to hear the note.
Every key has a number. 60 is middle C. Each key to the right is one more. These are the white keys we use:
| Letter | C | D | E | F | G | A | B | C |
|---|---|---|---|---|---|---|---|---|
| Number | 60 | 62 | 64 | 65 | 67 | 69 | 71 | 72 |
Add 12 and you get the same letter, one octave higher. 72 is a high C.
2 · How long is a note?
play note (60) for (1) beats
play note (60) for (0.5) beats
The block waits until the note ends. So notes stacked under each other play one after another, like the drums did.
3 · Choose an instrument
set instrument to [(1) Piano v] changes the sound of every note the sprite plays after it. There are 21 to try.
| Number | Instrument |
|---|---|
| 1 | Piano |
| 4 | Guitar |
| 6 | Bass |
| 12 | Flute |
| 16 | Vibraphone |
| 18 | Steel Drum |
How to use this: Click the green flag. Nothing else to press — four notes, four times, on four instruments.
4 · A block that sings — and shows the note
Typing 60, 64 and 67 is easy. Seeing them is better. We make a My Block called sing. It plays a note and shows its letter at a height that matches it.
- Add one sprite with the letters
CDEFGABas its costumes. The Glow letters in the sprite library are perfect. - Make a list called
letters. Put in 12 items, one per key from C up:C C D D E F F G G A A B. A black key shows the letter below it. - Make a Block called
singwith two number inputs:noteandbeats. - Build the definition below.
define sing (note) (beats)
switch costume to (item (((note) mod (12)) + (1)) of [letters v])
set y to ((((note) - (60)) * (6)) - (20))
show
play note (note) for (beats) beats
((note) mod (12)) finds the key inside its octave, from 0 to 11. Each key up lifts the letter 6 steps.How to use this: Click the green flag. Nothing else to press — the letter climbs the scale and comes back down.
5 · A rest in a tune
Music needs gaps. For a rest, hide the letter and use rest for (0.5) beats. The next sing shows it again.
Basic — the Studio Theme 24 min
You are going to play a short tune written for this course. It is 8 beats long and has one rest.
Step 1 — the singer
- Make the letter sprite, the letters list and the sing block from the Learnt.
- Test it: one call to
sing (67) (1) :: customshould show a G.
Step 2 — set up the music
when flag clickedset tempo to (120)set instrument to [(1) Piano v]
Step 3 — the tune
Add one sing for each note in this table, in order. Every note is 0.5 beats except the last.
| Bar | Notes |
|---|---|
| 1 | C 60 · E 64 · G 67 · E 64 |
| 2 | F 65 · A 69 · G 67 · rest |
| 3 | E 64 · G 67 · C 72 · G 67 |
| 4 | F 65 · D 62 · C 60 for 1 beat |
Step 4 — the rest, and the ending
- Where the table says rest:
hide, thenrest for (0.5) beats. - At the end:
say [Studio Theme!] for (2) seconds.
when flag clicked
set tempo to (120)
set instrument to [(1) Piano v]
sing (60) (0.5) :: custom
sing (64) (0.5) :: custom
sing (67) (0.5) :: custom
sing (64) (0.5) :: custom
sing (65) (0.5) :: custom
sing (69) (0.5) :: custom
sing (67) (0.5) :: custom
hide
rest for (0.5) beats
sing (64) (0.5) :: custom
sing (67) (0.5) :: custom
sing (72) (0.5) :: custom
sing (67) (0.5) :: custom
sing (65) (0.5) :: custom
sing (62) (0.5) :: custom
sing (60) (1) :: custom
say [Studio Theme!] for (2) seconds
How to use this: Click the green flag. Nothing else to press — follow the letter as it plays the tune.
The letter is always C.
Check the list has exactly 12 items in the right order, and that the costume names are single capital letters: C, not Glow-C.
The letter never moves up or down.
The set y to (0) line is using a number instead of the sum. Drag the note input out of the define hat into the sum.
The letter vanishes after the rest and never comes back.
show is missing from the sing block. Only the sing block brings the letter back.
An octave higher
Play the tune twice. The second time, every note is 12 keys higher.
- Make a variable called
shift. - Change only the sing block, so it plays
note + shift. - The tune is the same both times. You do not type a second tune.
How to use this: Click the green flag. Nothing else to press — the tune plays, then plays again higher up.
Teacher reveal
define sing (note) (beats)
switch costume to (item ((((note) + (shift)) mod (12)) + (1)) of [letters v])
set y to (((((note) + (shift)) - (60)) * (6)) - (20))
show
play note ((note) + (shift)) for (beats) beats
The script sets shift to 0, plays the tune, sets it to 12, plays it again. Adding 12 keeps every letter the same, because of the mod 12.
Two hands
A piano player uses two hands. Give the tune a bass line.
- Duplicate the letter sprite and call it
Bass. It uses instrument 6, Bass. - It plays: C 48 for 2 beats, F 53 for 2, C 48 for 2, G 43 for 1, C 48 for 1.
- The Stage sets the tempo, then broadcasts
go. Both sprites start ongo. - Both parts end together.
How to use this: Click the green flag. Nothing else to press — watch the low letter move slowly while the tune moves fast.
Teacher reveal
when I receive [go v]
set [color v] effect to (120)
set instrument to [(6) Bass v]
sing (48) (2) :: custom
sing (53) (2) :: custom
sing (48) (2) :: custom
sing (43) (1) :: custom
sing (48) (1) :: custom
The bass adds up to 8 beats, the same as the tune — that is why they end together. The colour effect just makes the two letters easy to tell apart.
A keyboard on your keyboard
Turn the computer keys into piano keys.
- The keys
A S D F G H J Kplay C D E F G A B C — 60 up to 72. - Each key plays its note for half a beat and shows its letter.
- When the flag is clicked, the letter tells the player which keys to press.
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 play a note.
Teacher reveal
when [a v] key pressed
say []
sing (60) (0.5) :: custom
when [s v] key pressed
say []
sing (62) (0.5) :: custom
Eight scripts like these, one per key. Pupils can play the Studio Theme from the table by ear — a good test that their numbers are right.
The whole band
Bring back last week’s drums and dancer, and play the tune over the beat.
- The Stage sets bpm to 120 and broadcasts go.
- The tune plays twice. The kick and snare play under it for 16 beats.
- The Ballerina steps on every beat.
- Everything stops together.
How to use this: Click the green flag. Nothing else to press — the tune plays twice over the beat while the Ballerina dances.
Teacher reveal
when flag clicked
set [bpm v] to (120)
set tempo to (bpm)
broadcast [go v]
when I receive [go v]
repeat (8)
rest for (1) beats
switch costume to [drum-snare-b v]
play drum [(1) Snare Drum v] for (0.25) beats
switch costume to [drum-snare-a v]
rest for (0.75) beats
end
The Stage, then the Snare. The Kick loops 8 times through a hit and a rest, sending beat twice per loop for the dancer, as in Lesson 9. The tune is the Basic stack under when I receive [go v], played twice.
Summary 5 min
- Every key has a number. 60 is middle C; each key up is one more.
- Add 12 for the same letter an octave higher.
play note (60) for (0.5) beatswaits until the note ends.- Each sprite has its own instrument. All sprites share the tempo.
- A sing My Block plays the note and shows it, so you can see the tune.
- Note number
- The number of a piano key. 60 is middle C.
- Octave
- Twelve keys. The same letter, higher or lower.
- Instrument
- The sound a sprite uses to play its notes.
- Melody
- The tune — the notes you could hum.
- Bass line
- Low, slow notes played under the melody.
Hand in
Save your tune. Next lesson the notes move out of the script and into two lists — and one loop plays any song you put in them.