Lesson 2: Sonic soundtracks

Using their programming skills, pupils create a piece of music based upon a given theme, including the use of loops. Thanks to the Dubai English Speaking School for our header image!

Before the lesson

Watch

  • Teacher video: Sonic soundtracks

Teacher video: Sonic soundtracks

Also, watch music skills videos: Pitch; Pulse and Rhythm; Tempo; Dynamics

 

Have ready

  • Presentation: Sonic soundtracks – IMAGES COMING SOON!!!
  • Charged laptops
  • Link: Install ‘Sonic Pi (free)’
  • Headphones (strongly recommended)
  • Headphone splitters, if sharing laptops

 

Print

  • Resource: Sonic Pi basic commands (see Classroom resources) – one per pair

Download classroom resources

Resource: Sonic Pi basic commands
icon download

Learning objective

  • To create a program that plays themed music

National curriculum

  • Design, write and debug programs that accomplish specific goals
  • Select, use and combine a variety of software (including internet services) on a range of digital devices to design and create a range of programs

Success criteria

  • I can use Sonic Pi’s basic commands
  • I can include a loop in my program
  • I can debug simple errors in my code

Cross-curricular links

Music

Pupils to be taught to:

  • Improvise and compose music for a range of purposes using the inter-related dimensions of music

Attention grabber

Display slide 2 of Presentation: Sonic soundtracks to discuss the Learning objective and Success criteria

Presentation: Sonic soundtracks

Show on your interactive whiteboard

The topic used in this lesson is ‘Space’. Ideally, you would choose a topic that you are currently studying as a class.

Slide 3: write the word ‘Space’ (or your chosen topic) on the board and ask the children – what do they think about when they hear that word? Create a mindmap of all of their ideas.

Slide 4: show the Example mindmap resource for reference, if children are struggling with ideas.

Slide 5: explain that today the children will be programming a piece of space-themed music.

Slide 6: think about the ideas you’ve got on the mindmap, what do they sound like? Do ‘aliens’ sound like little creatures scurrying along on tippy toes and creeping up behind you, or do ‘UFOs’ sound electronic and like they’re firing lasers? What music do you think would play as an astronaut walked on the moon for the first time? Would it be slow or fast?

Slide 7: encourage children to choose one of two areas of the mindmap that they’re most interested in and discuss with their partner what these would ‘sound like’.

Slide 8, 9 and 10: linking to their Music learning (see teacher videos), display and discuss the following musical features:

  • PITCH – High notes or low notes and how to transition from one to the other – really quick or a gradual climb?
  • RHYTHM – What’s the pattern of the music? Where does it repeat? We tend to like music that is predictable, so choose which bits repeat.
  • TEMPO – Will the music be fast or slow? (Denoted by the use of ‘sleep’ commands in Sonic Pi) Will it maintain that tempo or will it change part way through?
  • TIMBRE – The type of sound: if it’s a soft sound or a harsh sound, etc. We will explore how to do this in Sonic Pi today using different synths.

These ideas will help the children to plan a purposeful program/piece of music.

 

Key questions

  • What do you think about when you hear the word ‘space’?
  • What’s a mindmap?
  • Think about the ideas you’ve got on the mindmap, what do they sound like? 
  • Do ‘aliens’ sound like little creatures scurrying along on tippy toes and creeping up behind you?
  • Do ‘UFOs’ sound electronic and like they’re firing lasers? 
  • What music do you think would play as an astronaut walked on the moon for the first time?
  • Would it be slow or fast?
  • What do these musical features mean to you?

Main event

Slide 11: explain that there’s no real ‘right’ or ‘wrong’ to this lesson, as long as they can explain what they’ve done and why.

Debugging

Slide 12 and 13: ask children what they think the word ‘debugging ‘ means. As you model the code throughout the next section, keep ‘accidentally’ making mistakes, like the bugs we previously identified in Lesson 1:

  • typing a word wrong like ‘seelp’ or ‘pley’
  • missing the space between the word and the number
  • not including a number

When the code doesn’t work, get the children to identify why to reinforce their debugging skills.

Slide 14: draw attention to the error window below the code and explain how to identify when there is an error by both reading the error message and looking for a little pink arrow within the code itself.

Slide 15: usually, the error message will identify the line where there is an issue, although occasionally it will let you know that there is something missing by throwing up an error in a line that doesn’t exist (e.g. if you’re missing the word ‘end’ on a loop).

Slide 16: can the children remind you what you have to include to make Sonic Pi play music? They should suggest something like:

play 70

Slide 17: can they explain what you have to do to play two notes separately?

play 70

sleep 1

play 80

Loops

Slide 18: now, mention the second point on the Success Criteria: Can they remember the code to create a loop? It doesn’t matter if they cannot, even experienced programmers look up syntax, as long as they know what a loop does!

Slide 19: type this code and run it:

2.times do

play 70

sleep 1

play 80

sleep 0.5

Slide 20: it won’t work. There is a new bug to consider this week. Can the children spot it?

Slide 21: the ‘end’ is missing from the loop. Explain to children that ‘do’ and ‘end’ are friends – they always have to be together. This becomes even more important as their projects grow because they have more than one loop and are likely to miss one. There should always be the same amount of ‘do’s and ‘end’s. Just like capital letters and full stops.

Slide 22: the correct code should be:

2.times do

play 70

sleep 1

play 80

sleep 0.5

end

Slide 23: there are two new commands the children could add into their program: ‘use_synth’ and ‘play_chord’.

Slide 24: keep the code that you just had and add this line beforehand:

use_synth :tb303

2.times do

play 70

sleep 1

play 80

sleep 0.5

end

Can the children identify what has changed?

Slide 25: the timbre has changed – the type of sound we are using. Model to the children typing ‘use_synth’ and then a space to see the list of possible synths drop down.

Slide 26: make sure the children understand that synths must be selected from the list of pre-existing sounds and that even though the names sounds odd, they’ve been created as part of Sonic Pi. Each one of these provides its own different sound so they will need to spend some time exploring them.

Slide 27: you can also change synth halfway through a piece, e.g.

use_synth :tb303

play 70

sleep 1

play 80

sleep 0.5

use_synth :hollow

play 80

sleep 1

Some children may be unfamiliar with how to type an underscore on a laptop keyboard (it’s different than on a tablet). Model holding ‘shift’ and pressing the ‘subtract’ key.

Slide 28: finally, show them that they can play ‘chords’ if they want to. Chords are usually three or more notes played at the same time. The code for this is:

play_chord [60, 62, 64]

Slide 29: the children can change the numbered notes within the chord to be whatever they want them to be. They now have all the tools they need to create their themed music/program.

Slide 30: you may want to display or give out print outs of the Sonic Pi basic commands resource to support your pupils as they experiment.

 

Key questions

  • What does the word ‘coding’ mean to you?
  • What does the word ‘debugging’ mean to you?
  • Can you remember what you have to include to make Sonic Pi play music?
  • Can you remember what you have to do to play two notes separately?
  • What is a ‘loop’?
  • Can you remember the code to create a loop?
  • Can you spot the error?
  • Can you identify what has changed?

Differentiation

Pupils needing extra support: Use the Sonic Pi basic command sheet provided to help support spelling and syntax

 

Pupils working at greater depth: Can explain how they can use Sonic Pi to change the pitch, tempo, rhythm and timbre of the music.

  • pitch = higher/lower play notes
  • tempo = controlling the pauses with sleep
  • rhythm = using loops appropriately
  • timbre = using the synths

Wrapping up

Slide 31: every lesson should end with some time for children to share what they’ve been working on. Firstly, get the children to swap with the person next to them. Partner A plays their work for Partner B. After listening to it, partner A must explain which part of space they were focusing on and why they made the music sound this way. Partner B then does the same in return. Focusing on the purpose of the program is important as that’s the focus of the Learning objective.

Ask partners to nominate the person whose music they listened to if they think it meets the Learning objective. Who explained very clearly how their music linked to the theme? Share some with the whole class and discuss together.

Assessing pupils' progress and understanding

Pupils with secure understanding indicated by: Explaining how their program linked to the theme. Including a loop in their work. Correcting their own simple mistakes.

 

Pupils working at greater depth indicated by: Making links between changing the style of the music and different coding structures, e.g. “I wanted to create slow music so I included longer ‘sleeps’ between the played notes”.

Vocabulary

  • Program

  • Music

  • Sonic Pi

  • Commands

  • Loop

  • Debug

  • Errors

  • Code

  • Mindmap

  • Pitch

  • Rhythm

  • Tempo

  • Timbre

Created by:
Sway Grantham,  
Computing specialist
Sway Grantham (@SwayGrantham) is a Primary School Teacher, a CAS Master Teacher and Specialist Leader in Education for Primary ICT. She also has a BCS Certificate in Computer Science Teaching (Primary). She has written several curricula and conducted research into the…
Find out more
Download
save content as pdf file
save content as word file