After completing this activity, students should feel relatively comfortable:
Understand how loops can be used to write cleaner and more modular code
Recognize that code can be rewritten in different equivalent ways
Review and reinforce the knowledge gained over the last couple of weeks (i.e. playNote, beat values, bars, variables, using different instruments in TunePad)
Warm-Up (~5-10 min)
Ask about their day, transition to the warm-up discussion outlined below
Main content - Loops and Hat Patterns activity (~30min)
From first cell, all the way to Puzzle Instructions cell
Activity - Loops and Hat Patterns activity (~15min)
From Puzzle Instructions to the end
If students seem to comprehend the material in the drills, instead of working on the Puzzle problems, you can have them practice creating their own hi-hat pattern
Share (~5-10 min)
Students should use loops to add a new hi-hat pattern to the beat they made in Ableton
N.B. there’s some flex/buffer time to allow for introducing activities, login, and/or potential slowdowns. Take these timings as recommendations and use your own judgement
Try to ground discussions in whatever is relatable for the students in your group. A few ideas are provided below but feel free to come up with your own variations on the same theme.
Strongly recommended: Greet them with enthusiasm and ask about their day.
Ask them about the music they listen to. See if they can pick out any specific elements of the music that they like. Ask them to think about how they might code that in TunePad.
Since this lesson deals with repetition in code, ask them if they notice elements that repeat in their favorite song.
NOTE: Don’t spend too much time on “icebreaker” activities after you talk to them about their day unless the icebreaker directly ties to the activity. Not only are these usually super contrived and shallow, but they also take away from the very limited time we have to genuinely build rapport and help students learn.
Instruction 0: Login to TunePad (~2 min)
Make sure everyone gets logged into their accounts and troubleshoot as needed. If a student is having login issues, you might just wanna share your screen for the duration of the session and do the activity yourself for them to follow along or choose to do it entirely as one big group.
Instruction 1: Send TunePad Project and Preview Lesson (~2 min)
Send the students the link to the activity and give them a brief overview of what it is. Have them remix the project. Share your screen and take a look at the Basic Drum Beat and Preview cells. Tell students they will be learning how to create hi-hat patterns like the one in the Preview drum beat.
Instruction 2: Begin Reading Learning Content (~10 min)
Have students read through the Loops text cell and then complete Drill 1. In Drill 1, they should write a for-loop that plays the kick variable (which is defined for them) a total of four times for one beat each. They can do this in two lines of code:
for i in range(4):
playNote(kick)
Instruction 3: Read Hats Cell and Complete Drill 2 (~10 min)
Have students read through the Hats content. Try to resolve any syntax questions they may have. They will then convert text describing a hi-hat beat into code. This should take approximately nine lines of code:
for i in range(4):
playNote(hat, 0.25)
for i in range(4):
playNote(hat, 0.125)
for i in range(8):
playNote(hat, 0.25)
for i in range(5):
playNote(hat, 0.05)
playNote(hat, 0.25)
Instruction 3: Introduce puzzle instructions section (~5 min)
Once the students have worked through the beats values activity and have gotten the hang of how to write for-loops, tell them to move on to the puzzles further down in the TunePad project. Give them an overview by mentioning that they’ll have to use the playNote function in conjunction with the loops they learned about earlier in the TunePad project to rewrite code. You can demonstrate by walking through the Example cell.
Instruction 4: Begin puzzle instructions section (~10 min)
There will only be three puzzles to work through so you might want to do this as a group. It's okay if you don't complete all three puzzles, but try to get through the first two! Otherwise, let students work and chime in every few minutes to ask if anyone got the first puzzle, then the second. See Activity Solutions section for solutions.
*optional* Instruction 4: Writing hi-hat patterns (~10 min)
Alternatively, if students have gotten the hang of using for-loops, you can skip this activity and instead have them complete the creative activity: using loops to add a new hi-hat pattern to the beat they made in Ableton.
Instruction 5: Sharing & Challenge Activity (~5-10 min)
Start off by asking if anybody wants to share any TunePad project. If nobody responds, then you can share a cool project of your own or one from the cool projects doc. If you use something from the doc, make sure you fully understand it. After you take a few minutes to go over a cool project, introduce the creative activity for this week: using loops to add a new hi-hat pattern to the beat they made in Ableton. If your group worked on this instead of the puzzles, you can have them continue adding to their pattern.
1) Rewrite in 2 lines of code:
for i in range(4):
playNote(4, beats=0.25)
2) Rewrite in 4 lines of code:
for i in range(4):
playNote(1, beats=0.5)
playNote(1, beats=0.5)
playNote(2, beats=1.0)
3) Rewrite in 8 lines of code:
for i in range(4):
playNote(4, beats=0.75)
playNote(4, beats=0.25)
playNote(4, beats=0.5)
playNote(4, beats=0.75)
playNote(4, beats=0.25)
playNote(4, beats=0.5)
playNote(4, beats=1.0)
Troubleshooting
Issue: “name ___ is not defined on line ___”
Check: Check that the spelling of the argument to playNote is correct
Check: Check that any definitions or variables that are used in that line are spelled correctly and defined as needed in the code cell that should be at the top of the file
Issue: “Unable to import ___”
Check: That they renamed their code cell at the top to “beats” and used from beats import * at the beginning of their drum cells
Issue: “bad input on line __”
Check: if line is last line of cell, playNote is likely missing closing parenthesis
Check: otherwise, arguments to playNote could be missing comma in between
Issue: “Error on line ___”
Check: They have copied the code exactly and they aren’t leaving any spaces/tabs between or before words in a function, misspelling words, writing in lowercase where they should be writing uppercase or vice versa. Check that code is on its own line (e.g. playNote is used once per line). Nothing like “playNote(0) playNote(0)” in one line
Issue: Clicking play on the cell but no sound
Check: Make sure the number entered inside “playNote” is a valid number (i.e. it corresponds to one of the TunePad drum sounds)
Solution: Refresh the page and try again.
Issue: Logging into TunePad account problems
Check: Have them share screen and confirm that they are typing in the correct username and password
Workaround: If enough people can’t log in, have a coach share their screen and do the activity as a group on that person’s computer. Use the chat to vote on what genre and which patterns to use