Learning Goals 3 min
By the end of this lesson you will be able to:
- Use set tempo to (60) and change tempo by (20) to control how fast beats play, in BPM (beats per minute).
- Read the current tempo with the (tempo) reporter and drop it into a say () block for debugging.
- Use rest for (0.25) beats to add silence between notes, and explain why a melody without rests sounds like mush.
Warm-Up — the same melody, twice 7 min
Here are two scripts. They have the exact same notes in the exact same order. Only one block is different.
when flag clicked
set tempo to (60)
play note (60) for (1) beats
play note (64) for (1) beats
play note (67) for (1) beats
when flag clicked
set tempo to (180)
play note (60) for (1) beats
play note (64) for (1) beats
play note (67) for (1) beats
Predict — which one finishes first, and how much faster?
Reveal the answer
Script A takes 3 seconds (3 beats × 1 second per beat at 60 BPM). Script B takes 1 second — exactly three times faster, because 180 BPM is three times 60 BPM. Same notes, same beat values, same lengths-on-paper. Tempo is the only thing that changed, and it changed everything you hear.
Reveal: what does "BPM" actually mean?
Beats Per Minute. At 60 BPM, you get 60 beats every minute — exactly one per second. At 120 BPM (a typical pop song), you get two beats per second. At 180 BPM (drum-and-bass, dikir barat speed) you get three beats per second.
Today is about tempo (how fast the beats fly) and rests (the silences between them). Without these two ideas, your Music scripts can only ever sound like "notes happening". With them, they start to sound like music.
New Concept — speed and silence 15 min
You met "beats" last lesson. A beat is a unit of musical time. But how long a beat is depends on the tempo. Today's blocks let you set, change, and read the tempo — and add the missing ingredient that turns notes into music: silence.
set tempo to ()
Find this in the magenta Music palette:
set tempo to (60)
Useful tempo values to keep in your head:
- 60 BPM — slow, lullaby pace. One beat per second. Easiest for counting.
- 90 BPM — a slow ballad. Hip-hop low end.
- 120 BPM — most pop songs. Twice as fast as 60, so a 0.5-beat block now lasts a quarter-second.
- 140 BPM — upbeat dance music.
- 180 BPM — drum-and-bass, fast K-pop choruses.
change tempo by ()
If set tempo to () is "make tempo equal to X", then change tempo by () is "add X to the current tempo". You can give it a negative number to slow down:
when flag clicked
set tempo to (60)
repeat (10)
play note (60) for (0.5) beats
change tempo by (20)
end
The (tempo) reporter
The little checkbox next to (tempo) shows tempo on the Stage. The block itself is a round reporter — drop it into any value slot:
when flag clicked
set tempo to (120)
say (tempo) for (2) seconds
rest for () beats — the missing block
Here's a common rookie melody:
when flag clicked
play note (60) for (0.5) beats
play note (62) for (0.5) beats
play note (64) for (0.5) beats
play note (65) for (0.5) beats
The piano voice in Scratch holds each note for the full beat length. With no gap between them, the second note starts the exact instant the first one ends — and your ear hears them as a connected blob. The fix is rests:
when flag clicked
play note (60) for (0.4) beats
rest for (0.1) beats
play note (62) for (0.4) beats
rest for (0.1) beats
play note (64) for (0.4) beats
rest for (0.1) beats
play note (65) for (0.4) beats
A rest is just silence with a duration. The block does nothing audible — it just makes Scratch wait the right number of beats before the next sound starts. Rests are also the only way to put space inside a drum loop:
when flag clicked
play drum (2 v) for (0.25) beats
rest for (0.5) beats
play drum (1 v) for (0.25) beats
Worked Example — the same tune, slow and fast 12 min
We'll build one short melody and play it twice — once slow, once fast — so you can hear what tempo does to the same notes. Seven steps.
Step 1 — Start fresh with Music loaded
New project. Add the Music extension if it's not already there.
Step 2 — Drop the hat and set the slow tempo
From Events: when ⚑ clicked. From Music: set tempo to (60). Snap underneath.
Step 3 — Play the melody once
Add the C-D-E-G phrase with tiny rests between each note. (Numbers from last lesson's table.)
Step 4 — Add a "spacer" rest
From Music: rest for (1) beats. This gives a one-beat (one-second-at-60-BPM) pause between the slow and fast versions, so you can hear the difference clearly.
Step 5 — Switch to fast tempo
From Music: set tempo to (180). Snap on. Tempo is now triple-speed.
Step 6 — Play the same melody again
Copy the four note + three rest blocks (right-click → duplicate the stack). Drop the duplicate at the bottom.
Step 7 — Click the flag
You hear C-D-E-G slowly, then a one-second pause, then the exact same notes three times faster. Same melody. Tempo is the only thing different.
The full assembled stack
when flag clicked
set tempo to (60)
play note (60) for (0.4) beats
rest for (0.1) beats
play note (62) for (0.4) beats
rest for (0.1) beats
play note (64) for (0.4) beats
rest for (0.1) beats
play note (67) for (0.8) beats
rest for (1) beats
set tempo to (180)
play note (60) for (0.4) beats
rest for (0.1) beats
play note (62) for (0.4) beats
rest for (0.1) beats
play note (64) for (0.4) beats
rest for (0.1) beats
play note (67) for (0.8) beats
What you just heard: tempo is the single most powerful "make it feel different" knob in music. A lullaby played at 180 BPM becomes a chase scene. A drum-and-bass groove at 60 BPM becomes a funeral march.
Try It Yourself — three speed-and-silence drills 15 min
Goal: Show the current tempo on the Stage. Tick the checkbox next to (tempo). Then write a script that sets tempo to 120 when the flag is clicked, and sets it to 60 when the space key is pressed.
when flag clicked
set tempo to (120)
when [space v] key pressed
set tempo to (60)
Think: Watch the tempo display flip from 120 to 60 the instant you tap space. The reporter on the Stage updates immediately because tempo is a project-wide value that all sprites share.
Goal: Build a melody that accelerates. Set tempo to 60, then play 8 notes (any from the scale). After each note, use change tempo by (15) so the next note is faster. End at tempo 60 + 7×15 = 165 BPM.
when flag clicked
set tempo to (60)
repeat (8)
play note (60) for (0.5) beats
rest for (0.1) beats
change tempo by (15)
end
Think: Eight notes, but each one shorter than the last because the tempo keeps rising. The first note takes about 0.6 seconds; the last takes about 0.22 seconds. Same beat value, very different real time.
Goal: Build a 2-bar drum pattern with deliberate silences. Kick on beat 1, rest for half a beat, snare on beat 2, rest for half a beat, kick on beat 3, snare on beat 4. Loop 4 times at 100 BPM.
when flag clicked
set tempo to (100)
repeat (4)
play drum (2 v) for (0.5) beats
rest for (0.5) beats
play drum (1 v) for (0.5) beats
rest for (0.5) beats
play drum (2 v) for (0.5) beats
play drum (1 v) for (0.5) beats
end
Think: The rests in the first half of the bar make the second half feel busier — even though the second half has the same drum hits as before. Silence reshapes what comes next.
Mini-Challenge — Imran's runaway tempo 5 min
"Why does it keep getting faster forever?"
Imran wanted a melody that starts slow and speeds up once per loop, then settles. He writes:
when flag clicked
forever
set tempo to (60)
play note (60) for (0.5) beats
play note (64) for (0.5) beats
change tempo by (40)
play note (67) for (0.5) beats
play note (72) for (0.5) beats
end
Click the flag mentally. Why doesn't the melody get faster over time, like Imran expected?
Reveal one valid fix
Look at the first block inside the forever: set tempo to (60). Every time the loop comes round, Imran resets tempo to 60 — wiping out the change tempo by (40) from the previous iteration. So tempo briefly jumps to 100 mid-loop, then snaps back to 60 the moment the next loop starts.
The fix is to move the set tempo to (60) above the forever, so it only runs once:
when flag clicked
set tempo to (60)
forever
play note (60) for (0.5) beats
play note (64) for (0.5) beats
change tempo by (40)
play note (67) for (0.5) beats
play note (72) for (0.5) beats
end
Same nine blocks. One moved outside the loop. Now tempo starts at 60, climbs by 40 every loop, and after about 5 loops the melody is unplayably fast — exactly what Imran wanted (well, until it gets silly). Setup blocks belong outside the loop. Change blocks belong inside it.
Recap 3 min
You met three blocks that shape musical time. set tempo to () sets the project's BPM — 60 means one beat per second, 120 means two. change tempo by () adds to the current tempo (negative slows down). (tempo) reports the current value for debugging or display. And rest for () beats adds silence — the block that turns "notes happening" into "notes you can hear separately". Setup blocks go above the loop; change blocks go inside.
- Tempo
- How fast beats play, measured in BPM (beats per minute). 60 BPM = one beat per second; 120 BPM = two beats per second. Default in Scratch is 60.
- BPM
- Beats Per Minute. The unit tempo uses. 60 BPM is slow; 120 BPM is pop-song speed; 180 BPM is fast.
- Rest
- A measured silence. The rest for () beats block makes Scratch wait the given beat-length before the next sound plays — no note, no drum, just air.
- Beat (revisited)
- The unit of musical time used by every Music block. Its length in real seconds depends on tempo: 1 beat = (60 ÷ BPM) seconds.
- Setup vs change
- A pattern: setup blocks like set tempo to () run once at the top of a script. Change blocks like change tempo by () run inside loops to evolve a value over time.
Homework 2 min
The Speed Lab. Take the melody you made for last lesson's homework — your Malaysian song phrase — and add tempo + rest control to make it feel like real music.
- Open your
HW-L4-13-My-Song.sb3project (or rebuild the phrase if you didn't save it). - Add a set tempo to () at the top. Pick a BPM that matches the song's natural feel — a lullaby like Burung Kakak Tua sits around 80; a march like Negaraku sits around 100.
- Add a small rest for (0.1) beats between every pair of notes. Listen — the phrase should now sound like spoken music instead of a slide.
- Bonus: at the end of the phrase, add rest for (1) beats then play the whole thing again at a tempo 20 BPM faster using change tempo by (20).
Save as HW-L4-14-Speed-Lab.sb3.
Bring back next class:
- The
.sb3file. - Your answer to: "What tempo did you pick, and why does it fit the song?"
Heads up for next class: SCR-L04-15 ties everything together. You'll compose an 8-bar original theme song with melody + percussion + tempo + rests, and refactor the melody into a reusable My Block.