def c1(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) for i in range(0, 2): for j in range(0, 16 * 4): chordNote = chords[(int)((j/16))] listNotes[0][0].append(chordNote - 12) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(1) listNotes[0][4].append(.125) listNotes[1][0].append(chordNote - 24) listNotes[1][1].append(.125) listNotes[3][0].append(scale[1][0]) listNotes[3][3].append(.125) if j%8 == 4: # snare on every 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if j%2 == 0: # cymbal on every 1, 2, 3, and 4 listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) for i in range(0, 4): listNotes[2][0].append(chords[i]) randomInterval = random.randint(4,5) synthIndex = ((scale[0].index(chords[i]) + randomInterval)%len(scale[0])) listNotes[2][0].append(scale[0][synthIndex] + (12 * ((int)((chordNote + randomInterval) > scale[0][len(scale) - 1]))) - 12) randomInterval = random.randint(1,2) synthIndex = ((scale[0].index(chords[i]) + randomInterval)%len(scale[0])) listNotes[2][0].append(scale[0][synthIndex] + (12 * ((int)((chordNote + randomInterval) > scale[0][len(scale) - 1])))) listNotes[2][1].append(.75) listNotes[2][1].append(.75) listNotes[2][1].append(.5) return listNotes
def b4(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] lengths = [.5, .25] chords = getChordProgression(scale) chord = [] for i in range(0, 2): midiBeatCounter = 0 while midiBeatCounter < 8: chord.clear() rootNote = chords[(int)(midiBeatCounter/2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 4th/5th/6th randInt = random.randint(1, 2) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randInt = random.randint(3, 5) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randomLength = random.choice(lengths) if randomLength + midiBeatCounter > 8: randomLength = 8 - midiBeatCounter rest = random.randint(0,1) if rest == 0: listNotes[0][0].append(scale[0][0] - 12 + 1) listNotes[0][1].append(scale[0][0] - 12 + 7) listNotes[1][0].append(scale[0][0] - 24 + 1) else: listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[1][0].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][4].append(randomLength) listNotes[1][1].append(randomLength) midiBeatCounter += randomLength for i in range(0, int(randomLength * 4)): if i == 0 and rest == 0: listNotes[3][0].append(scale[1][0]) else: listNotes[3][0].append(-1) listNotes[3][3].append(.25) if random.randint(0, 1) == 0: listNotes[2][0].append(random.choice(scale[0])) else: listNotes[2][0].append(random.choice(chord)) listNotes[2][1].append(randomLength) for i in range(0, 2): for j in range(0, 8 * 4): if (j%8 == 4 and i == 0) or (j%16 == 8 and i == 1): listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if (j%2 == 0 and i == 0) or (j%4 == 0 and i == 1): listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) return listNotes
def c4(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] lengths = [.25, .125, .5] chords = getChordProgression(scale) chord = [] for i in range(0, 2): midiBeatCounter = 0 while midiBeatCounter < 8: chord.clear() rootNote = chords[(int)(midiBeatCounter/2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 4th/5th/6th randInt = random.randint(1, 2) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randInt = random.randint(3, 5) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) chord.append(scale[0][(scale[0].index(rootNote) + 6)%len(scale[0])] + (12 * ((int)((scale[0].index(rootNote) + 6)/len(scale[0]))))) randomLength = random.choice(lengths) if randomLength + midiBeatCounter > 8: randomLength = 8 - midiBeatCounter if randomLength == .5: listNotes[0][0].append(scale[0][0] - 24) listNotes[1][0].append(scale[0][0] - 24) else: randInt = random.randint(0, 3) if randInt == 0: listNotes[0][0].append(scale[0][0] - 24) listNotes[1][0].append(scale[0][0] - 24) else: randomNote = random.choice(chord) - 12 listNotes[0][0].append(randomNote) listNotes[1][0].append(randomNote - 12) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(1) listNotes[0][4].append(randomLength) listNotes[1][1].append(randomLength) midiBeatCounter += randomLength for j in range(0, int(randomLength * 8)): if j == 0: listNotes[3][0].append(scale[1][0]) else: listNotes[3][0].append(-1) listNotes[3][3].append(.125) for j in range(0, 16 * 4): chord.clear() rootNote = chords[(int)(j/16)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 4th/5th/6th randInt = random.randint(1, 2) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randInt = random.randint(3, 5) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) chord.append(scale[0][(scale[0].index(rootNote) + 6)%len(scale[0])] + (12 * ((int)((scale[0].index(rootNote) + 6)/len(scale[0]))))) if ((j%8 == 2 or j%8 == 6) and i == 0) or (j%8 == 4 and i == 1): listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if j%2 == 0: # cymbal on every 1, 2, 3, and 4 listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) listNotes[2][0].append(chord[j%4]) listNotes[2][1].append(.125) return listNotes
def c3(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) chord = [] for i in range(0, 2): for j in range(0, 16 * 4): chord.clear() rootNote = chords[(int)(j/16)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 4th/5th/6th randInt = random.randint(1, 2) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randInt = random.randint(3, 5) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) if j%16 < 8: listNotes[0][0].append(rootNote - 12) listNotes[0][1].append(chord[1] - 12) listNotes[1][0].append(rootNote - 24) else: listNotes[0][0].append(chord[1] - 12) listNotes[0][1].append(chord[2] - 12) listNotes[1][0].append(chord[1] - 24) listNotes[0][2].append(-1) listNotes[0][3].append(random.randint(0, 1)) listNotes[0][4].append(.125) listNotes[1][1].append(.125) listNotes[3][0].append(scale[1][0]) if int(j/16)%2 == 0: listNotes[3][0].append(-1) else: listNotes[3][0].append(scale[1][0]) if j%2 == 0: listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) listNotes[3][2].append(-1) if j%2 == 0 and int(j/16)%2 == 0: listNotes[3][1].append(scale[1][1]) elif j%8 == 4 and int(j/16)%2 == 1: listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) listNotes[3][1].append(-1) for i in range(0, 2): listNotes[3][3].append(.0625) if j%16 < 8: listNotes[2][0].append(chord[1]) else: listNotes[2][0].append(rootNote) listNotes[2][1].append(.125) return listNotes
def c2(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) chord = [] for i in range(0, 2): j = 0 while j < 8 * 4: chord.clear() rootNote = chords[(int)((j/4)/2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 5th/6th #for x in range(1, 3): # synthIndex = ((scale[0].index(rootNote) + (x * 2))%len(scale[0])) # chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + (x * 2))/len(scale[0]))))) if int(j%4) == 3: listNotes[1][0].append(rootNote - 12) listNotes[1][1].append(.25) listNotes[3][0].append(scale[1][0]) listNotes[3][0].append(-1) else: randInt = random.randint(0, 3) if randInt == 0 and j%4 == 0: listNotes[1][0].append(rootNote - 24) listNotes[1][1].append(.5) listNotes[3][0].append(scale[1][0]) for i in range(0, 3): listNotes[3][0].append(-1) j += 1 elif randInt == 1 and j%4 == 2: listNotes[1][0].append(-1) listNotes[1][1].append(.25) listNotes[3][0].append(-1) listNotes[3][0].append(-1) elif randInt == 2: listNotes[1][0].append(rootNote - 24) listNotes[1][1].append(.25) listNotes[3][0].append(scale[1][0]) listNotes[3][0].append(-1) else: for i in range(0, 2): listNotes[1][0].append(rootNote - 24) listNotes[1][1].append(.125) listNotes[3][0].append(scale[1][0]) j += 1 chord = [] for k in range(0, 16 * 4): chord.clear() rootNote = chords[(int)(k/16)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 4th/5th/6th randInt = random.randint(1, 2) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) randInt = random.randint(3, 5) synthIndex = ((scale[0].index(rootNote) + randInt)%len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + randInt)/len(scale[0]))))) if not k%4 == 3: listNotes[0][0].append(chord[k%4] - 12) listNotes[2][0].append(chord[k%4]) else: listNotes[0][0].append(chord[1] - 12) listNotes[2][0].append(chord[1]) listNotes[2][1].append(.125) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][4].append(.125) listNotes[3][3].append(.125) if k%8 == 4: # snare on every 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if k%2 == 0: # cymbal on every 1, 2, 3, and 4 listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) return listNotes
def c0(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) for i in range(0, 2): for j in range(0, 8 * 4): # I will either add two sixteenth notes or one quarter note # isDouble means I will add two sixteenth notes # otherwise, I will add a quarter note isDouble = False randomInt = random.randint(0, 5) chordNote = chords[(int)((j/8))] ### guitar and bass if(randomInt >= 3): # one quarter note ### guitar and bass listNotes[0][0].append(chordNote - 12) listNotes[0][1].append(chordNote + 7 - 12) sixIndex = (scale[0].index(chordNote) + 2) % len(scale[0]) listNotes[0][2].append(scale[0][sixIndex] + (12 * ((int)(scale[0].index(chordNote) + 2 > len(scale[0]) - 1)))) listNotes[0][3].append(1) listNotes[0][4].append(.25) # bass listNotes[1][0].append(chordNote - 24) listNotes[1][1].append(.25) # kick drum listNotes[3][0].append(scale[1][0]) listNotes[3][3].append(.25) elif(randomInt >= 1): # two sixteenth notes isDouble = True randInt = random.randint(0,3) ### guitar and bass if(randInt == 0): # palm mute and rest listNotes[0][0].append(chordNote - 12) listNotes[0][1].append(chordNote + 7 - 12) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) # bass listNotes[1][0].append(chordNote - 24) listNotes[1][0].append(-1) # kick drum listNotes[3][0].append(scale[1][0]) listNotes[3][0].append(-1) elif(randInt == 1): # two palm mutes for i in range(0, 2): listNotes[3][0].append(scale[1][0]) listNotes[0][0].append(chordNote - 12) listNotes[0][1].append(chordNote + 7 - 12) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[1][0].append(chordNote - 24) else: # rest and palm mute listNotes[3][0].append(-1) listNotes[3][0].append(scale[1][0]) listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][0].append(chordNote - 12) listNotes[0][1].append(chordNote + 7 - 12) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[1][0].append(-1) listNotes[1][0].append(chordNote - 24) for i in range(0, 2): listNotes[3][3].append(.125) listNotes[0][4].append(.125) listNotes[1][1].append(.125) else: # quarter note rest listNotes[3][0].append(-1) listNotes[3][3].append(.25) listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][4].append(.25) listNotes[1][0].append(-1) listNotes[1][1].append(.25) ### drums listNotes[3][2].append(scale[1][2]) if(j%4 == 2): # snare on every 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if(isDouble): listNotes[3][2].append(-1) listNotes[3][1].append(-1) ### synth # arpeggiates the third of the root note synthIndex = ((scale[0].index(chordNote) + 2)%len(scale[0])) listNotes[2][0].append(scale[0][synthIndex] + (12 * ((int)((chordNote + 2) > scale[0][len(scale) - 1])))) listNotes[2][0].append(scale[0][synthIndex]) for i in range(0, 2): listNotes[2][1].append(.125) return listNotes
def v1(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] # build a basic four-'chord' structure chords = getChordProgression(scale) randomNote = 0 for i in range(0, 2): for j in range(0, 16 * 4): ### guitar and bass randomNote = 0 # get an int from 0-3 using integer division # use this int as an index for chords[] to get a 'chord' note chordNote = chords[(int)((j / 8) / 2)] # defaults to palm-mutes velocity = 0 # reinforce 'chord' note if (random.randint(0, 2) == 0 or j % 8 == 0): randomNote = chordNote listNotes[3][0].append(scale[1][0]) listNotes[1][0].append(randomNote - 24) else: # open notes velocity = 1 while (randomNote < chordNote or randomNote > chordNote + 15): randomNote = 12 * random.choice(range( 0, 2)) + random.choice(scale[0]) if (i == 0): # kick and bass match every guitar note for the first rep listNotes[3][0].append(scale[1][0]) listNotes[1][0].append(randomNote - 24) else: # for the second rep they only reinforce the palm-muted root notes listNotes[3][0].append(-1) listNotes[1][0].append(-1) # arpeggiates the 3rd of the 'chord' note # the 3rd is the degree of the root + 2 # 3rd of the 1st degree is the 3rd degree because 1 + 2 = 3 # 3rd of the 2nd degree is the 4th degree, etc. synthIndex = ((scale[0].index(chordNote) + 2) % len(scale[0])) listNotes[2][0].append(scale[0][synthIndex] + (12 * ( (int)((scale[0].index(chordNote) + 2) / len(scale[0]))))) listNotes[2][1].append(.125) listNotes[3][3].append(.125) listNotes[0][0].append(randomNote - 12) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(velocity) listNotes[0][4].append(.125) listNotes[1][1].append(.125) if j % 4 == 2 and i == 0: # snare on every 2 and 4 listNotes[3][1].append(scale[1][1]) elif j % 8 == 4 and i == 1: # snare on every 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if j % 2 == 0: # cymbal on every 1, 2, 3, and 4 listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) return listNotes
def v4(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) chord = [] for i in range(0, 2): for j in range(0, 16 * 4): chord.clear() rootNote = chords[(int)((j / 8) / 2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 5th/6th for x in range(1, 4): synthIndex = ((scale[0].index(rootNote) + (x * 2)) % len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + (x * 2)) / len(scale[0]))))) listNotes[2][0].append(chord[j % 4]) listNotes[2][1].append(.125) if i == 0: randomInt = random.randint(0, 7) if randomInt > 5: listNotes[0][0].append(rootNote - 12) listNotes[0][1].append(rootNote - 12 + 7) listNotes[1][0].append(rootNote - 24) listNotes[3][0].append(scale[1][0]) elif j % 16 == 0: listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[1][0].append(-1) listNotes[3][0].append(scale[1][0]) else: listNotes[0][0].append(-1) listNotes[0][1].append(-1) listNotes[1][0].append(-1) listNotes[3][0].append(-1) listNotes[1][1].append(.125) listNotes[0][3].append(0) else: randomInt = random.randint(0, 5) listNotes[0][0].append(rootNote - 12) listNotes[0][1].append(chord[2] - 12) listNotes[1][0].append(rootNote - 24) listNotes[1][1].append(.125) listNotes[3][0].append(scale[1][0]) if randomInt > 2: listNotes[0][3].append(1) else: listNotes[0][3].append(0) listNotes[0][2].append(-1) listNotes[0][4].append(.125) if j % 8 == 4: # snare on 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if j % 2 == 0: # cymbals on 1, 2, 3, and 4 listNotes[3][2].append(scale[1][4]) else: listNotes[3][2].append(-1) listNotes[3][3].append(.125) return listNotes
def v3(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) chord = [] for i in range(0, 2): for j in range(0, 16 * 4): chord.clear() rootNote = chords[(int)((j / 8) / 2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 5th/6th for x in range(1, 3): synthIndex = ((scale[0].index(rootNote) + (x * 2)) % len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + (x * 2)) / len(scale[0]))))) if random.randint(0, 1) == 0: listNotes[0][0].append(rootNote - 12) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(0) listNotes[0][4].append(.125) listNotes[1][0].append(rootNote - 24) listNotes[1][1].append(.125) else: randomNote = random.choice(chord) for k in range(0, 2): listNotes[0][0].append(randomNote - 12) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(1) listNotes[0][4].append(.0625) listNotes[1][0].append(randomNote - 24) listNotes[1][1].append(.0625) if i == 0: listNotes[3][0].append(-1) listNotes[3][0].append(scale[1][0]) listNotes[3][1].append(scale[1][1]) listNotes[3][1].append(-1) listNotes[3][2].append(scale[1][2]) listNotes[3][2].append(-1) listNotes[3][3].append(.0625) listNotes[3][3].append(.0625) else: if j % 8 == 4: listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) listNotes[3][1].append(-1) if j % 2 == 0: listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) listNotes[3][2].append(-1) for i in range(0, 2): listNotes[3][0].append(scale[1][0]) listNotes[3][3].append(.0625) if j % 2 == 0: for l in range(0, 4): if l == 3: listNotes[2][0].append(chord[1]) else: listNotes[2][0].append(chord[l]) listNotes[2][1].append(.0625) return listNotes
def v2(scale): listNotes = [[[], [], [], [], []], [[], []], [[], []], [[], [], [], []]] chords = getChordProgression(scale) chord = [] for i in range(0, 2): for j in range(0, 16 * 4): chord.clear() rootNote = chords[(int)((j / 8) / 2)] chord.append(rootNote) # builds a chord from the root note # root + 2nd/3rd + 5th/6th for x in range(1, 3): synthIndex = ((scale[0].index(rootNote) + (x * 2)) % len(scale[0])) chord.append(scale[0][synthIndex] + (12 * ((int)((scale[0].index(rootNote) + (x * 2)) / len(scale[0]))))) ### guitar if j % 16 == 0: # reinforces the key center randomNote = scale[0][0] - 12 else: # random note from the chord randomNote = random.choice(chord) - 12 if i == 0: if random.randint(0, 5) == 0: listNotes[0][0].append(randomNote + 12) else: listNotes[0][0].append(randomNote) listNotes[0][1].append(-1) listNotes[0][2].append(-1) listNotes[0][3].append(random.randint(0, 1)) listNotes[0][4].append(.125) else: # repeat the first rep for k in range(0, len(listNotes[0])): listNotes[0][k].append(listNotes[0][k][j]) ### synth # arpeggiates up and down the chord if not j % 4 == 3: listNotes[2][0].append(chord[j % 4]) else: listNotes[2][0].append(chord[len(chord) - 2]) listNotes[2][1].append(.125) ### bass # copies the guitar listNotes[1][0].append(listNotes[0][0][j] - 12) listNotes[1][1].append(.125) ### drums listNotes[3][0].append(scale[1][0]) if j % 4 == 2 and i == 0: # snare on 2 and 4 listNotes[3][1].append(scale[1][1]) elif j % 8 == 4 and i == 1: # snare on 3 listNotes[3][1].append(scale[1][1]) else: listNotes[3][1].append(-1) if j % 2 == 0: # cymbals on 1, 2, 3, and 4 listNotes[3][2].append(scale[1][2]) else: listNotes[3][2].append(-1) listNotes[3][3].append(.125) return listNotes