Activity 1 - Set tempo & add sounds

Workshop Resources

Let’s take a closer look at the pre-existing code and understand what it means.

The setTempo() function allows you to set the overall project tempo. Tempo is the speed at which a piece of music is played. Changing a project’s tempo allows for different styles of music to be created. Try changing the tempo of your setTempo function by changing the number in the block and see what happens! Please make sure it is a number between 45-220. Below are some suggestions for tempos you can use.

Now that our tempo is set, it is time to add sounds. To do so, we must utilize the fitMedia() function. We will be placing the new code below the setTempo() function.

Activity 1

  1. Make sure the cursor in your program is below the setTempo() functions
  1. Scroll through the API list on the left side of the code editor and find the fitMedia() function.
  1. Click on the Paste icon on the right corner of fitMedia() to insert the function below the setTempo function.
  1. You may notice that when you paste the function, Earsketch produces some placeholder texts that we will need to replace later. These placeholder texts are also known as parameters.

You can specify your own values for the following:

If you are not sure what values to choose, try this:

Your code should now look something like this:

from earsketch import *

setTempo(120)
fitMedia(YG_TRAP_ELECTRIC_PIANO_FILTERED_1, 3, 1, 17)

Make sure the capitalization of the method call is correct. Most programming languages, Python included, are case sensitive. This means that adding capital letters can call a different function than expected. For example: fitMedia() is not the same as FitMedia().

  1. Once you have input your own parameters, press run, then click on play to listen to your audio clip!

Digital Audio Workstation (DAW) is the area which the sounds appear in. It is at the center top of your EarSketch window. The following is an example of how different sections of a song may look in the DAW.