Skip to Content
Module 4 Creating Your Soundbank, Variables, & Tracks

Action: Creating A Soundbank And Variables

Activity 2: Creating Your Sound Bank (15 minutes)

Now that you have the outline of your script, let’s add some music. EarSketch has audio stems (sound clips) from genres such as R&B, Hip Hop, EDM, House, Pop, and Funk (and many more), and from over 300 different instrument samples. We are proud to present sound clips from our participating Indigenous Canadian musicians—SamianJayli Wolf, and Dakota Bear.  In addition to these, we have sound clips from recording artists and sound engineers such as Pharrell, Ciara, Common, Richard Devine, and Young Guru. (Select the artist's name to learn more about their music.)

You will create a #SOUNDBANK with all our favourite sounds that we will use during our song. For more details on #SoundBank, see the EarSketch curriculum (25.6)


Create a new script called Your Voice is Power [Your Initials].

  • Don't include the brackets [ ] in the script name!

Create your #SOUNDBANK

  • Type #SOUNDBANK in the CODE EDITOR on an empty line after the setTempo(120) line.
    - Notice that it is a comment because you used a # so it won't run like the other code.
  • Your #SOUNDBANK will be like a drawer that holds your selected sound clips. You will go into that drawer and place those sounds in your song when and where you want them.

Time to listen to and choose some great beats.

  • Access the sound browser by selecting  Sounds (headphones icon) in the CONTENT MANAGER just below the EarSketch logo.
  • Search for sounds by artist, genre, and instrument. There will also be suggestions for sounds that fit your script or sounds used by others who have searched for similar sounds in the sound collection menu. 
  • Use the green play button next to the sound clip’s name to listen to it and decide if you like it.
  • Use the blue clipboard icon to paste the sound clip into your code editor under the #SOUNDBANK heading.
  • Add two sound clips to your #SOUNDBANK – one drum sound and one vocal sound. 
  • Don't forget to select the next empty line before pasting your second sound.

Note: You might add separate sections to your #SOUNDBANK for each category of sound clip. For example:





Activity 3: Assigning Variables to Your Sound Clips (15 minutes) 

Some of the sounds have pretty long names. E.g.,  JWOLF_COTG_BEAT_FULL 

We can use variables to give our sounds nicknames. 



Now when you want JWOLF_COTG_BEAT_FULL, you can use its nickname or variable - drum.

Look at your #SOUNDBANK in your code editor. It’s time to assign these clips to some variables.

A variable is like a container that stores data or information. You give this container a name to remind you what information you put inside it. You can put whatever kind of data you like inside! The information can be numbers, words, and sentences called strings, or unchangeable data called constants, like our sound clip names.


  • Use the assignment operator = to assign your variable a value. 


  • Assign a variable/nickname for each sound clip in your #SOUNDBANK
  • Now, add 3 more sound clips to your #SOUNDBANK! Think about the different instruments you heard in Samian's song. Add some different sounds.

Most songs include at least one sound from 5 main categories:

  1. SteadyBeat - drum beats and percussion loops
  2. Bass - Deep and low sounding instruments
  3. Harmony - “steady” toned instruments without much action, like strings
  4. Melody - the main tune of the song, often able to be sung.
  5. Sound Effects(SFX) - fun accents or “bells and whistles” that occasionally happen in a song for emphasis.
  • Assign your new sound clips a variable/nickname!
Learn more about variables in this tutorial with video.

Activity 4: Adding Sound Clips to your Tracks (15 minutes)

Now we will revisit fitMedia(). This time, you are going to be in charge of 'fitting the media' in where you want! We have our sounds and even assigned them cool nicknames (or variables). Now, you are ready to remix them in your song using the function fitMedia(). Remember, a function is a piece of code that performs a task. The fitMedia() function adds an audio file to a specified track at specific start and end times.

The fitMedia() function takes in four input parameters:

  • Sound clip name: The sound clip placed in the Digital Audio Workstation
  • trackNumber: Track on which music is placed
  • startMeasure: The measure at which the sound clip will start
  • endMeasure: The measure at which the sound clip will end

Ex. fitMedia(drums,1,1,5)

A function is a piece of code that performs a task—often consisting of many smaller actions.


  • Type #intro to your script in the code editor (after your #SOUNDBANK entries)
    - but before the finish() function 
    - This is a comment that helps to organize the structure of your song!
    - We will consider this music you are adding to be the #Intro to your song. Of course, this is all practice so you can learn the skills. It may not really end up being the real intro of your final song!
  • Select  enter to type on the line below #intro 
  • Type fitMedia() in your code editor.
    - Notice that your closing parenthesis automatically inserts as you type the opening parenthesis. The cursor remains between the brackets—ready for the parameters!) 
    - If you do type the closing parenthesis, you will need to click between them before the next step!
  • Choose a sound from your #SOUNDBANK and type the variable name as your first parameter. Place a comma after the variable name.
  • Enter “1” as your trackNumber. Place a comma after the track number.
  • Enter “1” as your startMeasure. Place a comma after the startMeasure.
  • Enter “5” as your endMeasure
  • Select  Run and Play.
  • You have coded your first piece of music. How does it sound?
  • Repeat this process for the remaining four sound clips. Remember each sound clip needs to be on a different track (2, 3, 4, etc) and the ending measure must be a larger number than your starting measure. 
    - Note: As an extension in Module 6, you will learn to stagger your starting and ending measures. But, let's leave it as is for now—all starting on measure 1 and ending on measure 5 in a later module.
  • If you want to add sound clips directly from the sound browser, you can select the blue clipboard icon to paste it directly in the fitMedia() function.

Remember to check that you have commas between each argument and close your parentheses. Run and play your song often to hear your beats. If you need additional support, check out the EarSketch chapter on Composing in EarSketch

Congratulations, you are officially a code DJ!

Kick it up a Notch with Some Effects!

There are many other functions available for students to use when they are ready!

Your students will have a competitive EarSketch submission without the extra EarSketch functions.  However, if students want to try out one function, we recommend setEffect().

Change the volume on one of the tracks. This is a pretty easy effect exercise.


 setEffect(2,VOLUME, GAIN, 8) (increases volume on track 2)

setEffect(3, VOLUME, GAIN, -30) (decreases volume on track 3)

Extension B lists other functions to try!

Activity 5: Recording and Adding a Sound to EarSketch (10 minutes + homework)

You may wish to add your own sound (either lyrics you say or sing) or something you've recorded or get from another copyright-free source.

In this activity, you will record and add lyrics. You might add a lyric from Jayli's song (and credit her with a #comment in your script) OR you may record an original lyric that you were inspired to write by her song.

  1. Open your Your Voice is Power [Your Initials] script.
  2. Select the Add Sound button in the Sound browser.
Add Sound button in Content Manager

3. This action will open a pop up window, with the "Upload Sound" tab open.

Add a New Sound dialog box

4. Select the QUICK RECORD tab.

5. Select the REC icon to start recording. It will countdown, then start recording.

6. Select the REC icon again to stop recording.

7. Type a name for your recording where it says Constant Name (required).

Select the UPLOAD button.

Quick Record tab

8. FILTER your SOUNDS by Artists. You will see your login name there as an artist!

NOTE: Make sure you CLEAR your Instruments first!

Artists' List in Content Manager

9. Select Your Name. You will see your sound clip.

10. You can now add your sound clip to the #SOUNDBANK

- Assign it a variable

- Replace one of the tracks you have in your #intro with your new sound

- Change the variable name in one of the fitMedia() functions

11. Select Run and Play

Sound Collection - Your Name

Extension A shows students how to add sound clips they like to favourites.