- Learnt28 min · mouth shapes, a dope sheet, the timer, sound effects
- Basic25 min · Pip sings the whole song
- Challenge 1–327 min · karaoke, an effects track, a performance
- Extrabonus · tap along, sing it back
Review — Cartoon Studio I 5 min
- Pip is five sprites. Only the Body moves, and it posts
body xandbody yevery frame. - Every other piece goes to the body plus its offset, every frame.
- An arm turns round its costume’s centre — its pin.
- A scene is beats:
broadcast and wait, one after another.
Quick-fire
Today the Mouth will switch costume thirty times in seven seconds. Which of Pip’s pieces has to change for that — and which ones do not care?
Reveal the answer
Only the Mouth. It still follows the body with its offset (0, 58); a costume change does not move it. That is why the mouth is its own piece: the face can talk without anything else being redrawn.
Today’s Topic 3 min
- Four mouth shapes, and which sounds each one makes
- A dope sheet: when each mouth shape starts, in two lists
- Timing by the
timer, not by adding up waits - A sound-effects library you call by name
Learning outcome
By the end of this lesson you will be able to:
- Read two lists in step, with one counter.
- Make something happen at a time measured from a start.
- Play a sound whose name is in a variable.
Learnt — a mouth that keeps time 28 min
1 · Four shapes
Your mouth makes dozens of shapes when you talk, but a cartoon needs only a few. Animators sort every sound into a handful of shapes. Pip has four.
| Costume | Sounds | In “Happy birthday to you” |
|---|---|---|
closed | M, B, P — and every rest | between the lines |
open | a, i as in “bird” | Hap-, birth- |
wide | ee, ay | -py, -day |
round | oo, o | to, you |
How to use this: Click the green flag to start it. Nothing else to press — the mouth shows each shape and says what it is for.
2 · The dope sheet
Animators plan a voice on a dope sheet: a list of moments, and the shape the mouth takes at each one. Ours is two lists that stay in step — row 3 of one goes with row 3 of the other, like the card lists in Level 3.
| Row | cue times | cue mouths | Sung |
|---|---|---|---|
| 1 | 0 | open | Hap- |
| 2 | 0.225 | wide | py |
| 3 | 0.4 | open | birth- |
| 4 | 0.675 | wide | day |
| 5 | 1 | round | to |
| 6 | 1.3 | round | you |
| 7 | 1.7 | closed | (rest) |
The times are real. They were measured from the Birthday sound itself: each one is the moment a note gets suddenly louder.
3 · The clock
The timer counts seconds since the project started. Write down its value when the song starts, in start. Then (timer) - (start) is how far into the song you are — always, however slow the computer is.
when flag clicked
set [start v] to (timer)
start sound [Birthday v]
set [cue v] to (1)
repeat (length of [cue times v])
wait until <((timer) - (start)) > (item (cue) of [cue times v])>
switch costume to (item (cue) of [cue mouths v])
change [cue v] by (1)
end
cue, reads both lists. Each turn waits for the next moment, then shows its shape.How to use this: Click the green flag to start it. Nothing else to press — listen, and watch the mouth and the two lists.
4 · Why not waits?
You could write wait (0.225) seconds, wait (0.175) seconds … one gap after another. Try it, and the mouth falls behind the song.
A wait can only finish on a frame, and a frame is a thirtieth of a second. So every wait finishes a little late, and the lateness adds up. The timer cannot add up — each cue is measured from the same start.
How to use this: Click the green flag to start it. Nothing else to press — two mouths sing the same 29 cues; read what each says at the end.
5 · A sound library
Cartoons need sound effects: a boing, a laugh, a ta-da. Keep them all on one sprite, the Speaker, and ask for one by name.
when I receive [sfx v]
start sound (sfx)
say (sfx) for (1) seconds
sfx variable onto the sound menu.
set [sfx v] to [Boing]
broadcast (sfx v)
broadcast (jump v) and wait
How to use this: Click the green flag to start it. Nothing else to press — listen, and read the Speaker.
Basic — Pip sings the whole song 25 min
Open last lesson’s Pip. The song has four lines and 29 cues.
Step 1 — the mouth and the song
- Give the Mouth four costumes, named
closed,open,wideandround: closed, open, wide, round. - On the Mouth’s Sounds tab, choose
Birthdayfrom the library.
Step 2 — the dope sheet
- Make two lists, For all sprites:
cue timesandcue mouths. Make the variablesstartandcue. - Save birthday-cue-times.txt and birthday-cue-mouths.txt.
- Right-click each list’s box on the Stage, choose import, and pick its file. Each list should now have 29 items.
Step 3 — sing
- Build the clock script from Learnt part 3 on the Mouth.
- Put
wait (0.5) secondsat the top, so the puppet is in place before the first note. - Click the green flag and watch the mouth — and listen.
How to use this: Click the green flag to start it. Nothing else to press — listen to the song and watch Pip’s mouth.
(Our demo also keeps a late variable: the biggest gap it saw between a cue’s time and the moment it ran. That is the number Pip says at the end.)
The mouth changes once, then stops.
change [cue v] by (1) is missing, or it is outside the repeat. Each turn must move on to the next row.
The mouth runs through every shape at once.
start is never set, so it is 0 — and (timer) - (0) is already bigger than every cue. Set start to the timer just before the song.
The shapes are right, but early or late all the way through.
The song and start are not side by side. Set start and start the sound in the same two blocks, with nothing between them.
Karaoke
Show the words, so the audience can sing along.
- A third list,
cue words, holds the word for each cue (birthday-cue-words.txt). - Pip says each word at the moment the mouth sings it.
- In the rests, Pip shows a ♪.
How to use this: Click the green flag to start it. Nothing else to press — read the words as Pip sings them.
Teacher reveal
One more block in the loop, under the costume switch:
say (item (cue) of [cue words v])
The same cue reads a third list. Three lists in step, one counter.
An effects track
Films have a sound-effects track running beside the voice. Give Pip one.
- Two more lists:
fx times(1.7, 3.6, 5.55, 7.4) andfx names(Hand Clap, Hand Clap, Hand Clap, Cheer). - The Speaker plays each effect at its time, on the song’s clock.
- Its own counter — not the Mouth’s.
How to use this: Click the green flag to start it. Nothing else to press — listen for the claps between the lines and the cheer at the end.
Teacher reveal
when flag clicked
wait until <(start) > (0)>
set [fx v] to (1)
repeat (length of [fx times v])
wait until <((timer) - (start)) > (item (fx) of [fx times v])>
start sound (item (fx) of [fx names v])
change [fx v] by (1)
end
On the Speaker. It does not need its own start — it reads the Mouth’s start, so the two tracks share one clock. (Set start to 0 on the green flag, so the wait really waits.)
A performance
A singer moves while singing. Make Pip conduct.
- The Front Arm swings on every sung note: one way, then the other.
- It does not swing on a rest.
- Meanwhile the head blinks now and then, on its own.
- A
swingsvariable counts the swings.
How to use this: Click the green flag to start it. Nothing else to press — watch the arm keep time and the eyes blink.
swings ends at 25.Teacher reveal
when flag clicked
set [swings v] to (0)
wait until <(start) > (0)>
set [beat v] to (1)
repeat (length of [cue times v])
wait until <((timer) - (start)) > (item (beat) of [cue times v])>
if <not <(item (beat) of [cue mouths v]) = [closed]>> then
if <(direction) = (120)> then
point in direction (150)
else
point in direction (120)
end
change [swings v] by (1)
end
change [beat v] by (1)
end
point in direction (165)
On the Front Arm, with beat For this sprite only. It reads the same dope sheet as the Mouth, with its own counter. A rest is the row whose mouth is closed. The blink is last lesson’s Challenge 1.
Tap along, sing it back
Typing 29 times is slow. Record the dope sheet by tapping instead.
- The song plays. Each press of the space bar adds “how far into the song” to a list.
- When the song ends, recording stops.
- Then Pip sings it back: the mouth opens at each tap, and closes 0.12 s later.
How to use this: Click the green flag, then click the stage once and press the space bar on every note. Our pretend pupil taps along too, so it works if you just watch.
Teacher reveal
when [space v] key pressed
if <(recording) = (1)> then
add ((round (((timer) - (start)) * (100))) / (100)) to [taps v]
end
when flag clicked
delete all of [taps v]
set [start v] to (timer)
start sound [Birthday v]
set [recording v] to (1)
wait (7.5) seconds
set [recording v] to (0)
wait (0.5) seconds
set [start v] to (timer)
set [cue v] to (1)
repeat (length of [taps v])
wait until <((timer) - (start)) > (item (cue) of [taps v])>
switch costume to [open v]
wait (0.12) seconds
switch costume to [closed v]
change [cue v] by (1)
end
Our demo’s pretend pupil is a Stage script that sends the same message as the space bar, about 0.05 s after each note — a person is never exactly on time.
Summary 5 min
- Four mouth shapes are enough to sing: closed, open, wide, round.
- A dope sheet is two lists in step: when, and which shape.
- Time things from one start with
(timer) - (start). Waits add up their lateness; the timer does not. - One Speaker sprite can play any sound you name in a variable.
- Lip sync
- Moving a mouth so it matches the sound you hear.
- Dope sheet
- An animator’s plan: what happens at each moment.
- Cue
- One row of that plan: a time and a thing to do.
- Drift
- Small lateness adding up until things are badly out of time.
Hand in
Save singing Pip. Next lesson the world gets bigger than the Stage, and you get a camera to look round it.