top of page

Music & Coding: Scratch Music

In this activity, students will use Scratch to create a band that plays a simple tune. They can use different virtual instruments and characters that move to the beat of the song they pick. The cool part is that both students and teachers can do this even if they don't know how to read music or code.

Cover image for blog post

Scratch can be used to explore music, games, simulations, and animations beyond this specific activity. It was made to be a drag-and-drop computer language, so learners don't have to deal with complicated syntax rules. This makes learning to code easier. One more benefit is that it works right in your browser, so you don't have to download any software.

When students use Scratch to generate music, they can see how writing code and music is similar.

Scratch was created in 2003 by a group of people at MIT. It was made for kids ages 8 to 16. Over time, it has grown into a tool that kids all over the world use to learn how to code. It supports more than 70 languages, so it doesn't matter what language they speak. This thriving community has made over 100 million projects together, creating a culture of sharing and remixing that lets users customize the program to their own artistic goals.

Why this activity?

When students use Scratch to generate music, they can see how writing code and music is similar. Coding is carried out step by step, just like music is played in a sequence. The way commands and notes are arranged is very important. If you put notes or commands in the wrong order, you might end up with a bad song or computer program. The activity also teaches students how to understand the beat of a song and how to blend the sounds of different instruments.


If your students are new to Scratch, I've provided an introductory video in the presentation slideshow. This should be enough for them to be able to code in Scratch. The slideshow also showcases finished sample projects. Showing these will help kids understand what they need to do for the activity. The presentation also has two training videos: one shows how to code music in Scratch, and the other shows how to add motion and more instruments. In the resources area, there is a document called "Simple Tunes to Code." This has songs that kids can use, along with a video of the song.

Scratch Sprite

Students start by using Scratch to code a song. To code music, you'll need to use the music extension, which is only available in the online version of Scratch. Click "Add Ons" in the bottom left corner of your screen to get to it. Drag a "play note" block to the editor from there. When you click on the number of the note, a piano keyboard pops up so you can choose the note. Add as many blocks of "play note" as your song needs. At the beginning, don't forget to set your instrument type with a "set instrument" block and start your tune with a "Flag" block.

Students can animate their characters, known as "sprites", in sync with the music's rhythm. They can either move the sprite or switch its costume after each note. If they decide to move the sprite, they need to think about where it will be when the song is over. For example, if a sprite moves 10 steps with each beat, it might be off-screen by the end of the song. To stop this from happening, students can change the direction of the sprite or move it in different ways. Another fun option is to enlarge, shrink, or change the sprite's color after every beat.

Example of orchestra project

Once a student has coded a sprite to move and play music, they can put together the rest of the band. To create a new band member, simply right-click on a sprite in the sprite zone and duplicate it along with its code. Next, just change the new sprite's instrument and outfit. For added flair, change how the new band member moves To complete the ensemble, add more band members and choose a fitting background.

With a Scratch account, it's easy for students to save and share their work. Their work is automatically saved, and from their "MyStuff" page, they can send you a link to their project. But if they don't have an account, they should save the project to their computer or Google Drive. Then, they can send you the file they made in Scratch, which you can upload to Scratch to see what they made.

It's easy to change the activity for older students or students who already know how to play music or code. You could have them code music directly from sheet music, figure out the notes for a tune on their own, or write their own music in Scratch. Students who know a lot about coding could let users choose what instruments or even the songs the band will play.



Recent Posts

See All
bottom of page