published on
Creator: Robert Marzec
-------------------------------------------------------------
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. To learn more about EarSketch, visit http://earsketch.gatech.edu.
-------------------------------------------------------------
This music was generated by the following code:
# python code
# script_name: Mid day Parade Competition Song
#
# author: Robert Marzec
# description: My attempt at an electro song for the EarSketch Competition. I hope you enjoy!
from earsketch import *
init()
setTempo(125)
#Creating variables to simplify code
fM = fitMedia
sE = setEffect
#Adjusting volume based on user input
adjustVolume = 0
validInput = False
while(validInput == False):
inputVal = readInput("Enter a value ranging from -10 to 10 to adjust the volume of the song. Enter 0 or nothing for the song to play as normal.")
if(inputVal == "" or int(inputVal) == 0):
validInput = True
readInput("The volume will not be changed. (Enter anything to continue)")
elif(int(inputVal) > 0 and int(inputVal) <= 10):
validInput = True
readInput("The volume will be increased by " + inputVal + ". (Enter anything to continue)")
adjustVolume = inputVal
elif(int(inputVal) < 0 and int(inputVal) >= -10):
validInput = True
readInput("The volume will be decreased by " + str(((-1) * int(inputVal))) + ". (Enter anything to continue)")
adjustVolume = inputVal
else:
readInput("I'm sorry, but you did not enter a value within the specified range. Please try again. (Enter anything to be asked again)")
#Lists of sounds for simple access and organization in the different sections
openingSounds = ["YG_ELECTRO_ELECTRIC_PIANO_1", "YG_ELECTRO_RHODES_1", "YG_ELECTRO_PAD_1", "Y56_ELECTRO_BUILD_1", "Y15_HI_HAT_1"]
sectionASounds = ["Y46_ELECTRO_2", "YG_ELECTRO_RHODES_1", "RD_ELECTRO_MAINBEAT_6"]
sectionBSounds = ["YG_ELECTRO_LEAD_1", "YG_ELECTRO_SYNTH_BRASS_2", "YG_ELECTRO_RHODES_1", "RD_ELECTRO_MAINBEAT_8", "YG_EDM_REVERSEFX_1"]
#Section of the song that plays from measures from 1 to 13
def openingSection(startMeasure):
endMeasure = startMeasure + 12
#Sounds and effects for track 2
fM(openingSounds[0], 2, startMeasure, endMeasure)
sE(2, VOLUME, GAIN, -20, startMeasure, 0, startMeasure + 2)
#Sounds and effects for track 3
fM(openingSounds[1], 3, startMeasure + 4, endMeasure)
sE(3, VOLUME, GAIN, -20, startMeasure + 4, 0, startMeasure + 6)
#Sounds and effects for track 4-5
for i in range(2, 4):
fM(openingSounds[i], i + 2, startMeasure + 8, endMeasure)
sE(4, VOLUME, GAIN, -5, startMeasure + 8, -5, endMeasure)
sE(5, VOLUME, GAIN, -20, startMeasure + 8, 0, endMeasure)
#Sounds and effects for track 6
for i in range(1, 13):
fM(openingSounds[4], 6, i, i + 1)
sE(6, VOLUME, GAIN, -40, startMeasure, 0, startMeasure + 8)
return endMeasure
#The first of two sections that get played after the intro
def sectionA(startMeasure):
endMeasure = startMeasure + 12
#Sounds and effects on track 2
fM(sectionASounds[0], 2, startMeasure + 4, endMeasure)
sE(2, VOLUME, GAIN, -30, startMeasure + 4, 0, endMeasure - 4)
#Sounds and effects on track 3
fM(sectionASounds[1], 3, startMeasure, endMeasure)
#Sounds and effects on track 4
fM(sectionASounds[2], 4, startMeasure, endMeasure - 4)
transition(startMeasure)
return endMeasure
#The second of two sections that get played after the intro
def sectionB(startMeasure):
endMeasure = startMeasure + 8
#Sounds and effects on track 2
fM(sectionBSounds[0], 2, startMeasure + 4, endMeasure)
fM(sectionBSounds[1], 2, startMeasure, startMeasure + 4)
sE(2, VOLUME, GAIN, -5, startMeasure, -5, endMeasure)
#Sounds and effects on track 3
fM(sectionBSounds[2], 3, startMeasure, endMeasure)
#Sounds and effects on track 4
fM(sectionBSounds[3], 4, startMeasure, endMeasure)
#Sounds and effects on track 5
fM(sectionBSounds[4], 5, endMeasure - 1, endMeasure)
sE(5, VOLUME, GAIN, 0, endMeasure - 1, 5, endMeasure)
transition(startMeasure)
return endMeasure
#Creates the clapping beat that goes throughout the entire song and makes the song fade out at the end
def endSong(finalMeasure):
for i in range(1, finalMeasure):
fM(Y62_CLAP_2, 1, i, i + 1)
sE(1, VOLUME, GAIN, -25, 1, -5, 13)
sE(0, VOLUME, GAIN, 0, finalMeasure - 4, -40, finalMeasure)
return finalMeasure + 4
#Plays a sound at the provided measure to help with smooth transitions
def transition(startMeasure):
fM(Y56_GUN_1, 5, startMeasure, startMeasure + 4)
sE(5, VOLUME, GAIN, 0, startMeasure, -30, startMeasure + 4)
#Creates the song and adjusts the volume to what was specified by the user earlier
def playSong():
measure = openingSection(1)
measure = sectionA(measure)
measure = sectionB(measure)
measure = sectionA(measure)
measure = sectionA(measure)
endSong(measure)
sE(0, VOLUME, GAIN, int(adjustVolume), 1, int(adjustVolume), 1)
#Playing the song
playSong()
finish()
-------------------------------------------------------------
To load this track in EarSketch, visit https://earsketch.gatech.edu/earsketch2/#?sharing=MJyTwSx7ASRJGNoIvDUDpw
-------------------------------------------------------------