Scratch coding offers many ways to enhance your project, and one of them is by adding music! This article will show you how to create music in Scratch. There are many options for customized and pre-recorded sound. Don't forget to upload and show off your project here once you're done!
For live expert guidance making fun games and animations in Scratch while learning beginner-friendly coding concepts, join our award-winning free Scratch classes. Designed by professionals from Google, Stanford, and MIT, each class is held in a small group format and uses inquiry-based and project-based learning to ensure students discover the magic in technology and have fun.
Discover how to create music in Scratch
To add music and sounds to your Scratch project you have many options. One of the places to start is the “Sounds” panel in the upper left.
Scratch has hundreds of pre-recorded sounds you can add to your project. To do so, click the “add sound” symbol in the bottom left. Then you’ll see all the options available! You can scroll through them or search in categories like “Animals”, “Percussion” or “Wacky”.
To learn how to get even more creative in Scratch and add all sorts of unique features to your projects, join our award-winning live online Scratch classes (Scratch Ninja for Grades 2-5 and Accelerated Scratch for Grades 5-9), designed by experts from Google, Stanford, and MIT.
How to upload music to Scratch
Another option is to upload a sound or music file from your computer. Hover over the “add sound” symbol, and then click the “upload” option at the top of the choices that appear. Now you can select the file from your computer that you want.
If you would like to record a sound, you can do that as well! Hover over the “add sound” symbol, but this time select “record”, which is the third option from the top. Make sure to enable microphone access. Then click the button in the pop up screen and start recording.
Once your sound is in Scratch, you have many options for customization. You can change the speed and volume, or play around with effects like fade in/out.
How to create a music loop in Scratch
In your project, you may want to create a music loop. The first block you’ll need is “when green flag clicked” from the Events section. Next you’ll need a block to execute the loop from the Control section. If you want the sound to loop over the entire project, use the “forever” block. If you only want to loop a certain number of times, then use the “repeat” block and change the number to what you want it to be.
Finally, within your loop, you want to put a “play sound until done” Sound block. This makes sure the entire soundtrack finishes before looping again. If you want more sounds to select from the drop down, you can add more options in the “Sounds” panel as described earlier in this post. Your final loop looks like this.
Using the Instruments Extension in Scratch coding
Back on the “Code” tab, the “Music” extension is another way to add sound. The extension button is in the bottom left corner.
Now you have a whole new set of drag and drop blocks to use. You can select percussion instruments ranging from the snare drum to the cowbell. A different block lets you select instruments like piano or clarinet. Other blocks let you set the tempo or the duration of a note.
One way to get creative is the play notes block. The first note specifies the pitch of the block. The larger the number, the higher the note. You can also use the interactive piano that pops up to test out the different notes. The second number in this block lets you set how long to play the note.
Check out these cool Scratch projects that use music
Need a few ideas for inspiration? Explore some awesome Scratch projects that enhance their impact with music.
- Pumpkinoids uses laser sounds to complement the visuals. This project was made in Create & Learn's Scratch Ninja class.
- Egga's Time Traveling Adventure uses sounds to add suspense. This project was made in our Accelerated Scratch class.
- Macintosh 128K uses computer sounds as a special effect. This project was made in our Scratch Ninja class.
Now you know how to create music in Scratch
You can take a Scratch project you already have and add your own musical creations to it, or start a fresh project! Our Scratch classes and Scratch camps are a great way to learn how to build stories to accompany musical additions. Up next, find out how to make a jumping game in Scratch!
Written by Sophie Andrews, a Create & Learn instructor. Sophie Andrews is a student at Stanford University studying Math andComputational Sciences. She loves teaching and is a teaching assistant for Stanford's introductory computer science classes. Her work focuses on data science. Last year she built the online National Vote Trackers for The Cook Political Report, and she currently leads the Data Team at The Stanford Daily. She's also interned with the FCC and the National Renewable Energy Lab.