Code a song
Intro to EarSketch
- Open EarSketch.
- Click to Create a new script (give a script name & script language is Python)
- Select all and Delete.
- Select the Sample Music Code below and copy
- Go back to EarSketch and paste the code
- Click Run (you will need to click Run every time you make a change to the code)
- Click play button and listen to your beautiful music
- Try replacing an instrument for the variable synth1. Delete TECHNO_SYNTHPLUCK_001 and paste in new instrument, eg. synth1 = HOUSE_ACOUSTIC_PIANO_004
- Try creating a new variable.
- Try adding a new track.
- When finished, download your song. Select second folder on left-hand side of screen. Select blue lines next to your script. Select Download. Select MP3.
Sample Code
# python code
# script_name:
#
# author:
# description:
#
from earsketch import *
init()
setTempo(120)
synth1 = TECHNO_SYNTHPLUCK_001
synth2 = RD_EDM_ANALOGLEAD_3
drums = TECHNO_LOOP_PART_006
#melody
fitMedia(synth1, 1, 1, 2)
fitMedia(synth2, 2, 2, 4)
fitMedia(synth1, 1, 3, 4)
fitMedia(synth2, 2, 4, 5)
fitMedia(synth1, 1, 5, 6)
fitMedia(synth2, 2, 6, 7)
fitMedia(synth1, 1, 7, 8)
fitMedia(synth2, 2, 8, 9)
#drums
fitMedia(drums, 4, 5, 9)
finish()
# python code
# script_name:
#
# author:
# description:
#
from earsketch import *
init()
setTempo(120)
synth1 = TECHNO_SYNTHPLUCK_001
synth2 = RD_EDM_ANALOGLEAD_3
drums = TECHNO_LOOP_PART_006
#melody
fitMedia(synth1, 1, 1, 2)
fitMedia(synth2, 2, 2, 4)
fitMedia(synth1, 1, 3, 4)
fitMedia(synth2, 2, 4, 5)
fitMedia(synth1, 1, 5, 6)
fitMedia(synth2, 2, 6, 7)
fitMedia(synth1, 1, 7, 8)
fitMedia(synth2, 2, 8, 9)
#drums
fitMedia(drums, 4, 5, 9)
finish()