def genBasicIdea(prev_note = random.choice([0,2,4,7]), chords = [[0,2,4], [4,6,8], [0,2,4], [0,2,4]], motif1 = None, cell1 = None): if motif1 == None: motif1 = gm.genMotif(prev_note = prev_note, chords = chords[:2], cell1 = cell1) motif1_durs = fh.concat([i.durs for i in motif1]) if 2.0 in motif1_durs or motif1_durs == [1.0,1.0,1.0,1.0]: motif2 = gm.genMotif(prev_note=motif1[1].pits[-1], chords = chords[2:]) return Chunk(sub_chunks = motif1 + motif2, ctype='bi') else: motif2 = tf.transformMotif(transform_motif=motif1, prev_cell=motif1[0], chords=chords[2:]) return Chunk(sub_chunks = motif1 + motif2, ctype='bi')
def genPhrase( prev_note=random.randint(0, 4), chords=[[0, 2, 4], [0, 2, 4], [4, 6, 8], [0, 2, 4], [0, 2, 4], [3, 5, 7], [4, 6, 8], [0, 2, 4]], basicIdea=None, authentic_cadence=False, ): phrase_cells = [] if basicIdea == None: basicIdea = gb.genBasicIdea(prev_note=prev_note, chords=chords[:4], motif1=None) phrase_cells = basicIdea.cells # choose first or second motif of basic idea to transform for third motif which_motif_to_transform = random.choice([phrase_cells[:2], phrase_cells[2:]]) third_motif = tf.transformMotif(which_motif_to_transform, phrase_cells[-1], chords[4:6]) motif4cell1 = gc.genCell( 2.0, third_motif[-1].pits[-1], first_note=None, chord=chords[6], durs=rhy.getDefiningRhythm(phrase_cells + third_motif), ) motif4cell2 = genending.genEnding(motif4cell1.pits[-1], chords[-1], authentic_cadence) second_half = Chunk(sub_chunks=third_motif + [motif4cell1] + [motif4cell2], ctype="half") return Chunk(sub_chunks=[basicIdea, second_half], ctype="phrase")