Lab 2: Sliding Pitches
In Lab 1 you played three steady notes. Steady notes sound like a microwave oven finishing. In this lab you will make notes that slide while they play, and you will hear a plain beep turn into something that sounds alive.
Welcome back, engineers!
Here's the secret to robot personality: it isn't the notes, it's the
sliding between them. Let's make a beep sound curious, then make the
very same beep sound disappointed.
What You Need
- Your finished circuit from Lab 1
- The Pico connected to your computer with a USB cable
- Thonny, connected to the Pico
What You'll Learn
- What a glide is and why it carries feeling
- How rising and falling pitches read as different emotions
- How to write a glide in one line of code
- How a real R2-D2 sound was measured and turned into numbers
Step-by-Step
Step 1: Run the Glide Program
In Thonny, open 02-pitch-glide.py and press Run. Listen
carefully. You will hear three things: a sound that rises, a sound that
falls, and a longer sound that sags.
Step 2: Look at the Rising Glide
Find this line in the file:
1 | |
This slides the pitch smoothly from 400 Hz up to 1200 Hz over 300 milliseconds. Rising pitches sound curious, excited, or questioning — the same way your voice rises at the end of a question.
Step 3: Look at the Falling Glide
1 | |
The exact same two frequencies, in the opposite order. This one sounds disappointed or tired. Nothing changed except the direction.
Same two notes, opposite feelings
Hmm, think about this for a second. Both glides use 400 Hz and
1200 Hz. Only the order changed, and suddenly one asks a question
and the other gives up. Direction carries meaning all by itself!
Step 4: Play the Measured Sad Sound
The last part of the file plays something different. These three lines came from measuring a real recorded R2-D2 sound:
1 2 3 | |
Run it and listen. It starts near 462 Hz, lifts slightly, then sags down to 388 Hz while fading away. The five numbers per line are starting pitch, ending pitch, duration, starting volume, and ending volume.
Nobody guessed those numbers. A program listened to the real recording many times per second and wrote down what it heard.
Step 5: Break the Sadness on Purpose
Change the middle line so the pitch rises instead of sags:
1 | |
Run it. The sound is no longer sad. Same length, same volume fade, same starting note — but the feeling is gone. Change it back when you are done listening.
Try It Yourself
- Make a very fast rising glide:
r2d2.glide(300, 3000, 80). Short and steep sounds surprised. - Make a very slow falling glide:
r2d2.glide(900, 300, 1500). Long and gentle sounds sleepy. - Stack two glides back to back to make a wobble:
r2d2.glide(600, 700, 60)thenr2d2.glide(700, 600, 60). Repeat that pair six times in a loop and you have a warble. - Try a glide that barely moves, like
r2d2.glide(500, 510, 400). Can you hear the difference from a steady note?
What's Happening Under the Hood
The Pico cannot actually slide a pitch. It can only pick one frequency at
a time. So glide() cheats in a way your ears cannot catch: it changes
the frequency a tiny bit every 4 milliseconds.
Over a 300 millisecond glide that is 75 tiny steps. Each step is far too small and far too fast for an ear to pick out, so the staircase sounds like a smooth ramp. Movies use the same trick — still pictures shown fast enough look like motion.
Check Your Understanding
- What are the three numbers in
r2d2.glide(400, 1200, 300)? - Which direction of glide sounds like a question?
- How often does the Pico change the frequency during a glide?
- Where did the numbers in the sad sound come from?
Full Code
You can find the complete program at
src/kits/synth-sounds/02-pitch-glide.py.
You made a robot feel something!
You just discovered that emotion in sound is mostly direction — and
you proved it by breaking a sad sound on purpose. That's how sound
designers think!