Make a musical composition
This challenge has been written by EU Code Week Team and is part of the EU CODE WEEK CHALLENGES.
Target Audience
  1. Teachers
  2. Students (12-18)
  1. Intermediate
  1. 1 hour
Recommended Materials
  1. Earsketch
  1. To learn coding through music
  2. To distinguish music genres and instruments
  3. To compose a song by mixing sound clips
In this challenge you will create a musical composition by using a programming language. You can use built-in sound clips or record your own and mix them to create a musical composition. Run your code in the Digital Audio Workstation and listen to the music you have coded. Play with different sounds and effects to modify your piece of music.
  • Log in to Earsketch.
  • Click here to make a script. Name your script and choose Python as a programming language.
  • Start writing your code between the setTempo(120) and finish() lines.
  • Browse the music clips in the Sound Library and select the music genres, artists and instruments you like.
  • To add a sound clip to your song, type fitMedia(). Between the parenthesis there should be the following 4 parameters, separated by commas:
    1. Sound clip: Place your cursor between the parenthesis, go to the Sound Library, select a clip, and paste it by clicking on the blue paste icon.
    2. Track number: tracks help you organize your sounds by instrument-type (vocals, bass, drums, keyboards, etc.). Add as many tracks (instruments) as you want. Tracks are displayed as rows that run across the Digital Audio Workstation.
    3. Start measure: indicates when your sound will start playing. Measures are musical time units. One measure is 4 beats.
    4. End measure: indicates when your sound will stop playing.
  • Such a line of code will look like this: fitMedia (HOUSE_DEEP_AIRYCHORD_002, 2, 2, 8)
  • You can add different effects, such as volume to enhance the sound of your composition. Volume ranges from -60.0 decibels to 12.0 decibels with 0.0 being the original volume.
  • Write setEffect(). In the parenthesis, write the number of track, VOLUME, GAIN, level of the volume, the measure when it starts, the level and measure when it ends.
  • This is an example of a fade-in effect:
    setEffect (1, VOLUME, GAIN, -40, 1, 0, 4)
    and a fade-out effect:
    setEffect (5, VOLUME, GAIN, 0, 8, -15, 10)
Share the link to your work in your Instagram Bio: tap the Edit Profile button on your Instagram and add the link to your work in the Website field. After that, create a new post, add a screenshot of your work, write “Link in Bio”, add the hashtag #CodeWeekChallenge and mention @CodeWeekEU.
You prefer to share your challenge(s) on Facebook? EU Code Week will pin a new Challenge post on their Facebook page . You then just need to comment on the post with the link to your work.
Winners will be selected and offered Code Week goodies every day during Code Week between 9 – 24 October and announced on our Instagram and Facebook channels, so don't forget to check your notifications regularly.
Complete all the Challenges
Challenge completed? Print the bingo card and mark the little white bubble on the top left
Share your Challenge on social media and win some cool Code Week prizes
Just upload a picture with the completed row(s), column(s) or even better - the whole bingo - to Facebook, Instagram or Twitter
Make sure to use the #CodeWeekChallengesBingo
Listen to an example of a song coded with Earsketch. You can import the code and edit it.
Click here to download this challenge as a word document.