Advanced Scratch: Custom Blocks and Extensions (Make your own music!)

Custom Blocks in Scratch are an example of a function or method. They’re basically shortcuts: bits of code that you can use over and over again by calling the block, rather than reproducing it each time. This is very important as we get into more complex programs!

Music in Scratch

Music is an extra feature in Scratch. It’s hidden at first to give users a chance to learn the basics. To access Music (and other advanced features), look for the Add Extension button at the bottom left and select Music.

Some options, like selecting an instrument, are fairly straightforward. The “play note” command seems kind of tricky, but it’s really not! Drag it into your program and click in the space that says 60 and you’ll see a keyboard with Middle C selected. Any note can be selected by number or by key.

Each note is played for 0.25 beats, which corresponds to a quarter note in 4/4 time. If you don’t know the music theory, don’t worry — just know that 0.5 is twice as long as 0.25, 1 is twice as long as 0.5, etc. All of these notes together make up the first two lines of “Twinkle Twinkle Little Star” — now you know why we might want a shortcut!

We have our notes, now when do they play? Just like in gym class, they play when they’re called. If you look on the right, we see a command that says “When this sprite is clicked, Twinkle”. This tells Scratch when to run our custom block.

Leave a Reply