/curriculum/activities/livecode-house/
Learn how to code and customize a Chicago-style House beat.

Lesson Plan

Code a Chicago House Beat

Learn how to code and customize a Chicago-style House beat.

Level

Beginner

Time

45 minutes
Try It

In this activity we're going to learn how to code a Chicago-style House beat. House music originated in Chicago's underground club culture and has since become a worldwide phenomenon. House is characterized by a thumping four-on-the-floor beat pattern and high energy tempos in the 120 to 130 beats per minute range. Take a minute to listen to this example track, and try to pick out all of the different drum sounds.

Here's what the basic House patteren looks like. Notice that there's a kick drum placed at the start of every beat (four-on-the-floor). There are also snare drums at the start of beats 2 and 4.

Now that we have an idea of what a House beat sounds like, let's code it in Python.

Step 1: Log In to TunePad

  • Go to tunepad.com
  • Click on Sign In
  • Click on Sign in with Google
  • Enter your Gmail address and password

Step 2: Create a new TunePad Project

Click on the New Project button to create an empty project. It should look like the picture below.

Screenshot of an empty TunePad project

Step 3: Kick Drums

  • Click on the Add Cell button in your new project.
  • Click on the Drum button to add a new drum cell.
  • Change the name of the cell to Kicks.
  • Set the instrument to Drums → Headlines Drums and add this code.
  • Press the Play button to hear how it sounds.
/# Kick drum (play note 0 four times in a row) playNote(0) playNote(0) playNote(0) playNote(0)

Note that the first line of code above starts with a hashtag symbol (#). In Python programming, anything that comes after a hashtag is called a comment. Comments are notes for human programmers that are ignored by Python. Line 1 is there to help remind us which lines of code play the kick drum part.

Step 4: Snare Drums

  • Click on the Add Cell button again to add a second Drum cell.
  • Call this cell Snares
  • For the snare drum part, we want to add hits to beats 2 and 4 while skipping beats 1 and 3.
  • The easiest way to do this is to use the rest function.
  • Try playing both the Kick and Snare cells together at the same time.
/# Snare drum (note 2) rest(1) # skip beat 1 playNote(2) rest(1) # skip beat 3 playNote(2)

Step 5: Hi-Hats

  • In House music, hi-hat sounds get sprinkled between the kicks and snares to add energy and originality.
  • Here's a very simple pattern that you can customize.
  • In the next activity we'll learn how to use loops in Python to make more interesting hi-hat patterns.
/# Hi-hats (note 5) rest(0.5) # rest for a half a beat playNote(5) # play a hi-hat sound playNote(5) playNote(5) playNote(5, beats = 0.5) # play the last hi-hat for only half a beat

Try playing all three cells together at the same time to hear how they sound.

Step 6: Turbo Kicks

Here's a slightly more complicated version of the kick drum cell that uses a Python loop to repeat each drum sound four times in a row. It also plays a softer echo of each kick, which can add variety and energy to your beat.

for i in range(4): playNote(0, beats = 0.5) # play the kick drum for half a beat playNote(0, beats = 0.5, velocity = 60) # play it again more softly

Tips for Live Coding

  • Practice makes perfect. Practice typing out lines of code so that you can do it fluidly, confidently, and accurately.
  • Make use of Copy+Paste for repeated lines of code (you can also use a loop, which we'll show in the next beat activity).
  • Write some starter code ahead of time. That way you don't have to code everything from scratch.
  • Add or remove a hashtag at the beginning of lines of code to add or remove elements from live music.