Introduction:

In this project you will use samples to create a drum loop, including an intro and outro.

Click the play button below to hear how your drum loop will sound:

Step 1: The intro

Let’s start by creating a short intro to the drum loop.

Activity Checklist

  • Start by adding the :drum_tom_hi_hard sample. If you start typing, you should be able to choose the sample from the list that appears.

    screenshot
    screenshot
  • Here’s how your code should look:

    screenshot
    screenshot

    The line above the sample starting with # is a comment. These lines are ignored by Sonic Pi, but are useful for when we want to remind ourselves what our code does!

  • Press run, and you should hear your drum sample.

    screenshot
    screenshot
  • Add 2 more drum samples, so that they go from high to low. You’ll also need to sleep for 1 beat between each sample.

    screenshot
    screenshot
  • If you run your intro again, you’ll hear that it’s quite slow. You can add code to change the beats per minute (bpm – the speed) of the music.

    screenshot
    screenshot
  • Finally, add a sleep and a :drum_splash_hard sample at the end of the intro.

    screenshot
    screenshot
  • Test your intro again. You should now hear 3 drums, followed by a cymbal.

Save your project

Step 2: The drum loop

Now that you have an intro, let’s code the main drum loop!

Activity Checklist

  • The drum loop will be made up of 4 samples, alternating the bass (the lower drum sound) and snare (the higher drum sound).

    Add this code after your intro:

    screenshot
    screenshot
  • Test your drum loop. You should hear 4 drum beats after your intro.

  • You can repeat your drum loop by adding 4.times do before your drums and end at the end.

    screenshot
    screenshot
  • Play your drums again, and you’ll notice that they don’t quite sound right. That’s because you need to add a sleep after the final drum in the loop.

    screenshot
    screenshot
  • Test your code again. This time you should hear your 4 drum beats repeat 4 times.

  • To make your drum loop a little more interesting, you can play the second bass drum twice, for just 0.5 beats each.

    screenshot
    screenshot
  • Test your code again. You should hear a different rhythm.

Save your project

Step 3: The outro

Let’s add an ending to the drum loop.

Activity Checklist

  • Add the :drum_cymbal_open sample at the end of your code, outside of the loop.

    screenshot
    screenshot
  • Press run to test your code. It doesn’t sound very interesting, so let’s also add a :drum_snare_hard sample.

    screenshot
    screenshot
  • Test your code. Notice that there’s no sleep between the 2 outro samples, so they’ll play at the same time.

Save your project

Challenge: Create your own drum loop

Can you use what you’ve learnt to create your own drum loop? Here are some ideas to help you:

  • You could change the drum samples used in your intro or outro. To see what samples are available, you can go to jumpto.cc/sonic-pi-samples, or just type sample :drum and choose from the list that appears.

    screenshot
    screenshot
  • You could experiment by adding more drums to your drum loop, that play for a shorter time:

    screenshot
    screenshot
  • You could also play around with the sleeps between drums. Here are some examples you can try:

    screenshot
    screenshot

Save your project