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—Samian, Jayli 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…but before the finish( ) 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.
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:
- SteadyBeat - drum beats and percussion loops
- Bass - Deep and low sounding instruments
- Harmony - “steady” toned instruments without much action, like strings
- Melody - the main tune of the song, often able to be sung.
- 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
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!
Extension A shows students how to add sound clips they like to favourites.