import random

#function for choosing a random number from [1..4]
choice1to4 = lambda : random.choice([1,2,3,4])

#a generator for succesive time values that cycles over a list
def timeGeneratorCyclic(someList):
	length = len(someList)
	i = 0
	time = 0
	while 1:
		yield(time)
		time = time+someList[i]
		i = (i+1)%length

#a generator for note durations that also cycles over a list
def sustainGeneratorCyclic(someList):
	length = len(someList)
	i = 0
	while 1:
		yield(someList[i])
		i = (i+1)%length

#need something to generate note durations
def noteDuration(someList):
	while 1:
		yield(random.choice(someList))

#need a coroutine for keeping track of time
def timeGen():
	time = 0
	while 1:
		delta = yield(time)
		time += delta

#need a function that given a note duration,
#an integer from one to four and a start time
#returns a list of start times and durations
def splitter(duration,someInt,startTime):
	#this is how long each note should last
	delta = duration/float(someInt)
	#the list where we'll accumulate the values
	someList = []
	for i in range(someInt):
		someList.append((startTime+i*delta,delta))
	return someList
