def make_mixed_segmented_fields_score(): score = Score([]) staff = Staff([]) staff.accidental.style = 'forget' score.append(staff) duration = Fraction(1, 16) for field in manifolds.etc.pitch.mixed_segmented_fields: for segment in field: measure = AnonymousMeasure([]) measure.denominator = 16 tuplet = FixedDurationTuplet((3, 8), []) measure.append(tuplet) if min(segment) <= -1: measure.clef.forced = Clef('bass') else: measure.clef.forced = Clef('treble') notes = [Note(x, duration) for x in segment] tuplet.extend(notes) if 31 < max(segment): spanner = Octavation(tuplet) spanner.start = 1 measure.insert(0, Rest((1, 16))) measure.append(Rest((1, 16))) staff.append(measure) measure.formatter.number.self = 'comment' measure.barline.kind = '||' measure.breaks.line = True measure.barline.kind = '|.' score.rest.transparent = True score.meter.break_visibility = Function('end-of-line-invisible') score.clef.break_visibility = Function('end-of-line-invisible') pitchtools.make_sharp(score) score.tupletnumber.stencil = False score.tupletbracket.stencil = False #indicator = FixedSystemsIndicator( # (0, 20, 40, 60, 80, 100, 120, 140, 160, 180, 200), 1) #layout.apply_fixed_systems_indicator(staff, indicator) staves = StaffAlignmentOffsets(0) systems = SystemYOffsets(20, 10, 1) positioning = FixedStaffPositioning(systems, staves) layout.apply_fixed_staff_positioning(staff, positioning) return score
def make_labeled_mixed_fields_score(): score = Score([]) segmentation_series = manifolds.etc.pitch.segmentation_series fields = manifolds.etc.pitch.mixed_segmented_fields duration = Fraction(1, 16) measures_per_line = 6 ## for eight *pairs of* fields for i in range(len(fields) / 2): ## for the first or second member of each pair for member in ('first', 'second'): ## find a sequence between 0 and 15, inclusive if member == 'first': field_sequence = i else: field_sequence = i + 8 ## find a field number between 1 and 8, inclusive field_number = (field_sequence + 6) % 8 + 1 ## find direction of segmentation if segmentation_series[field_sequence] == -1: direction = 'L' elif segmentation_series[field_sequence] == 1: direction = 'R' else: raise ValueError ## find name for first system name = Markup( r'\hcenter-in #12 \box \pad-markup #1 \bold { %s%s }' % ( direction, field_number)) ## find name for second system if direction == 'L': second_system_direction = 'R' else: second_system_direction = 'L' short_name = Markup( r'\hcenter-in #12 \box \pad-markup #1 \bold { %s%s }' % ( second_system_direction, field_number)) ## if first field in pair if member == 'first': ## set up a staff staff = Staff([]) staff.accidental.style = 'forget' staff.instrument.name = name staff.instrument.short_name = short_name score.append(staff) ## get field to lay out, from 0 to 15, inclusive field = fields[field_sequence] ## lay out field as a single line of music for segment_number, segment in enumerate(field): measure = AnonymousMeasure([]) measure.denominator = 16 # if segment_number == 0: # if member == 'second': # print name # directive = r'\set Staff.shortInstrumentName = %s' # directive %= name.format # measure.directives.before.append(directive) tuplet = FixedDurationTuplet((3, 8), []) measure.append(tuplet) if min(segment) <= -1: measure.clef.forced = Clef('bass') else: measure.clef.forced = Clef('treble') notes = [Note(x, duration) for x in segment] tuplet.extend(notes) if 31 < max(segment) < 36: spanner = Octavation(tuplet) spanner.start = 1 elif 36 <= max(segment): spanner = Octavation(tuplet) spanner.start = 2 measure.insert(0, Rest((1, 16))) measure.append(Rest((1, 16))) staff.append(measure) # segment_letter = chr(ord('a') + segment_number) # segment_id = r'\circle \pad-markup #0.25 { %s }' # segment_id %= segment_letter # tuplet.leaves[0].markup.up.append(segment_id) segment_center = float(sum(segment)) / len(segment) segment_center = round(segment_center, 1) if int(segment_center) == segment_center: markup = r'\bold { %s }' % int(segment_center) else: markup = r'\bold { %.1f }' % segment_center tuplet.leaves[0].markup.down.append(markup) extra_measure_count = measures_per_line - (segment_number + 1) for j in range(extra_measure_count): measure = AnonymousMeasure([]) measure.extend(construct.rests([(1, 16), (3, 8), (1, 16)])) measure.dots.transparent = True staff.append(measure) measure.barline.kind = '||' measure.breaks.line = True measure.barline.kind = '|.' score.rest.transparent = True score.meter.break_visibility = Function('end-of-line-invisible') #score.clef.break_visibility = Function('end-of-line-invisible') pitchtools.make_sharp(score) for i, measure in enumerate(iterate.naive(score, AnonymousMeasure)): measure.formatter.number.self = 'comment' if not i % 6 == 5: measure.breaks.whitespace = Fraction(1, 16) score.tupletnumber.stencil = False score.tupletbracket.stencil = False score[0][measures_per_line - 1].breaks.page = True alignment_offsets = [-25 * x for x in range(8)] score[0][0].breaks.x = 10 score[0][0].breaks.y = 30 score[0][0].breaks.alignment_offsets = alignment_offsets score[0][measures_per_line].breaks.x = 10 score[0][measures_per_line].breaks.y = 15 score[0][measures_per_line].breaks.alignment_offsets = alignment_offsets return score
def make_segmented_pitch_fields_score(bigger): duration = Fraction(1, 16) score = Score([]) score.append(PianoStaff([])) piano_staff = score[0] piano_staff.extend([Staff([]), Staff([])]) treble = piano_staff[0] bass = piano_staff[1] treble.clef.forced = Clef('treble') treble.accidental.style = 'forget' bass.clef.forced = Clef('bass') bass.accidental.style = 'forget' if bigger == 'left': segmented_pitch_fields = manifolds.etc.pitch.left_segmented_fields elif bigger == 'right': segmented_pitch_fields = manifolds.etc.pitch.right_segmented_fields else: raise ValueError for i, segmented_pitch_field in enumerate(segmented_pitch_fields): field_number = (i + 6) % 8 + 1 segment_number = 0 for segment in segmented_pitch_field: segment = Chord(segment, duration) treble_measure = AnonymousMeasure() bass_measure = AnonymousMeasure() treble_measure.denominator = 16 bass_measure.denominator = 16 for note in chordtools.arpeggiate(segment): t, b = chordtools.split(note) treble_measure.append(t) bass_measure.append(b) treble.append(treble_measure) bass.append(bass_measure) segment_letter = chr(ord('a') + segment_number) treble_measure.leaves[0].markup.up.append( r'\circle { %s-%s }' % (field_number, segment_letter)) segment_number += 1 treble_measure.breaks.line = True bass_measure.breaks.line = True score.rest.transparent = True score.meter.break_visibility = Function('end-of-line-invisible') pitchtools.make_sharp(score) label.leaf_pcs(score, color = True) score.text.staff_padding = 4 #indicator = FixedSystemsIndicator((0, 40, 80, 120), 1) #layout.apply_fixed_systems_indicator(treble, indicator) staves = StaffAlignmentOffsets(0, -12) systems = SystemYOffsets(40, 4, 1) positioning = FixedStaffPositioning(systems, staves) layout.apply_fixed_staff_positioning(treble, positioning) return score