def label_sections_in_treble_in_blue(treble, section_lengths): treble_sections = sequencetools.partition_by_lengths( treble[:], section_lengths, cyclic = True) for section_index, treble_section in enumerate(treble_sections): section_number = section_index + 1 if 1 < len(treble_section): treble_leaves = list(iterate.naive(treble_section, _Leaf)) bracket = Bracket(treble_leaves[1:]) bracket.staff_padding = 8 bracket.color = 'blue' bracket.dash_period = 2 bracket.dash_fraction = 0.25 section_markup = '\halign #0 \with-color #blue \circle { %s } " "' section_markup %= section_number bracket.bound_details__left__text = Markup(section_markup) bracket.bound_details__left__stencil_align_dir_y = 'center' else: first_note = treble_section[0][1] section_markup = '\with-color #blue \circle { %s } " "' section_markup %= section_number first_note.markup.up.append(section_markup) first_note.text.staff_padding = 8
def make_two_staff_unordered_cells_score(): cells = manifolds.etc.pitch.unordered_cells_sequence directions = manifolds.etc.pitch.segmentation_series harmonic_walk = sequencetools.flatten_sequence(manifolds.etc.pitch.harmonic_walk) score = Score([]) piano_staff = PianoStaff([]) score.append(piano_staff) treble = Staff([]) treble.accidental.style = "forget" treble.clef.forced = Clef("treble") bass = Staff([]) bass.accidental.style = "forget" bass.clef.forced = Clef("bass") piano_staff.append(treble) piano_staff.append(bass) duration = Fraction(1, 16) for cell_number, cell in enumerate(cells): measure = AnonymousMeasure([]) notes = [Note(pitch, duration) for pitch in cell] measure.extend(notes) rest_measure = clone.unspan([measure])[0] for i, note in enumerate(rest_measure): rest_measure[i] = Rest(note.duration.written) pitches = [note.pitch for note in notes] clef = pitchtools.suggest_clef(pitches) if clef == Clef("treble"): treble.append(measure) bass.append(rest_measure) else: treble.append(rest_measure) bass.append(measure) if 26 < max(cell): octavation = Octavation(measure[:]) octavation.start = 1 if directions[cell_number % 16] == -1: direction = "L" else: direction = "R" field_number = (cell_number + 6) % 8 + 1 center_pitch = harmonic_walk[cell_number % len(harmonic_walk)] chord = Chord(measure[0]) notehead = NoteHead(None, center_pitch) notehead.style = "harmonic" notehead.color = "blue" chord.append(notehead) first_leaf = treble[-1].leaves[0] first_leaf.markup.up.append(str(cell_number)) label = r"\line { %s%s \with-color #blue (%s) }" % (direction, field_number, center_pitch) first_leaf.markup.up.append(label) front, back = Fraction(1, 16), Fraction(1, 32) layout.insert_measure_padding(score, front, back) lengths = manifolds.etc.pitch.harmonic_walk_lengths parts = sequencetools.partition_by_lengths(treble[:], lengths, cyclic=True) for part in parts: if 1 < len(part): bracket = Bracket(part) bracket.staff_padding = None parts = sequencetools.partition_by_lengths(bass[:], lengths, cyclic=True) for part_number, part in enumerate(parts): label = r"\with-color #blue \circle{ %s }" % (part_number + 1) part[0][1].markup.down.append(label) layout.line_break_every_prolated(treble, Fraction(58, 16)) layout.line_break_every_prolated(bass, Fraction(58, 16)) staves = StaffAlignmentOffsets(0, -10) systems = SystemYOffsets(45, 5) positioning = FixedStaffPositioning(systems, staves) layout.apply_fixed_staff_positioning(treble, positioning) score.rest.transparent = True return score
def make_unordered_cells_score(): cells = manifolds.etc.pitch.unordered_cells_sequence directions = manifolds.etc.pitch.segmentation_series harmonic_walk = sequencetools.flatten_sequence(manifolds.etc.pitch.harmonic_walk) score = Score([]) staff = Staff([]) staff.accidental.style = 'forget' score.append(staff) duration = Fraction(1, 16) for cell_number, cell in enumerate(cells): measure = AnonymousMeasure([]) notes = [Note(pitch, duration) for pitch in cell] measure.extend(notes) pitches = [note.pitch for note in notes] clef = pitchtools.suggest_clef(pitches) measure.clef.forced = clef if 26 < max(cell): octavation = Octavation(measure[:]) octavation.start = 1 measure.formatter.number.self = 'comment' staff.append(measure) if directions[cell_number % 16] == -1: direction = 'L' else: direction = 'R' field_number = (cell_number + 6) % 8 + 1 center_pitch = harmonic_walk[cell_number % len(harmonic_walk)] chord = Chord(measure[0]) notehead = NoteHead(None, center_pitch) notehead.style = 'harmonic' notehead.color = 'blue' chord.append(notehead) first_leaf = measure.leaves[0] first_leaf.markup.up.append(str(cell_number)) label = r'\line { %s%s \with-color #blue (%s) }' % ( direction, field_number, center_pitch) first_leaf.markup.up.append(label) front, back = Fraction(1, 16), Fraction(1, 32) layout.insert_measure_padding(measure, front, back) lengths = manifolds.etc.pitch.harmonic_walk_lengths parts = sequencetools.partition_by_lengths(staff[:], lengths, cyclic = True) spacing_voice = Voice([]) for part_number, part in enumerate(parts): if 1 < len(part): bracket = Bracket(part) bracket.staff_padding = None skip = Skip((1, 16)) spacing_voice.append(skip) skip = Skip((1, 1)) skip.duration.multiplier = durationtools.sum_prolated(part) - Fraction(1, 16) spacing_voice.append(skip) label = r'\with-color #blue \circle { %s }' % (part_number + 1) skip.markup.down.append(label) spacing_voice.text.staff_padding = 4 Voice(staff[:]) staff.parallel = True staff.append(spacing_voice) lines = Fraction(58, 16) systems = SystemYOffsets(33, 7, 1) positioning = FixedStaffPositioning(systems) layout.line_break_every_prolated(staff, lines) layout.apply_fixed_staff_positioning(staff, positioning) score.rest.transparent = True return score