Composition in Scratch

Mar 17, 2021

Miles Berry

Scratch sprites can be given sounds to play according to instructions in their scripts. As with costumes, there are a number of pre-recorded sounds the programmer can use, including notes played on a number of instruments as well as untuned percussion. A sequence of these can be used to play a tune, and here pupils might take inspiration from a familiar song or compose their own melody.

the first two bars of Frere Jacque using pre-recorded samplese

Figure 1 - the first two bars of Frere Jacque using pre-recorded samples

Scratch also allows the programmer to record their own sounds, playing these back using similar scripted instructions. From a composition perspective, more possibilities are opened up through the Midi-based Music extension, where the audio played back is generated by the computer rather than through playing back pre-recorded sounds. The equivalent to the above program looks like this:

The first two bars of Frere Jacque using Midi notes

Figure 2 - The first two bars of Frere Jacque using Midi notes

Notice here that pitch, duration and tempo are parameters in these Scratch blocks, just like the distance and angles in the turtle graphics examples above. This means that the music can be generated by the computer - for example using the computer keyboard to create a piano simulator, or generating random music. It is also possible to have tuned instruments playing alongside percussion instruments in Scratch, as two (or more) scripts can be executed at the same time.

parallel Scratch scripts for the first two bars of Frere Jacques, accompanied by percussion

Figure 3 - parallel Scratch scripts for the first two bars of Frere Jacques, accompanied by percussion

The idea of parallelisation can be extended further, by having multiple sprites playing at the same time, perhaps using different instruments to harmonise with a lead sprite. Through Scratch’s support for remixing, one pupil might start a project by laying down a melody as code, another may then add a percussion accompaniment, with a third or fourth adding in further harmony or accompaniment, working collaboratively to create a multipart composition.