EarSketch helps you learn core topics in computer science, music, and music technology in a fun, engaging environment. You learn to code in Python or JavaScript, two of the most popular programming languages in the world, while manipulating loops, composing beats, and applying effects to a multi-track digital audio workstation.

fitMedia() is the main function you will call when you want to add a music file to your program. There are four different pieces of the fitMedia() function.

A complete fitMedia() function looks like this: fitMediaThat looks like a lot so we will go over it piece by piece.

The first part, fitMediaonly , is written in camel case. It calls the fitMedia() function that is programmed into EarSketch.

Camel Case is called that because the first word is written in lower case, then every word after that has a capitol letter at the beginning and now spaces between words.

An example is: thisIsCamelCase

The second part in the example is written inside of the paranthsis of the fitMedia() function, this is the name of one of the music pieces you want to use.


How do we insert our music?

  1. Go to the Capture button that is on the far left side of the screen. This is the entire library of music that EarSketch has, it has classical, electronics, hip hop, and dub step instrumental pieces for you to use.
  2. Listen to the different pieces my pressing the play.PNG button
  3. One you have selected on piece of music you wish to use, click in between fitMedia’s (). Then press the addmusic.

The third part controls on which line the specific piece of music is on. After the inserted music title put a comma, a  space and then which ever line you want to your music to be on.  I’ll put 1 because I want to my music to be on line 1. Now my program looks like this: part3

A measure with the same number of beats in each measure. In EarSketch, measures always have four beats. You may have noticed above that you can clap along to a song in quite a few ways that seem to fit. For example, if you clap once every 4 beats, you are clapping once every measure

The fourth part controls when the music starts. After the inserted music title put a comma, a  space and then which ever measure you want the music to start on. I’ll put 1 because I want start my music at 1. Now my program looks like this: part4

The fifth part controls on which measure the music finishes. After the last comma type in whatever number you want the music to end on. The best measures for your song to end is measures that are a multiple of 8 (16, 24, 32, etc). I am going to put 16, now my program looks like this: part5

Much like a regular song where multiple instruments are used we will use multiple fitMedia() functions to make out first song. Repeat the above process to call upon multiple pieces of music to make our song but each time you must change a few things.

When I create a new fitMedia() function I must change the first 1 to a 2 becasue two pieces of music can be on the same line

So my final song, which has three different parts, looks like this:


The fitMedia() functions have to be written in between the setTempo(120) and finish(). You can have as many different parts as wish.