Students learn to incorporate audio into their projects to make them more interactive and fun.
Imagine playing your favorite video game, but the volume is at zero. No 'level up' chimes, no 'game over' music, and no 'jump' sounds. It feels empty, doesn't it?
To add sound to your project, you first need to explore the Sound Library. In most block-based coding tools, there is a special Sound Tab at the top of the screen. When you click the 'Choose a Sound' button (usually shaped like a speaker), you can search for hundreds of noises, from animal sounds to space lasers! Once you pick a sound, it gets added to your project's 'backpack' so you can use it in your code blocks. Remember, every Sprite (your character) can have its own unique list of sounds.
1. Click on your Cat Sprite. 2. Go to the Sounds Tab and click 'Choose a Sound'. 3. Search for 'Meow' and click it. 4. Go back to the Code Tab. 5. Drag out a 'When Green Flag Clicked' block. 6. Snap a 'Play Sound Meow Until Done' block underneath it.
Quick Check
Where do you go to find new sounds like 'Laser' or 'Boing'?
Answer
The Sound Library (found inside the Sound Tab).
There are two main ways to play a sound: Start Sound and Play Sound Until Done. These sound similar, but they act differently! The 'Start Sound' block is like a quick tap; the sound starts playing, and the computer immediately moves to the next block of code. The 'Play Sound Until Done' block is like a pause button; the computer waits for the entire sound to finish before it moves to the next step. This is very important when you want a sound to match a movement, like a 'Boing' sound happening exactly when a ball hits the floor.
Let's make a sprite jump and make a sound at the same time: 1. Drag a 'When Space Key Pressed' block. 2. Snap a 'Start Sound Jump' block underneath. 3. Snap a 'Change Y by ' block under the sound. 4. Snap a 'Wait seconds' block. 5. Snap a 'Change Y by ' block to bring the sprite back down.
Quick Check
If you want a sprite to move while a sound is playing, which block should you use?
Answer
The 'Start Sound' block.
Short sounds are great for actions, but what about Background Music? To keep music playing throughout your whole game, you need a Loop. By placing a sound block inside a Forever Loop, the music will restart as soon as it ends. It is best to use 'Play Sound Until Done' inside a loop. If you used 'Start Sound' in a loop, the computer would try to start the song times every second, creating a very loud and glitchy noise!
1. Choose a long music track like 'Video Game Land' from the library. 2. Drag a 'When Green Flag Clicked' block. 3. Snap a 'Forever' loop block underneath. 4. Inside the loop, place the 'Play Sound Video Game Land Until Done' block. 5. Now, your music will play in a perfect circle: .
Which block should you use for background music inside a loop?
What happens if you put 'Start Sound' inside a 'Forever' loop?
True or False: You can only have one sound in your entire project.
Review Tomorrow
Tomorrow, try to remember the difference between the 'Start Sound' block and the 'Play Sound Until Done' block.
Practice Activity
Try creating a 'Soundboard' project: make five different sprites that each play a different funny sound when you click on them!