Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaimez/6dfe95aec03cff743941 to your computer and use it in GitHub Desktop.
Save jaimez/6dfe95aec03cff743941 to your computer and use it in GitHub Desktop.
Project B Survey of music technology Georgia Institute of Technology
###########################################################
# script_name: Project B #
# #
# author: Jaime Bescansa #
# #
# description: Jaime Bescansa's Project B #
# #
###########################################################
#General Imports
from earsketch import *
from random import *
#Global variables
global index
index = 0
#Functions...
def getRandElem(elemList):
"""
It returns an random integer taking into account
the length of a given list.
"""
return randint(0, len(elemList) - 1)
def getElement(elementList):
"""
It returns a randomed string beat
with random sound files for each beat.
"""
a = getRandElem(elementList)
b = getRandElem(elementList)
c = getRandElem(elementList)
d = getRandElem(elementList)
e = getRandElem(elementList)
out =["++++++++%d+++++++" % a,
"++++++++%d++++%d++" % (a, b),
"++%d+++++%d++++%d++" % (a, b, c),
"++%d++%d++%d++++%d++" % (a, b, c, d),
"++%d++%d++%d++%d+%d++" % (a, b, c, d, e)]
return out[randint(0, 4)]
def getSingleElement(elementList):
"""
It returns a single string beat with random sounds.
False if the elementList is None
"""
myChoosen = getRandElem(elementList)
if not elementList[myChoosen]:
return None
out = "%d+++++++++++++++" % myChoosen
return out
def getHatElement(elementList):
a = getRandElem(elementList)
b = getRandElem(elementList)
c = getRandElem(elementList)
d = getRandElem(elementList)
e = getRandElem(elementList)
f = getRandElem(elementList)
g = getRandElem(elementList)
out = ["%d+%d+%d++%d++%d+++%d%d" % (a, b, c, d, e, f, g),
"%d+%d%d+++%d+%d+++%d+%d" % (a, b, c, d, e, f, g),
"%d+%d++%d+%d+%d++%d++%d" % (a, b, c, d, e, f, g)]
return out[randint(0, 2)]
#Initializing song...
init()
setTempo(125)
#Constants...
baseGrid = Y15_BEAT_1
myKick = Y15_PERCUSSION_1
myBase = Y58_BASS_1
mySingleCrash = Y15_SNARE_1
#Changes the duration of the song...
duration = 65
#Variables...
hats = [OS_CLOSEDHAT01, OS_CLOSEDHAT02, OS_CLOSEDHAT04, OS_CLOSEDHAT05, OS_CLOSEDHAT06]
snares = [OS_SNARE01, OS_SNARE02, OS_SNARE03, OS_SNARE04, OS_SNARE05, OS_SNARE06]
crashes = [Y15_SNARE_1, Y06_HI_HATS, Y03_CRASH_1, Y02_CRASH_1]
melodies = [TECHNO_CLUBRICH_PAD_001, TECHNO_CLUBRICH_PAD_002, TECHNO_CLUBRICH_PAD_003,
TECHNO_CLUBRICH_PAD_004, None]
#Creating Tracks...
#Track 01 fitMedia for BaseGrid...
fitMedia(baseGrid, 1, 1, duration - 0.5)
#Track 02 plain makeBeat for myKick sound...
for i in range (8, duration - 1):
makeBeat(myKick, 2, i, "0+++++++0+0+++++")
#Track 03 plain makeBeat for Base sound...
for i in range (5, duration - 10):
makeBeat(myBase, 3, i, "0++++++++++++++0")
#Track 04 crash Sounds avoiding elements from a list ...
myAvoidBeats = [8, 16, 24, 32, 48, 54, 66, 72, 78, 84]
for i in range (14, duration, 2):
if not i in myAvoidBeats:
makeBeat(mySingleCrash, 4, i, "++++0+++++++++++")
#Track 05 hithat Sounds randomed using the function getHatElement...
for i in range(12, duration - 5):
myHitHat = getHatElement(hats)
makeBeat(hats, 5, i, myHitHat)
#Track 06 snare randomed sounds using the function getElement...
for i in range(18, duration - 2):
mySnare = getElement(snares)
makeBeat(snares, 6, i, mySnare)
#Track 7 randomed melodies placed at the beginning of the beat...
for i in range(25, duration - 20):
myMelodies = getSingleElement(melodies)
if myMelodies:
makeBeat(melodies, 7, i, myMelodies)
#Track 8 fitMedia with effect around the melody time range...
fitMedia(baseGrid, 8, 25, duration - 12)
#Set Flanger effect during this time range...
for i in range(25, duration - 12):
setEffect(8, FLANGER, FLANGER_FEEDBACK, float(randint(-8, -1)), i)
#Finnishing song...
finish()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment