This project is featured in chapter 3 of Coding and the Arts. In it, students use the music blocks in Scratch to sequence out simple melodies. Depending on the song used, this can also be a great place to practice iteration as students find repeating segments of a song and then use loops to recreate those patterns in code.
Starter Project
The following starter project shows the first two measures of Twinkle Twinkle Little Star. You can either have students continue to build out that song from this start, or just use it as a demonstration of how the music blocks work.
See inside
Exemplar Project
This exemplar goes above and beyond, but I couldn’t turn down the chance for an infinite round. The code attached to the “When I start as a clone” block uses loops to repeat the various sections of Frère Jacques, and that’s really all that’s necessary to hit the goals of this activity. The added fun comes in when, after the first looping section, we start a new clone, and therefore a new round of the song. Notice the use of the “pick random” block inside the “set instrument to” block - you can replace the dropdowns in many blocks with a variable or number block!
See inside
You may notice some lag or delays as the song plays, particularly once there are 3 or 4 instruments going at once. Programming environments that are purpose-built for music put a lot of energy towards ensuring perfect timing, which is why you may want to move on from Scratch if you want to get really into music programming in your class.