def harmonies(): hr = harmonic_rhythms() assert [len(x) for x in hr] == [41, 41, 41, 41] # 42 harmonies needed per part cello_harmonies = [ 9, 18, 15, 10, 17, 19, 1, 4, 7, 14, 18, 5, 8, 6] assert len(cello_harmonies) == 14 violin_harmonies = [ 12, 10, 8, 17, 6, 3, 8, 6, 3, 12, 10, 19, 17, 12, 17, 3, 19, 8, 6] assert len(violin_harmonies) == 19 flute_harmonies = [ 18, 15, 12, 5, 10, 8, 6, 15, 5, 10, 18, 12] assert len(flute_harmonies) == 12 clarinet_harmonies = [ 14, 2, 15, 12, 1, 16, 9, 7, 11, 18, 10, 14, 1, 16, 9, 18, 10, 2, 15, 12, 7, 11] assert len(clarinet_harmonies) == 22 harmonies = [ flute_harmonies, clarinet_harmonies, violin_harmonies, cello_harmonies] harmonies = [sequencetools.repeat_list_to_length(x, 41) for x in harmonies] return harmonies
def add_fleurs(score): print('adding fleurs ...') hh = harmonies() hr = harmonic_rhythms() assert [len(x) for x in hh] == [41, 41, 41, 41] assert [len(x) for x in hr] == [41, 41, 41, 41] for staff_index, staff in enumerate(score.instrument_staves): hr_eighths = hr[staff_index] hr_durations = [Fraction(n, 8) for n in hr_eighths] staff_harmony = hh[staff_index] staff_leaves = list(iterate.leaves_forward_in(staff)) leaf_runs = durationtools.group_prolated(staff_leaves, hr_durations, fill = 'greater', cyclic = False, overhang = True) offset = 0 fleur_ordinal = 0 for leaf_run, fleur_number in zip(leaf_runs, staff_harmony): add_fleur_to_leaf_run(leaf_run, fleur_number, offset, fleur_ordinal) offset += len(leaf_run) fleur_ordinal += 1