## Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Teaching Programming in Primary Schools. Join the course to learn more.
2.8

## Raspberry Pi Foundation

Skip to 0 minutes and 3 seconds In this video, I’m going to show you how to use repetition to create a song that uses repeated patterns of notes. The song we’ll be making in this video is “Frere Jacques”. And before we start, I’m just going to make the scratch project look a little bit more exciting by adding a backdrop and a different sprite. So for the backdrop, I’m going to choose room one, and for the sprite I’m going to click Music and use the keyboard. And I’m just going to make that a little bit bigger.

Skip to 0 minutes and 40 seconds And then let’s delete the cat. There we go. So the scratch blocks we’ll be using to play music are in the extensions in the music section, and we’ll be using this play note block. If you click the Down Arrow to choose the note that you want to play, you’ll see that Scratch gives you the numerical value of the note as well as the letter name of the node. And when I click a note– [NOTE] –you see it plays the note for you so you can tell you’ve got the right one, and then it sets it for you. So when I click the piano sprite, it will play note 60, which is middle C.

Skip to 1 minute and 22 seconds [NOTE] And then for the first part of the song I need four notes. I need C. [NOTE] I need D. Then I need E. [NOTE] And then I need another C. [NOTE] And if I click the [INAUDIBLE]– [NOTES] –you’ll see that it plays each of these four notes, and it’s a little bit fast though. So I’ll change this value to 0.5 of a beat.

Skip to 2 minutes and 18 seconds Now the first part of the “Frere Jacques” song has this four notes repeated twice. So I’m going to use a repeat block, and I’m going to change the number of times that these notes are repeated so that it repeats twice. And then I can click the keyboard to test that again. [NOTES]

Skip to 2 minutes and 44 seconds So the second part of the song uses the notes E, F, and G. So I’m just going to drag them on now.

Skip to 2 minutes and 54 seconds So I have note B– [NOTE] –note [NOTE] –F– [NOTE] –and then note G. And, of course, these three notes also need to be repeated twice. So I’m going to put a repeat block around them.

Skip to 3 minutes and 15 seconds Now to test out the second bit of code, what I could do is I could add the second part of the song to the first part, and I could click the piano to play the entire song through. But I already know that this first part is correct because I’ve tested it. So instead, what I’m going to do is I’m going to drag this second part away from the first, and then I can just click on these blocks to test them on their own. [NOTES] And that doesn’t sound quite right to me.

Skip to 3 minutes and 46 seconds The third of these three notes should be held on for one beat so that it lasts twice as long as the other two, and the other two should also be 0.5. Let’s test it. [NOTES] Great. Now I know that this second bit of code works. I can then drag it and attach it to the first part. So now we’re creating the entire song.

Skip to 4 minutes and 22 seconds You’ll notice though that playing the entire song takes quite a long time, and it would take even longer the more of the song that we put together. So another block that’s useful to show you is the set tempo. So the tempo at the moment is 60 beats a minute. And actually we can click the tick box next to the tempo so that we can see it on the stage.

Skip to 4 minutes and 47 seconds And we can see that the tempo has been set to 60 beats a minute. So it will play each of these notes at half a beat with 60 beats in a whole minute. So if we want to test the entire song, we could actually change the tempo of the song to a hundred beats a minute so that it’s a bit quicker to test it.

Skip to 5 minutes and 11 seconds And now I know that’s right. I’m just going to put the tempo back to 60. And I don’t need to see this variable anymore either, so I’m going to untick that box.

Skip to 5 minutes and 25 seconds And now you’ve seen the first two parts of the song. Your challenge is to code the rest.

# Coding Frère Jacques

In this video you’ll learn how to use repetition to create the first half of the song Frère Jacques in Scratch.

You’ll then be able to use what you’ve learnt to make the rest of the song.