def genPeriod(chords = default_chords, bi11 = None, real_end = False): if bi11 == None: bi11 = gbi.genBasicIdea(chords=chords[:4]) bi21 = gbi.genBasicIdea(prev_note = bi11.pits[-1], chords=chords[4:8]) bi21cells = bi21.cells bi21cells[-1] = genending.genEnding(bi21cells[-2].pits[-1], chord=chords[7], authentic=False) bi21 = Chunk(sub_chunks = bi21cells) bi12 = tf.alterBasicIdea(bi = bi11, prev_note = bi21.pits[-1], chords = chords[8:12]) bi22 = tf.alterBasicIdea(bi = bi21, prev_note = bi12.pits[-1], chords = chords[12:], cadence='authentic', real_end = real_end) return Chunk(sub_chunks=[Chunk(sub_chunks=[bi11,bi21]), Chunk(sub_chunks=[bi12, bi22])])
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")