def apply_tempo_spanners(score): lengths = get_measures_per_reading() tempi = make_tempi() for staff in iterate.naive_forward_in(score, Staff): measures = list(iterate.measures_forward_in(staff)) readings = sequencetools.partition_by_lengths(measures, lengths, True, True) tempo_spanners = make_tempo_spanners() for reading, tempo_spanner in zip(readings, tempo_spanners): tempo_spanner.extend(reading) return score
def make_empty_measures(score): print('making empty measures ...') numerators, second_numerators = make_numerators() numerators = sequencetools.flatten_sequence(numerators) reading_lengths = get_measures_per_reading() #for staff in iterate.naive_forward_in(score, klass = Staff): for voice in score.music_voices: meter_tokens = [(numerator, 8) for numerator in numerators] measures = measuretools.make(meter_tokens) #staff.extend(measures) voice.extend(measures) return score
def add_double_bar_lines(score): measures_per_reading = get_measures_per_reading() #cello_staff = scoretools.find(score, 'Cello') #cello_measures = list(iterate.measures_forward_in(cello_staff)) #measure_groups = sequencetools.partition_by_lengths( # cello_measures, measures_per_reading) breaks_measures = list(abjad.iterate.measures_forward_in(score.breaks_voice)) measure_groups = abjad.sequencetools.partition_by_lengths( breaks_measures, measures_per_reading) # the -1 means to avoid add what would be the double bar prior prolungato for group in measure_groups[:-1]: last_measure = group[-1] last_measure.bar_line.kind = '||' return score
def get_active_measure_groups(score): reading_lengths = get_measures_per_reading() flute_staff = scoretools.find(score, "Flute") flute_measures = list(iterate.measures_forward_in(flute_staff)) flute_measure_groups = sequencetools.partition_by_lengths(flute_measures, reading_lengths) clarinet_staff = scoretools.find(score, "Clarinet") clarinet_measures = list(iterate.measures_forward_in(clarinet_staff)) clarinet_measure_groups = sequencetools.partition_by_lengths(clarinet_measures, reading_lengths) violin_staff = scoretools.find(score, "Violin") violin_measures = list(iterate.measures_forward_in(violin_staff)) violin_measure_groups = sequencetools.partition_by_lengths(violin_measures, reading_lengths) cello_staff = scoretools.find(score, "Cello") cello_measures = list(iterate.measures_forward_in(cello_staff)) cello_measure_groups = sequencetools.partition_by_lengths(cello_measures, reading_lengths) active_flute_measure_groups = [] active_flute_measure_groups.append(flute_measure_groups[1]) active_flute_measure_groups.append(flute_measure_groups[2]) active_flute_measure_groups.append(flute_measure_groups[3]) active_flute_measure_groups.append(flute_measure_groups[4]) active_clarinet_measure_groups = [] active_clarinet_measure_groups.append(clarinet_measure_groups[2]) active_clarinet_measure_groups.append(clarinet_measure_groups[3]) active_clarinet_measure_groups.append(clarinet_measure_groups[4]) active_clarinet_measure_groups.append(clarinet_measure_groups[5]) active_violin_measure_groups = [] active_violin_measure_groups.append(violin_measure_groups[0]) active_violin_measure_groups.append(violin_measure_groups[1]) active_violin_measure_groups.append(violin_measure_groups[2]) active_violin_measure_groups.append(violin_measure_groups[3]) active_cello_measure_groups = [] active_cello_measure_groups.append(cello_measure_groups[0]) active_cello_measure_groups.append(cello_measure_groups[3]) active_cello_measure_groups.append(cello_measure_groups[4]) active_cello_measure_groups.append(cello_measure_groups[5]) return ( active_flute_measure_groups, active_clarinet_measure_groups, active_violin_measure_groups, active_cello_measure_groups, )
def get_active_measures_by_section_index(score, section_index): # [13, 13, 11, 12, 10, 9] reading_lengths = get_measures_per_reading() start_stop_pairs = sequencetools.list_pairwise_cumulative_sums_zero(reading_lengths) fl = scoretools.find(score, 'Flute') cl = scoretools.find(score, 'Clarinet') vn = scoretools.find(score, 'Violin') vc = scoretools.find(score, 'Cello') staves = list(iterate.naive_forward_in(score, Staff)) start_stop_pair = start_stop_pairs[section_index] measure_lists = [] #for staff in staves: for music_voice in score.music_voices: #measures = list(iterate.measures_forward_in(staff, *start_stop_pair)) measures = list(iterate.measures_forward_in( music_voice, *start_stop_pair)) measures = [m for m in measures if getattr(m.history, 'active', False)] measure_lists.append(measures) return measure_lists