Skip to Content

Reuse Musical Patterns with Code!

Why do more work when you can do less?

Check out how you can reuse musical patterns to add interest and organization to your music while saving time!

Think About

  • What types of patterns do you hear in the music you like to listen to?
  • Can you hear patterns that repeat throughout music you like?
  • How can we repeat patterns with code?

Get Started

  1. Choose whether you would like to work with Scratch or Sonic Pi
  2. Follow the directions for using Scratch or Sonic Pi to reuse musical patterns below

Reuse Musical Patterns with Scratch

  1. Take a look at the following project in Scratch
    1. Look at the blocks for each part of the song. Each part is called a phrase. 
    2. You can drag one block to play the entire musical phrase rather than having to type it many times
    3. Read the comments in the code to see how the code works
    4. You can also watch this video that explains how the code works:

Now:

  1. Experiment with the blocks
  2. Create something different

Not sure what a block does?

  1. When you are looking at the Scratch project, click on the question mark on the top of the screen
  2. Then click on a block for an explanation of what the block does

scratchblockhelp

Reuse Musical Patterns with Sonic Pi

  1. Try tutorial 5.5 in Sonic Pi to learn how to use functions to reuse blocks of code to make music
  2. After trying the tutorial, experiment with creating your own functions and “call” them to create a melody, harmony, or beat. 
    1. If you’d like an example to customize, use one of the examples in the “Help” section of Sonic Pi
    2. OR follow these steps to code Hot Cross Buns 

Learn more

Learn more about reusing musical patterns with functions.

Share What You Learned

Post a link to a shared Scratch project you created or sample code from Sonic Pi and explain how you used functions to reuse blocks of code to make music or sound.