The students of the Khan Academy programming community love making games, animations and mini-movies, and they've been clamoring for a particular new feature for the last year: sound. Their wait is over! Last week, we released a way for programs to play sound effects.
The code is as simple as this, purposefully similar to image()
:
playSound(getSound("rpg/metal-clink"));
The current sound effects in the picker are from an RPG pack:
We also have more sound effects coming soon, like a retro pack made by one of our top community members.
We've updated the program guidelines to specify that sounds should only be in response to user interaction, so that sounds don't become an annoyance. We'll hold a contest soon to challenge students to use the sound to enhance their programs in the most impressive ways. We hope that sound effects inspire even more creativity in our community!