Making music with Scratch - Festive Edition
In this introduction to programming, students will learn how to create music in Scratch.
Suggested time: 50 mins
Learning Objectives:
- Understand and use sequence in an algorithm
- Understand and use iteration in an algorithm (FOR and WHILE loops)
Curriculum Mapping:
KS2:
- Design, write and debug programs that accomplish specific goals; solve problems by breaking them into smaller parts. Select, use and combine a variety of software on a range of digital devices to design and create a range of programs.
- Use sequence, selection and repetition in programs; work with variables and various forms of input and output
- Use logical reasoning to explain how some simple algorithms work; detect and correct errors in algorithms and programs
KS3:
- Use two or more programming languages, at least one of which is textual, to solve a variety of computational problems.
- Make appropriate use of data structures [for example, lists, tables or arrays]; design and develop modular programs that use procedures or functions
What you will need:
- Web enabled device (PC, Tablet, Phone) with an up-to-date browser (Internet Explorer, Safari, Chrome)
- Scratch 2.0 (Web or offline version)
- Speaker or headphones
Making music with Scratch:
The built-in music library in Scratch allows you to play music on your device through internal / external speakers or headphones.
To play a note we use the following command:
The built-in music library in Scratch allows you to play music on your device through internal / external speakers or headphones.
To play a note we use the following command:
Where 60 is the note (Middle C) and 0.5 is the duration.
Example
Try the following example:
Example
Try the following example:
Did you recognise the tune
Music too slow?
By default, the tempo in Scratch is set to 60.bpm The most common tempo used in music is 120 bpm. To change the tempo, add the following block to the beginning of your code:
By default, the tempo in Scratch is set to 60.bpm The most common tempo used in music is 120 bpm. To change the tempo, add the following block to the beginning of your code:
Transcribing songs from sheet music
If we want to re-create our favourite songs on our micro:bit, we first need a basic understanding of sheet music.
Here’s a reminder of the most common notes used in a musical score:
The Treble Clef
If we want to re-create our favourite songs on our micro:bit, we first need a basic understanding of sheet music.
Here’s a reminder of the most common notes used in a musical score:
The Treble Clef
Below is the score for a very popular piece of music - Can you can guess what it is?
Answer: Grande Valse (You may know it as the ‘Nokia Ringtone’)
Did you notice the special # symbols at the start of the score. This shows that some of the notes are sharps. In this case, the sharp notes are:
F#, C#, and G#
In Make Code, sharp notes are selected by clicking on the ‘black notes’ in the drop-down keyboard:
Did you notice the special # symbols at the start of the score. This shows that some of the notes are sharps. In this case, the sharp notes are:
F#, C#, and G#
In Make Code, sharp notes are selected by clicking on the ‘black notes’ in the drop-down keyboard:
Below is the music score for the Nokia Ringtone (this time with notes underneath).
It’s all about the timing
If we look at the notes in a music score again, you will notice that they’re different shapes and colours. These different shapes and colours denote the timings. (See below)
Notice that some of the notes have a dot (or full stop) after them. For these notes, we need to multiply the duration by 1.5.
Below is the score again however, this time, with timings (duration).
Rests
Rests are natural pauses or breaks in a piece of music. Rests can be added to your code using the following command:
Rests are identified by the following symbols:
Challenge
- Program your micro:bit to play the Nokia ringtone.
- Use a loop to repeat the ringtone 4 times (or forever if you want to be really annoying!)
- Modify your code so that the ringtone only plays when you press the ‘A’ button
Resources
Sheet music:
Licence:
Unless otherwise specified, everything in this repository is covered by the following licence:
BBC micro:bit "Magic 8-Ball" lesson is licenced under a Creative Commons Attribution 4.0 International License.