Example #1
0
 def calc_anchor(self):
     durs = [self.leaf.written_duration, self.anchor_dur]
     container = abjad.Container()
     pre_mult = self.leaf.written_duration - self.anchor_dur
     mult = pre_mult / self.leaf.written_duration
     if isinstance(self.leaf, abjad.Chord):
         pitches = [
             abjad.NamedPitch(_) for _ in abjad.get.pitches(self.leaf)
         ]
     elif isinstance(self.leaf, abjad.Note):
         pitches = [
             abjad.NamedPitch(_) for _ in abjad.get.pitches(self.leaf)
         ]
         pitches = pitches[0]
     else:
         pass
     maker = abjad.LeafMaker()
     new_leaves = [list_ for list_ in maker([pitches], durs)]
     indicators = abjad.get.indicators(self.leaf)
     for indicator in indicators:
         abjad.attach(indicator, new_leaves[0][0])
     self.leaf.multiplier = mult
     abjad.attach(
         abjad.LilyPondLiteral(r"""\abjad-invisible-music""",
                               format_slot="before"),
         new_leaves[1],
     )
     abjad.annotate(new_leaves[1], "type", "spanner anchor")
     container.extend(new_leaves)
     return container
Example #2
0
    def __call__(self):
        """Return ``self.ready_staff``."""
        abjad_instrument = self.abjad_instrument
        staves = self.append_staves(self)
        self.append_voices(self, staves)
        staff_count = self.staff_count

        if staff_count == 1:
            abjad.annotate(staves[0], "default_instrument", abjad_instrument)
            self.ready_staff = staves[0]
        else:
            if abjad_instrument == abjad.Piano():
                staffgroup = abjad.StaffGroup(
                    lilypond_type="PianoStaff",
                    name="Piano_StaffGroup",
                    tag=self.tag,
                    simultaneous=True,
                )
                for staff in staves:
                    staffgroup.append(staff)

            else:
                staffgroup = abjad.StaffGroup(name=self.name, tag=self.tag)
                for staff in staves:
                    staffgroup.append(staff)

            abjad.annotate(staffgroup, "default_instrument", abjad_instrument)

            self.ready_staff = staffgroup

        return self.ready_staff
    def __call__(self):
        """
        Calls two-staff piano score template.

        Returns score.
        """
        import abjad
        tag = 'TwoStaffPianoScoreTemplate'
        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # RH STAFF
        rh_voice = abjad.Voice(
            name='RH_Voice',
            tag=tag,
        )
        rh_staff = abjad.Staff(
            [rh_voice],
            name='RH_Staff',
            tag=tag,
        )

        # LH STAFF
        lh_voice = abjad.Voice(
            name='LH_Voice',
            tag=tag,
        )
        lh_staff = abjad.Staff(
            [lh_voice],
            name='LH_Staff',
            tag=tag,
        )
        abjad.annotate(
            lh_staff,
            'default_clef',
            abjad.Clef('bass'),
        )

        # PIANO STAFF
        staff_group = abjad.StaffGroup(
            [rh_staff, lh_staff],
            lilypond_type='PianoStaff',
            name='Piano_Staff',
            tag=tag,
        )
        abjad.annotate(
            staff_group,
            'default_instrument',
            abjad.Piano(),
        )

        # SCORE
        score = abjad.Score(
            [global_context, staff_group],
            name='Two_Staff_Piano_Score',
            tag=tag,
        )
        return score
Example #4
0
    def __call__(
        self, q_events: typing.Sequence[QEvent]
    ) -> tuple[
        tuple[abjad.NamedPitch, ...],
        typing.Optional[tuple],
        typing.Optional[abjad.BeforeGraceContainer],
    ]:
        """
        Calls concatenating grace handler.
        """
        grace_events, final_event = q_events[:-1], q_events[-1]
        attachments: tuple | None
        if grace_events and self._replace_rest_with_final_grace_note:
            index = self._find_last_pitched_q_event(q_events)
            grace_events, final_event = q_events[:index], q_events[index]

        if isinstance(final_event, PitchedQEvent):
            # TODO: we are only supporting preserving attachments for PitchedQEvent
            pitches = final_event.pitches
            attachments = final_event.attachments
        else:
            pitches = ()
            attachments = None

        grace_events_list = list(grace_events)
        if self._discard_grace_rest:
            for q_event in grace_events_list:
                if isinstance(q_event, SilentQEvent):
                    grace_events_list.remove(q_event)
        grace_events = tuple(grace_events_list)

        grace_container: abjad.BeforeGraceContainer | None
        if grace_events:
            grace_container = abjad.BeforeGraceContainer()
            for q_event in grace_events:
                leaf: abjad.Leaf
                if isinstance(q_event, PitchedQEvent):
                    if len(q_event.pitches) == 1:
                        leaf = abjad.Note(q_event.pitches[0], self.grace_duration)
                    else:
                        leaf = abjad.Chord(q_event.pitches, self.grace_duration)
                else:
                    leaf = abjad.Rest(self.grace_duration)
                q_event_attachments = (
                    None if not hasattr(q_event, "attachments") else q_event.attachments
                )
                # assert hasattr(q_event, "attachments")
                # q_event_attachments = q_event.attachments
                if q_event_attachments is not None:
                    abjad.annotate(leaf, "q_event_attachments", q_event_attachments)
                grace_container.append(leaf)
        else:
            grace_container = None

        return tuple(pitches), attachments, grace_container
Example #5
0
 def _attach_attachments_to_logical_ties(
     self,
     voice: abjad.Voice,
     all_attachments: typing.Sequence[tuple | None],
 ):
     logical_tie_list = list(
         abjad.iterate.logical_ties(voice, grace=False, pitched=True))
     assert len(logical_tie_list) == len(all_attachments)
     for logical_tie, attachments in zip(logical_tie_list, all_attachments):
         first_leaf = abjad.get.leaf(logical_tie, 0)
         abjad.annotate(first_leaf, "q_event_attachments", attachments)
    def __call__(self):
        """
        Calls score template.

        Returns score.
        """
        import abjad

        staves = []
        tag = "abjad.GroupedRhythmicStavesScoreTemplate.__call__"
        if isinstance(self.staff_count, int):
            for index in range(self.staff_count):
                number = index + 1
                name = "Voice_{}".format(number)
                voice = abjad.Voice([], name=name, tag=tag)
                name = "Staff_{}".format(number)
                staff = abjad.Staff([voice], name=name, tag=tag)
                staff.lilypond_type = "RhythmicStaff"
                abjad.annotate(staff, "default_clef", abjad.Clef("percussion"))
                staves.append(staff)
                key = "v{}".format(number)
                self.voice_abbreviations[key] = voice.name
        elif isinstance(self.staff_count, list):
            for staff_index, voice_count in enumerate(self.staff_count):
                staff_number = staff_index + 1
                name = "Staff_{}".format(staff_number)
                staff = abjad.Staff(name=name, tag=tag)
                staff.lilypond_type = "RhythmicStaff"
                assert 1 <= voice_count
                for voice_index in range(voice_count):
                    voice_number = voice_index + 1
                    if voice_count == 1:
                        voice_identifier = str(staff_number)
                    else:
                        voice_identifier = "{}_{}".format(
                            staff_number, voice_number
                        )
                        staff.is_simultaneous = True
                    name = "Voice_{}".format(voice_identifier)
                    voice = abjad.Voice([], name=name, tag=tag)
                    staff.append(voice)
                    key = "v{}".format(voice_identifier)
                    self.voice_abbreviations[key] = voice.name
                staves.append(staff)
        grouped_rhythmic_staves_staff_group = abjad.StaffGroup(
            staves, name="Grouped_Rhythmic_Staves_Staff_Group", tag=tag
        )
        grouped_rhythmic_staves_score = abjad.Score(
            [grouped_rhythmic_staves_staff_group],
            name="Grouped_Rhythmic_Staves_Score",
            tag=tag,
        )
        return grouped_rhythmic_staves_score
Example #7
0
 def _notate_leaves(self,
                    grace_handler: GraceHandler,
                    voice: abjad.Voice | None = None) -> list[tuple | None]:
     all_q_event_attachments: list[tuple | None] = []
     for leaf in abjad.iterate.leaves(voice):
         if leaf._has_indicator(dict):
             annotation = leaf._get_indicator(dict)
             q_events = annotation["q_events"]
             pitches, attachments, grace_container = grace_handler(q_events)
             new_leaf: abjad.Leaf
             if not pitches:
                 new_leaf = abjad.Rest(leaf)
             elif 1 < len(pitches):
                 new_leaf = abjad.Chord(leaf)
                 new_leaf.written_pitches = pitches
             else:
                 new_leaf = abjad.Note(leaf)
                 new_leaf.written_pitch = pitches[0]
             if attachments is not None:
                 all_q_event_attachments.append(attachments)
             if grace_container:
                 abjad.attach(grace_container, new_leaf)
             abjad.mutate.replace(leaf, new_leaf)
             if not isinstance(new_leaf, abjad.Rest):
                 abjad.annotate(new_leaf, "tie_to_next", True)
             elif abjad.get.indicator(new_leaf, abjad.Tie):
                 abjad.detach(abjad.Tie, new_leaf)
         else:
             previous_leaf = abjad._iterlib._get_leaf(leaf, -1)
             if isinstance(previous_leaf, abjad.Rest):
                 new_leaf = type(previous_leaf)(leaf.written_duration)
             elif isinstance(previous_leaf, abjad.Note):
                 new_leaf = type(previous_leaf)(previous_leaf.written_pitch,
                                                leaf.written_duration)
             else:
                 new_leaf = type(previous_leaf)(
                     previous_leaf.written_pitches, leaf.written_duration)
             abjad.mutate.replace(leaf, new_leaf)
             if abjad.get.annotation(previous_leaf, "tie_to_next") is True:
                 leaves = [previous_leaf, new_leaf]
                 abjad.tie(leaves)
                 abjad.annotate(new_leaf, "tie_to_next", True)
         if leaf._has_indicator(abjad.MetronomeMark):
             tempo = leaf._get_indicator(abjad.MetronomeMark)
             abjad.detach(abjad.MetronomeMark, leaf)
             abjad.detach(abjad.MetronomeMark, new_leaf)
             abjad.attach(tempo, new_leaf)
         if leaf._has_indicator(abjad.TimeSignature):
             time_signature = leaf._get_indicator(abjad.TimeSignature)
             abjad.detach(abjad.TimeSignature, leaf)
             abjad.detach(abjad.TimeSignature, new_leaf)
             abjad.attach(time_signature, new_leaf)
     return all_q_event_attachments
    def __call__(self):
        name = self.instrument.instrument_name.title()
        short_name = self.instrument.short_instrument_name.title()

        bowing_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Bowing Rhythm')

        string_space_staff = abjad.scoretools.Staff(
            [],
            context_name='StringSpaceStaff',
            is_simultaneous=True,
            name='String Space')

        fingering_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Fingering Rhythm')

        # combine

        staff_list = [
            bowing_rhythm_staff, string_space_staff, fingering_rhythm_staff
        ]

        for staff in staff_list:
            abjad.annotate(staff, 'instrument', name)

        abjad.setting(string_space_staff).instrument_name = abjad.Markup(name)
        abjad.setting(string_space_staff).instrument_name = \
            abjad.Markup(short_name)

        instrument_staff_group = abjad.scoretools.StaffGroup(
            staff_list,
            context_name='BowedStringInstrumentStaffGroup',
            name=name + ' Staff Group')

        # set stem direction

        abjad.override(bowing_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')

        abjad.override(fingering_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('DOWN')

        # Bar Line visibility
        abjad.override(bowing_rhythm_staff).bar_line.transparent = True
        abjad.override(fingering_rhythm_staff).bar_line.transparent = True

        # set padding

        override.staff_space_after(bowing_rhythm_staff, 2)
        override.staff_space_after(string_space_staff, 2)
        override.staff_space_after(fingering_rhythm_staff, 10)

        return instrument_staff_group
Example #9
0
    def __call__(self):
        """
        Calls score template.

        Returns score.
        """
        import abjad
        staves = []
        tag = 'GroupedRhythmicStavesScoreTemplate'
        if isinstance(self.staff_count, int):
            for index in range(self.staff_count):
                number = index + 1
                name = 'Voice_{}'.format(number)
                voice = abjad.Voice([], name=name, tag=tag)
                name = 'Staff_{}'.format(number)
                staff = abjad.Staff([voice], name=name, tag=tag)
                staff.lilypond_type = 'RhythmicStaff'
                abjad.annotate(staff, 'default_clef', abjad.Clef('percussion'))
                staves.append(staff)
                key = 'v{}'.format(number)
                self.voice_abbreviations[key] = voice.name
        elif isinstance(self.staff_count, list):
            for staff_index, voice_count in enumerate(self.staff_count):
                staff_number = staff_index + 1
                name = 'Staff_{}'.format(staff_number)
                staff = abjad.Staff(name=name, tag=tag)
                staff.lilypond_type = 'RhythmicStaff'
                assert 1 <= voice_count
                for voice_index in range(voice_count):
                    voice_number = voice_index + 1
                    if voice_count == 1:
                        voice_identifier = str(staff_number)
                    else:
                        voice_identifier = '{}_{}'.format(
                            staff_number, voice_number)
                        staff.is_simultaneous = True
                    name = 'Voice_{}'.format(voice_identifier)
                    voice = abjad.Voice([], name=name, tag=tag)
                    staff.append(voice)
                    key = 'v{}'.format(voice_identifier)
                    self.voice_abbreviations[key] = voice.name
                staves.append(staff)
        grouped_rhythmic_staves_staff_group = abjad.StaffGroup(
            staves,
            name='Grouped_Rhythmic_Staves_Staff_Group',
            tag=tag,
        )
        grouped_rhythmic_staves_score = abjad.Score(
            [grouped_rhythmic_staves_staff_group],
            name='Grouped_Rhythmic_Staves_Score',
            tag=tag,
        )
        return grouped_rhythmic_staves_score
Example #10
0
    def __call__(self):
        """
        Calls score template.

        Returns score.
        """
        import abjad

        staves = []
        site = "abjad.GroupedRhythmicStavesScoreTemplate.__call__()"
        tag = Tag(site)
        if isinstance(self.staff_count, int):
            for index in range(self.staff_count):
                number = index + 1
                name = "Voice_{}".format(number)
                voice = abjad.Voice([], name=name, tag=tag)
                name = "Staff_{}".format(number)
                staff = abjad.Staff([voice], name=name, tag=tag)
                staff.lilypond_type = "RhythmicStaff"
                abjad.annotate(staff, "default_clef", abjad.Clef("percussion"))
                staves.append(staff)
                key = "v{}".format(number)
                self.voice_abbreviations[key] = voice.name
        elif isinstance(self.staff_count, list):
            for staff_index, voice_count in enumerate(self.staff_count):
                staff_number = staff_index + 1
                name = "Staff_{}".format(staff_number)
                staff = abjad.Staff(name=name, tag=tag)
                staff.lilypond_type = "RhythmicStaff"
                assert 1 <= voice_count
                for voice_index in range(voice_count):
                    voice_number = voice_index + 1
                    if voice_count == 1:
                        voice_identifier = str(staff_number)
                    else:
                        voice_identifier = "{}_{}".format(staff_number, voice_number)
                        staff.simultaneous = True
                    name = "Voice_{}".format(voice_identifier)
                    voice = abjad.Voice([], name=name, tag=tag)
                    staff.append(voice)
                    key = "v{}".format(voice_identifier)
                    self.voice_abbreviations[key] = voice.name
                staves.append(staff)
        grouped_rhythmic_staves_staff_group = abjad.StaffGroup(
            staves, name="Grouped_Rhythmic_Staves_Staff_Group", tag=tag
        )
        grouped_rhythmic_staves_score = abjad.Score(
            [grouped_rhythmic_staves_staff_group],
            name="Grouped_Rhythmic_Staves_Score",
            tag=tag,
        )
        return grouped_rhythmic_staves_score
Example #11
0
 def _notate_leaves(self, grace_handler=None, voice=None):
     for leaf in abjad.iterate(voice).leaves():
         if leaf._has_indicator(dict):
             annotation = leaf._get_indicator(dict)
             q_events = annotation["q_events"]
             pitches, grace_container = grace_handler(q_events)
             if not pitches:
                 new_leaf = abjad.Rest(leaf)
             elif 1 < len(pitches):
                 new_leaf = abjad.Chord(leaf)
                 new_leaf.written_pitches = pitches
             else:
                 new_leaf = abjad.Note(leaf)
                 new_leaf.written_pitch = pitches[0]
             if grace_container:
                 abjad.attach(grace_container, new_leaf)
             abjad.mutate.replace(leaf, new_leaf)
             if not isinstance(new_leaf, abjad.Rest):
                 abjad.annotate(new_leaf, "tie_to_next", True)
         else:
             previous_leaf = abjad._iterate._get_leaf(leaf, -1)
             if isinstance(previous_leaf, abjad.Rest):
                 new_leaf = type(previous_leaf)(leaf.written_duration)
             elif isinstance(previous_leaf, abjad.Note):
                 new_leaf = type(previous_leaf)(previous_leaf.written_pitch,
                                                leaf.written_duration)
             else:
                 new_leaf = type(previous_leaf)(previous_leaf.written_pitch,
                                                leaf.written_duration)
             abjad.mutate.replace(leaf, new_leaf)
             if abjad.get.annotation(previous_leaf, "tie_to_next") is True:
                 leaves = abjad.select([previous_leaf, new_leaf])
                 abjad.tie(leaves)
                 abjad.annotate(new_leaf, "tie_to_next", True)
         if leaf._has_indicator(abjad.MetronomeMark):
             tempo = leaf._get_indicator(abjad.MetronomeMark)
             abjad.detach(abjad.MetronomeMark, leaf)
             abjad.detach(abjad.MetronomeMark, new_leaf)
             abjad.attach(tempo, new_leaf)
         if leaf._has_indicator(abjad.TimeSignature):
             time_signature = leaf._get_indicator(abjad.TimeSignature)
             abjad.detach(abjad.TimeSignature, leaf)
             abjad.detach(abjad.TimeSignature, new_leaf)
             abjad.attach(time_signature, new_leaf)
Example #12
0
def _make_staves(
    name,
    staff_specifiers,
    default_instrument,
    default_margin_markup,
    default_clef=None,
):
    tag = baca.site(inspect.currentframe())
    assert default_margin_markup is not None
    staves = []
    if not bool(staff_specifiers):
        return staves
    assert isinstance(staff_specifiers, list), repr(staff_specifiers)
    for staff_specifier in staff_specifiers:
        assert isinstance(staff_specifier, tuple), repr(staff_specifier)
        assert len(staff_specifier) == 2, repr(staff_specifier)
        staff_number, voices = staff_specifier
        assert isinstance(staff_number, int), repr(staff_number)
        assert isinstance(voices, list), repr(voices)
        if len(voices) == 1:
            simultaneous = False
        else:
            simultaneous = True
        staff = abjad.Staff(
            simultaneous=simultaneous,
            name=f"{name}.Staff.{staff_number}",
            tag=tag,
        )
        for voice_number in voices:
            voice = abjad.Voice(name=f"{name}.Voice.{voice_number}", tag=tag)
            staff.append(voice)
        abjad.annotate(staff, "default_instrument", default_instrument)
        abjad.annotate(staff, "default_margin_markup", default_margin_markup)
        if default_clef is not None:
            abjad.annotate(staff, "default_clef", default_clef)
        staves.append(staff)
    return staves
Example #13
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        # GLOBAL CONTEXT
        global_context = abjad.Voice(name="Global_Context")
        global_context_ii = abjad.Voice(name="Global_Context_II")
        global_context_iii = abjad.Voice(name="Global_Context_III")

        # RH STAFF
        rh_voice_one = abjad.Voice(name="RH_Voice_One")
        # command = abjad.LilyPondLiteral(r"\voiceOne")
        # abjad.attach(command, rh_voice_one)
        # abjad.override(rh_voice_one).stem.direction = abjad.Up
        # abjad.override(rh_voice_one).tie.direction = abjad.Up
        rh_voice_two = abjad.Voice(name="RH_Voice_Two")
        # command = abjad.LilyPondLiteral(r"\voiceTwo")
        # abjad.attach(command, rh_voice_two)
        # abjad.override(rh_voice_two).stem.direction = abjad.Down
        # abjad.override(rh_voice_two).tie.direction = abjad.Down
        rh_voice_three = abjad.Voice(name="RH_Voice_Three")
        # command = abjad.LilyPondLiteral(r"\voiceThree")
        # abjad.attach(command, rh_voice_three)
        # abjad.override(rh_voice_three).stem.direction = abjad.Down
        # abjad.override(rh_voice_three).tie.direction = abjad.Down
        rh_staff = abjad.Staff(
            [global_context, rh_voice_one, rh_voice_two, rh_voice_three],
            name="RH_Staff")
        rh_staff.simultaneous = True

        # LH STAFF
        lh_voice_one = abjad.Voice(name="LH_Voice_Four")
        lh_voice_two = abjad.Voice(name="LH_Voice_Five")
        lh_staff = abjad.Staff([global_context_ii, lh_voice_one, lh_voice_two],
                               name="LH_Staff")
        lh_staff.simultaneous = True

        # ORGAN STAFF
        piano_group = abjad.StaffGroup(
            [rh_staff, lh_staff],
            lilypond_type="PianoStaff",
            name="Piano_Staff",
        )
        abjad.annotate(piano_group, "default_instrument", abjad.Piano())
        instrumentName_piano = abjad.LilyPondLiteral(
            r"\set PianoStaff.instrumentName = \markup{Organ}")
        abjad.attach(instrumentName_piano, piano_group)

        # ELECTRONICS
        # ELECTRONICS RH STAFF
        voice_one_elec = abjad.Voice(name="RH_Voice_One_Electronics")
        electronics = abjad.Staff([global_context_iii, voice_one_elec],
                                  name="Electronics_Staff")
        electronics.simultaneous = True

        abjad.annotate(electronics, "default_instrument", abjad.Piano())
        instrumentName_electronics = abjad.LilyPondLiteral(
            r"\set Staff.instrumentName = \markup{Electronics}")
        abjad.attach(instrumentName_electronics, electronics)

        # SCORE
        score = abjad.Score(
            [piano_group, electronics],
            name="Score",
        )
        # abjad.override(score).script.padding = 1.1
        # abjad.override(score).spacing_spanner.strict_grace_spacing = True
        # abjad.override(score).spacing_spanner.strict_note_spacing = True
        # abjad.override(score).spacing_spanner.uniform_stretching = True
        # abjad.override(score).stem.length = 8
        # abjad.override(score).text_script.outside_staff_padding = 1
        # abjad.override(score).tuplet_bracket.bracket_visibility = True
        # abjad.override(score).tuplet_bracket.minimum_length = 3
        # abjad.override(score).tuplet_bracket.outside_staff_padding = 1.5
        # abjad.override(score).tuplet_bracket.padding = 1.5
        # abjad.override(score).tuplet_bracket.springs_and_rods = \
        #     abjad.scheme.Scheme('ly:spanner::set-spacing-rods', verbatim=True)
        # abjad.override(score).tuplet_bracket.staff_padding = 2.25
        # abjad.override(score).tuplet_number.text = \
        #     abjad.scheme.Scheme(
        #         'tuplet-number::calc-fraction-text', verbatim=True)
        # abjad.setting(score).proportional_notation_duration = \
        #     abjad.scheme.SchemeMoment((1, 24))
        # abjad.setting(score).tuplet_full_length = True

        return score
    def __call__(self):
        picking_rhythm_staff = abjad.scoretools.Staff(
            [],
            context_name='RhythmStaff',
            name='Picking Rhythm'
        )

        picking_staff = abjad.scoretools.Staff(
            [],
            context_name='PickingStaff',
            name='Picking'
        )

        fretting_staff = abjad.scoretools.Staff(
            [],
            context_name='FrettingStaff',
            is_simultaneous=True,
            name='Fretting'
        )

        fretting_rhythm_staff = abjad.scoretools.Staff(
            [],
            context_name='RhythmStaff',
            name='Fretting Rhythm'
        )

        name = self.instrument.instrument_name.title()
        if name[-1] == 'i':
            name = name[0:-1] + 'I'

        subgroup = abjad.StaffGroup(
            [picking_staff, fretting_staff],
            context_name='StaffSubgroup',
            name=name + ' Staff Subgroup'
        )

        staff_list = [
            picking_rhythm_staff,
            subgroup,
            fretting_rhythm_staff,
        ]

        instrument_staff_group = abjad.scoretools.StaffGroup(
            staff_list,
            context_name='GuitarStaffGroup',
            name=name + ' Staff Group'
        )

        # Naming

        abjad.setting(picking_staff).instrument_name = abjad.Markup('Picking')

        abjad.setting(picking_staff).short_instrument_name = \
            abjad.Markup('Picking')

        abjad.setting(fretting_staff).instrument_name = \
            abjad.Markup('Fretting')

        abjad.setting(fretting_staff).short_instrument_name = \
            abjad.Markup('Fretting')

        abjad.annotate(staff_list[0], 'instrument', name)
        abjad.annotate(staff_list[1][0], 'instrument', name)
        abjad.annotate(staff_list[1][1], 'instrument', name)
        abjad.annotate(staff_list[2], 'instrument', name)

        # Stem direction

        abjad.override(picking_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')

        abjad.override(fretting_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('DOWN')

        # Bar Line visibility
        abjad.override(picking_rhythm_staff).bar_line.transparent = True
        abjad.override(fretting_rhythm_staff).bar_line.transparent = True

        # Padding
        override.staff_space_after(picking_rhythm_staff, 2)
        override.staff_space_after(picking_staff, 4)
        override.staff_space_after(fretting_staff, 2)
        override.staff_space_after(fretting_rhythm_staff, 10)

        return instrument_staff_group
Example #15
0
    def handle_orphaned_q_event_proxies(self, last_leaf, q_event_proxies):
        r"""
        Embeds orphaned ``QEvents`` into an ``AfterGraceContainer`` and
        attaches it to the last leaf.

        ..  container:: example

            >>> durations = [1000, 1000, 1000, 400, 50, 50]
            >>> pitches = range(len(durations))
            >>> quantizer = nauert.Quantizer()
            >>> q_event_sequence = nauert.QEventSequence.from_millisecond_pitch_pairs(
            ...     tuple(zip(durations, pitches))
            ... )
            >>> search_tree = nauert.UnweightedSearchTree()
            >>> attack_point_optimizer = nauert.MeasurewiseAttackPointOptimizer()
            >>> q_schema = nauert.MeasurewiseQSchema(
            ...     search_tree=search_tree, time_signature=(7, 8), use_full_measure=True
            ... )
            >>> result = quantizer(
            ...     q_event_sequence,
            ...     q_schema=q_schema,
            ...     attach_tempos=True,
            ...     attack_point_optimizer=attack_point_optimizer,
            ... )
            >>> staff = abjad.Staff([result])
            >>> abjad.show(staff) # doctest: +SKIP

            ..  docs::

                >>> string = abjad.lilypond(staff)
                >>> print(string)
                \new Staff
                {
                    \new Voice
                    {
                        {
                            \tempo 4=60
                            \time 7/8
                            c'4
                            cs'8
                            ~
                            cs'8
                            d'8
                            ~
                            d'8
                            \afterGrace
                            ef'8
                            {
                                e'16
                                f'16
                            }
                        }
                    }
                }

        """
        grace_container = abjad.AfterGraceContainer() if q_event_proxies else None
        for proxy in q_event_proxies:
            q_event = proxy.q_event
            if isinstance(q_event, PitchedQEvent):
                if len(q_event.pitches) == 1:
                    leaf = abjad.Note(q_event.pitches[0], self.grace_duration)
                else:
                    leaf = abjad.Chord(q_event.pitches, self.grace_duration)
                abjad.annotate(leaf, "q_event_attachments", q_event.attachments)
                assert grace_container is not None
                grace_container.append(leaf)
        if grace_container:  # TODO: check if the grace_container is empty?
            abjad.attach(grace_container, last_leaf)
Example #16
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        site = "rill.ScoreTemplate.__call__()"
        tag = abjad.Tag(site)

        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # Violin
        markup_voice = abjad.Voice(name="Violin_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Violin_Dynamics_Voice", tag=tag)
        violin_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Violin",
            tag=tag,
        )
        abjad.annotate(
            violin_staff,
            "default_instrument",
            rill.instruments["Violin"],
        )
        abjad.annotate(violin_staff, "default_clef", abjad.Clef("treble"))

        # MonoSynth
        markup_voice = abjad.Voice(name="MonoSynth_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="MonoSynth_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="MonoSynth_Dynamics_Voice", tag=tag)
        monosynth_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="MonoSynth",
            tag=tag,
        )
        abjad.annotate(
            monosynth_staff,
            "default_instrument",
            rill.instruments["MonoSynth"],
        )
        abjad.annotate(monosynth_staff, "default_clef", abjad.Clef("treble"))

        ### RH PolySynth Voices ###
        markup_voice = abjad.Voice(name="RH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="RH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="RH_I_Dynamics_Voice", tag=tag)

        #        rh_voice_2 = abjad.Voice(
        #            lilypond_type="RHVoiceII", name="RH_II_Music_Voice", tag=tag
        #            )

        # RH PolySynth Staff
        polysynth_music_rh_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            lilypond_type="PolySynthRHStaff",
            simultaneous=True,
            name="PolySynth_Music_RH_Staff",
            tag=tag,
        )
        abjad.annotate(polysynth_music_rh_staff, "default_clef",
                       abjad.Clef("treble"))

        ### LH PolySynth Voices ###
        markup_voice = abjad.Voice(name="LH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="LH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="LH_I_Dynamics_Voice", tag=tag)
        #        lh_voice_2 = abjad.Voice(
        #            lilypond_type="LHVoiceII", name="LH_II_Music_Voice", tag=tag
        #        )
        #

        # LH PolySynth Staff
        polysynth_music_lh_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            lilypond_type="PolySynthLHStaff",
            simultaneous=True,
            name="PolySynth_Music_LH_Staff",
            tag=tag,
        )
        abjad.annotate(polysynth_music_lh_staff, "default_clef",
                       abjad.Clef("bass"))

        # PolySynth Staff Group
        polysynth_music_staff_group = abjad.StaffGroup(
            [polysynth_music_rh_staff, polysynth_music_lh_staff],
            lilypond_type="PolySynthMusicStaffGroup",
            name="PolySynth_Music_Staff_Group",
            tag=tag,
        )
        polysynth = rill.instruments["PolySynth"]
        abjad.annotate(polysynth_music_staff_group, "default_insrument",
                       polysynth)

        # PolySynth Music Context
        polysynth_music_context = abjad.Context([polysynth_music_staff_group],
                                                lilypond_type="MusicContext",
                                                name="PolySynth_Music_Context",
                                                tag=tag)

        # Music Context
        music_context = abjad.Context(
            [
                violin_staff,
                monosynth_staff,
                polysynth_music_context,
            ],
            lilypond_type="MusicContext",
            simultaneous=True,
            name="Music_Context",
            tag=tag,
        )

        # Score
        score = abjad.Score([global_context, music_context],
                            name="Score",
                            tag=tag)
        return score
Example #17
0
    def __call__(self):
        """
        Calls score template.

        Returns score.
        """

        # GLOBAL CONTEXT
        global_context = self._make_global_context()
        #part_names = [_[0] for _ in ScoreTemplate.part_names]
        part_names = [_.name for _ in self.part_manifest.parts]
        tag_string = '.'.join(part_names)
        self._attach_lilypond_tag(tag_string, global_context)

        # BASS CLARINET
        bass_clarinet_music_voice = abjad.Voice(
            lilypond_type='BassClarinetMusicVoice',
            name='BassClarinetMusicVoice',
            )
        bass_clarinet_music_staff = abjad.Staff(
            [bass_clarinet_music_voice],
            lilypond_type='BassClarinetMusicStaff',
            name='BassClarinetMusicStaff',
            )
        abjad.annotate(
            bass_clarinet_music_staff,
            'default_instrument',
            green_score.instruments['BassClarinet'],
            )
        abjad.annotate(
            bass_clarinet_music_staff,
            'default_clef',
            abjad.Clef('treble'),
            )
        self._attach_lilypond_tag('BassClarinet', bass_clarinet_music_staff)

        # VIOLIN
        violin_rh_music_voice = abjad.Voice(
            lilypond_type='ViolinRHMusicVoice',
            name='ViolinRHMusicVoice',
            )
        violin_rh_music_staff = abjad.Staff(
            [violin_rh_music_voice],
            lilypond_type='ViolinRHMusicStaff',
            name='ViolinRHMusicStaff',
            )
        abjad.annotate(
            violin_rh_music_staff,
            'REMOVE_ALL_EMPTY_STAVES',
            True,
            )
        abjad.annotate(
            violin_rh_music_staff,
            'default_clef',
            abjad.Clef('percussion'),
            )
        violin_music_voice = abjad.Voice(
            lilypond_type='ViolinMusicVoice',
            name='ViolinMusicVoice',
            )
        violin_music_staff = abjad.Staff(
            [violin_music_voice],
            lilypond_type='ViolinMusicStaff',
            name='ViolinMusicStaff',
            )
        abjad.annotate(
            violin_music_staff,
            'default_clef',
            abjad.Clef('treble'),
            )
        violin_staff_group = abjad.StaffGroup(
            [violin_rh_music_staff, violin_music_staff],
            lilypond_type='ViolinStaffGroup',
            name='ViolinStaffGroup',
            )
        abjad.annotate(
            violin_staff_group,
            'default_instrument',
            green_score.instruments['Violin'],
            )
        self._attach_lilypond_tag('Violin', violin_staff_group)

        # VIOLA
        viola_rh_music_voice = abjad.Voice(
            lilypond_type='ViolaRHMusicVoice',
            name='ViolaRHMusicVoice',
            )
        viola_rh_music_staff = abjad.Staff(
            [viola_rh_music_voice],
            lilypond_type='ViolaRHMusicStaff',
            name='ViolaRHMusicStaff',
            )
        abjad.annotate(
            viola_rh_music_staff,
            'REMOVE_ALL_EMPTY_STAVES',
            True,
            )
        abjad.annotate(
            viola_rh_music_staff,
            'default_clef',
            abjad.Clef('percussion'),
            )
        viola_music_voice = abjad.Voice(
            lilypond_type='ViolaMusicVoice',
            name='ViolaMusicVoice',
            )
        viola_music_staff = abjad.Staff(
            [viola_music_voice],
            lilypond_type='ViolaMusicStaff',
            name='ViolaMusicStaff',
            )
        abjad.annotate(
            viola_music_staff,
            'default_clef',
            abjad.Clef('alto'),
            )
        viola_staff_group = abjad.StaffGroup(
            [viola_rh_music_staff, viola_music_staff],
            lilypond_type='ViolaStaffGroup',
            name='ViolaStaffGroup',
            )
        abjad.annotate(
            viola_staff_group,
            'default_instrument',
            green_score.instruments['Viola'],
            )
        self._attach_lilypond_tag('Viola', viola_staff_group)

        # CELLO
        cello_rh_music_voice = abjad.Voice(
            lilypond_type='CelloRHMusicVoice',
            name='CelloRHMusicVoice',
            )
        cello_rh_music_staff = abjad.Staff(
            [cello_rh_music_voice],
            lilypond_type='CelloRHMusicStaff',
            name='CelloRHMusicStaff',
            )
        abjad.annotate(
            cello_rh_music_staff,
            'REMOVE_ALL_EMPTY_STAVES',
            True,
            )
        abjad.annotate(
            cello_rh_music_staff,
            'default_clef',
            abjad.Clef('percussion'),
            )
        cello_music_voice = abjad.Voice(
            lilypond_type='CelloMusicVoice',
            name='CelloMusicVoice',
            )
        cello_music_staff = abjad.Staff(
            [cello_music_voice],
            lilypond_type='CelloMusicStaff',
            name='CelloMusicStaff',
            )
        cello_staff_group = abjad.StaffGroup(
            [cello_rh_music_staff, cello_music_staff],
            lilypond_type='CelloStaffGroup',
            name='CelloStaffGroup',
            )
        abjad.annotate(
            cello_staff_group,
            'default_instrument',
            green_score.instruments['Cello'],
            )
        abjad.annotate(
            cello_staff_group,
            'default_clef',
            abjad.Clef('bass'),
            )
        self._attach_lilypond_tag('Cello', cello_staff_group)

        # ENSEMBLE STAFF GROUP
        ensemble_staff_group = abjad.StaffGroup(
            [
                bass_clarinet_music_staff,
                violin_staff_group,
                viola_staff_group,
                cello_staff_group,
                ],
            lilypond_type='EnsembleStaffGroup',
            name='EnsembleStaffGroup',
            )

        # MUSIC CONTEXT
        music_context = abjad.Context(
            [ensemble_staff_group],
            lilypond_type='MusicContext',
            name='MusicContext',
            )

        # SCORE
        score = abjad.Score(
            [global_context, music_context],
            name='Score',
            )
        self._assert_lilypond_identifiers(score)
        self._assert_unique_context_names(score)
        self._assert_matching_custom_context_names(score)
        return score
Example #18
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        tag = "krummzeit.ScoreTemplate.__call__"

        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # OBOE
        oboe_music_voice = abjad.Voice(name="Oboe_Music_Voice", tag=tag)
        oboe_music_staff = abjad.Staff(
            [oboe_music_voice], name="Oboe_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Oboe", oboe_music_staff)
        abjad.annotate(
            oboe_music_staff,
            "default_instrument",
            krummzeit.instruments["Oboe"],
        )
        abjad.annotate(oboe_music_staff, "default_clef", abjad.Clef("treble"))

        # CLARINET
        clarinet_music_voice = abjad.Voice(
            name="Clarinet_Music_Voice", tag=tag
        )
        clarinet_music_staff = abjad.Staff(
            [clarinet_music_voice], name="Clarinet_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Clarinet", clarinet_music_staff)
        abjad.annotate(
            clarinet_music_staff,
            "default_instrument",
            krummzeit.instruments["BassClarinet"],
        )
        abjad.annotate(
            clarinet_music_staff, "default_clef", abjad.Clef("treble")
        )

        # WIND SECTION
        wind_section_staff_group = abjad.StaffGroup(
            [oboe_music_staff, clarinet_music_staff],
            lilypond_type="WindSectionStaffGroup",
            name="Wind_Section_Staff_Group",
            tag=tag,
        )

        # PIANO
        piano_music_voice = abjad.Voice(name="Piano_Music_Voice", tag=tag)
        piano_music_staff = abjad.Staff(
            [piano_music_voice], name="Piano_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Piano", piano_music_staff)
        abjad.annotate(
            piano_music_staff,
            "default_instrument",
            krummzeit.instruments["Piano"],
        )
        abjad.annotate(piano_music_staff, "default_clef", abjad.Clef("treble"))

        # PERCUSSION
        percussion_music_voice = abjad.Voice(
            name="Percussion_Music_Voice", tag=tag
        )
        percussion_music_staff = abjad.Staff(
            [percussion_music_voice], name="Percussion_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Percussion", percussion_music_staff)
        abjad.annotate(
            percussion_music_staff,
            "default_instrument",
            krummzeit.instruments["Xylophone"],
        )
        abjad.annotate(
            percussion_music_staff, "default_clef", abjad.Clef("treble")
        )

        # PERCUSSION SECTION
        percussion_section_staff_group = abjad.StaffGroup(
            [piano_music_staff, percussion_music_staff],
            lilypond_type="PercussionSectionStaffGroup",
            name="Percussion_Section_Staff_Group",
            tag=tag,
        )

        # VIOLIN
        violin_music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag)
        violin_music_staff = abjad.Staff(
            [violin_music_voice], name="Violin_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Violin", violin_music_staff)
        abjad.annotate(
            violin_music_staff,
            "default_instrument",
            krummzeit.instruments["Violin"],
        )
        abjad.annotate(
            violin_music_staff, "default_clef", abjad.Clef("treble")
        )

        # VIOLA
        viola_music_voice = abjad.Voice(name="Viola_Music_Voice", tag=tag)
        viola_music_staff = abjad.Staff(
            [viola_music_voice], name="Viola_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Viola", viola_music_staff)
        abjad.annotate(
            viola_music_staff,
            "default_instrument",
            krummzeit.instruments["Viola"],
        )
        abjad.annotate(viola_music_staff, "default_clef", abjad.Clef("alto"))

        # CELLO
        cello_music_voice = abjad.Voice(name="Cello_Music_Voice", tag=tag)
        cello_music_staff = abjad.Staff(
            [cello_music_voice], name="Cello_Music_Staff", tag=tag
        )
        self._attach_lilypond_tag("Cello", cello_music_staff)
        abjad.annotate(
            cello_music_staff,
            "default_instrument",
            krummzeit.instruments["Cello"],
        )
        abjad.annotate(cello_music_staff, "default_clef", abjad.Clef("bass"))

        # STRING SECTION
        string_section_staff_group = abjad.StaffGroup(
            [violin_music_staff, viola_music_staff, cello_music_staff],
            lilypond_type="StringSectionStaffGroup",
            name="String_Section_Staff_Group",
            tag=tag,
        )

        # MUSIC CONTEXT
        music_context = abjad.Context(
            [
                wind_section_staff_group,
                percussion_section_staff_group,
                string_section_staff_group,
            ],
            lilypond_type="MusicContext",
            is_simultaneous=True,
            name="Music_Context",
            tag=tag,
        )

        # SCORE
        score = abjad.Score(
            [global_context, music_context], name="Score", tag=tag
        )
        self._assert_lilypond_identifiers(score)
        self._assert_unique_context_names(score)
        self._assert_matching_custom_context_names(score)
        return score
    def __call__(self):
        name = self.instrument.instrument_name.title()
        short_name = self.instrument.short_instrument_name.title()

        # Create staves

        embouchure_rhythm_staff = abjad.scoretools.Staff(
            [],
            context_name='RhythmStaff',
            name='Embouchure Rhythm'
        )

        embouchure_staff = abjad.scoretools.Staff(
            [],
            context_name='EmbouchureStaff',
            is_simultaneous=True,
            name='Embouchure',
        )

        lh_fingering_rhythm_staff = abjad.scoretools.Staff(
            [],
            context_name='RhythmStaff',
            name='Left Hand Fingering Rhythm',
        )

        lh_fingering_staff = abjad.scoretools.Staff(
            [],
            context_name='WoodwindFingeringStaff',
            is_simultaneous=True,
            name='Left Hand Fingering',
        )

        rh_fingering_staff = abjad.scoretools.Staff(
            [],
            context_name='WoodwindFingeringStaff',
            is_simultaneous=True,
            name='Right Hand Fingering',
        )

        rh_fingering_rhythm_staff = abjad.scoretools.Staff(
            [],
            context_name='RhythmStaff',
            name='Right Hand Fingering Rhythm',
        )

        # Combine
        subgroup = abjad.StaffGroup(
            [
                embouchure_staff,
                lh_fingering_rhythm_staff,
                lh_fingering_staff,
                rh_fingering_staff,
            ],
            context_name='StaffSubgroup',
            name=name + ' Staff Subgroup'
        )

        staff_list = [
            embouchure_rhythm_staff,
            subgroup,
            rh_fingering_rhythm_staff,
        ]

        instrument_staff_group = abjad.StaffGroup(
            staff_list,
            context_name='WoodwindInstrumentStaffGroup',
            name=name + ' Staff Group'
        )

        # Set Names

        abjad.annotate(embouchure_rhythm_staff, 'instrument', name)
        abjad.annotate(embouchure_staff, 'instrument', name)
        abjad.setting(embouchure_staff).instrument_name = abjad.Markup('Emb.')
        abjad.setting(embouchure_staff).short_instrument_name = \
            abjad.Markup('Emb.')

        abjad.annotate(lh_fingering_rhythm_staff, 'instrument', name)

        abjad.setting(lh_fingering_staff).instrument_name = \
            abjad.Markup('L.H.')
        abjad.setting(lh_fingering_staff).short_instrument_name = \
            abjad.Markup('L.H.')
        abjad.annotate(lh_fingering_staff, 'instrument', name)

        abjad.setting(rh_fingering_staff).instrument_name = \
            abjad.Markup('R.H.')
        abjad.setting(rh_fingering_staff).short_instrument_name = \
            abjad.Markup('R.H.')
        abjad.annotate(rh_fingering_staff, 'instrument', name)

        abjad.annotate(rh_fingering_rhythm_staff, 'instrument', name)

        abjad.setting(instrument_staff_group).instrument_name = \
            abjad.Markup(name)
        abjad.setting(instrument_staff_group).instrument_name = \
            abjad.Markup(short_name)

        # Set Stem Direction

        abjad.override(embouchure_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')
        abjad.override(lh_fingering_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')
        abjad.override(rh_fingering_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('DOWN')

        # Set Padding

        override.staff_space_after(embouchure_rhythm_staff, 2)
        override.staff_space_after(embouchure_staff, 8)
        override.staff_space_after(lh_fingering_rhythm_staff, 2)
        override.staff_space_after(lh_fingering_staff, 4)
        override.staff_space_after(rh_fingering_staff, 2)
        override.staff_space_after(rh_fingering_rhythm_staff, 10)

        # hide span bars on first and last rhythm staff, and rh fingering
        abjad.override(embouchure_rhythm_staff).bar_line.allow_span_bar = False
        abjad.override(embouchure_rhythm_staff).bar_line.transparent = True

        # abjad.override(lh_fingering_rhythm_staff).bar_line.transparent = True

        abjad.override(rh_fingering_staff).bar_line.allow_span_bar = False

        abjad.override(rh_fingering_rhythm_staff)\
            .bar_line.allow_span_bar = False
        abjad.override(rh_fingering_rhythm_staff).bar_line.transparent = True

        return instrument_staff_group
Example #20
0
    def __call__(self):
        """
        Calls string quartet score template.

        Returns score.
        """
        import abjad

        # make first violin voice and staff
        first_violin_voice = abjad.Voice(
            [],
            name='First Violin Voice',
        )
        first_violin_staff = abjad.Staff(
            [first_violin_voice],
            name='First Violin Staff',
        )
        clef = abjad.Clef('treble')
        abjad.annotate(first_violin_staff, 'default_clef', clef)
        violin = abjad.Violin()
        abjad.annotate(first_violin_staff, 'default_instrument', violin)
        tag = abjad.LilyPondLiteral(r"\tag #'first-violin", 'before')
        abjad.attach(tag, first_violin_staff)

        # make second violin voice and staff
        second_violin_voice = abjad.Voice(
            [],
            name='Second Violin Voice',
        )
        second_violin_staff = abjad.Staff(
            [second_violin_voice],
            name='Second Violin Staff',
        )
        clef = abjad.Clef('treble')
        abjad.annotate(second_violin_staff, 'default_clef', clef)
        violin = abjad.Violin()
        abjad.annotate(second_violin_staff, 'default_instrument', violin)
        tag = abjad.LilyPondLiteral(r"\tag #'second-violin", 'before')
        abjad.attach(tag, second_violin_staff)

        # make viola voice and staff
        viola_voice = abjad.Voice(
            [],
            name='Viola Voice',
        )
        viola_staff = abjad.Staff(
            [viola_voice],
            name='Viola Staff',
        )
        clef = abjad.Clef('alto')
        abjad.annotate(viola_staff, 'default_clef', clef)
        viola = abjad.Viola()
        abjad.annotate(viola_staff, 'default_instrument', viola)
        tag = abjad.LilyPondLiteral(r"\tag #'viola", 'before')
        abjad.attach(tag, viola_staff)

        # make cello voice and staff
        cello_voice = abjad.Voice(
            [],
            name='Cello Voice',
        )
        cello_staff = abjad.Staff(
            [cello_voice],
            name='Cello Staff',
        )
        clef = abjad.Clef('bass')
        abjad.annotate(cello_staff, 'default_clef', clef)
        cello = abjad.Cello()
        abjad.annotate(cello_staff, 'default_instrument', cello)
        tag = abjad.LilyPondLiteral(r"\tag #'cello", 'before')
        abjad.attach(tag, cello_staff)

        # make string quartet staff group
        string_quartet_staff_group = abjad.StaffGroup(
            [
                first_violin_staff,
                second_violin_staff,
                viola_staff,
                cello_staff,
            ],
            name='String Quartet Staff Group',
        )

        # make string quartet score
        string_quartet_score = abjad.Score(
            [string_quartet_staff_group],
            name='String Quartet Score',
        )

        # return string quartet score
        return string_quartet_score
Example #21
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        tag = 'huitzil.ScoreTemplate.__call__'

        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # CELLO
        rh_music_voice = abjad.Voice(
            name='RH_Music_Voice',
            tag=tag,
            )
        rh_music_staff = abjad.Staff(
            [rh_music_voice],
            lilypond_type='RHStaff',
            name='RH_Music_Staff',
            tag=tag,
            )
        abjad.annotate(
            rh_music_staff,
            'default_clef',
            abjad.Clef('percussion'),
            )
        abjad.annotate(
            rh_music_staff,
            abjad.const.REMOVE_ALL_EMPTY_STAVES,
            True,
            )
        cello_music_voice = abjad.Voice(
            name='Cello_Music_Voice',
            tag=tag,
            )
        cello_music_staff = abjad.Staff(
            [cello_music_voice],
            name='Cello_Music_Staff',
            tag=tag,
            )
        abjad.annotate(
            cello_music_staff,
            'default_clef',
            abjad.Clef('bass'),
            )
        cello_staff_group = abjad.StaffGroup(
            [
                rh_music_staff,
                cello_music_staff,
                ],
            lilypond_type='PianoStaff',
            name='Cello_Staff_Group',
            tag=tag,
            )
        abjad.annotate(
            cello_staff_group,
            'default_instrument',
            huitzil.instruments['Cello'],
            )

        # SCORE
        music_context = abjad.Context(
            [cello_staff_group],
            lilypond_type='MusicContext',
            name='Music_Context',
            tag=tag,
            )
        score = abjad.Score(
            [global_context, music_context],
            name='Score',
            tag=tag,
            )
        self._assert_lilypond_identifiers(score)
        self._assert_unique_context_names(score)
        #self._assert_matching_custom_context_names(score)
        return score
Example #22
0
    def __call__(self):
        """
        Calls string quartet score template.

        Returns score.
        """
        import abjad

        site = "abjad.StringQuartetScoreTemplate.__call__()"
        tag = Tag(site)

        # make first violin voice and staff
        first_violin_voice = abjad.Voice(
            [], name="First_Violin_Voice", tag=tag
        )
        first_violin_staff = abjad.Staff(
            [first_violin_voice], name="First_Violin_Staff", tag=tag
        )
        clef = abjad.Clef("treble")
        abjad.annotate(first_violin_staff, "default_clef", clef)
        violin = abjad.Violin()
        abjad.annotate(first_violin_staff, "default_instrument", violin)
        literal = abjad.LilyPondLiteral(r"\tag #'first-violin", "before")
        abjad.attach(literal, first_violin_staff)

        # make second violin voice and staff
        second_violin_voice = abjad.Voice(
            [], name="Second_Violin_Voice", tag=tag
        )
        second_violin_staff = abjad.Staff(
            [second_violin_voice], name="Second_Violin_Staff", tag=tag
        )
        clef = abjad.Clef("treble")
        abjad.annotate(second_violin_staff, "default_clef", clef)
        violin = abjad.Violin()
        abjad.annotate(second_violin_staff, "default_instrument", violin)
        literal = abjad.LilyPondLiteral(r"\tag #'second-violin", "before")
        abjad.attach(literal, second_violin_staff)

        # make viola voice and staff
        viola_voice = abjad.Voice([], name="Viola_Voice", tag=tag)
        viola_staff = abjad.Staff(
            [viola_voice], name="Viola_Staff", tag=tag
        )
        clef = abjad.Clef("alto")
        abjad.annotate(viola_staff, "default_clef", clef)
        viola = abjad.Viola()
        abjad.annotate(viola_staff, "default_instrument", viola)
        literal = abjad.LilyPondLiteral(r"\tag #'viola", "before")
        abjad.attach(literal, viola_staff)

        # make cello voice and staff
        cello_voice = abjad.Voice([], name="Cello_Voice", tag=tag)
        cello_staff = abjad.Staff(
            [cello_voice], name="Cello_Staff", tag=tag
        )
        clef = abjad.Clef("bass")
        abjad.annotate(cello_staff, "default_clef", clef)
        cello = abjad.Cello()
        abjad.annotate(cello_staff, "default_instrument", cello)
        literal = abjad.LilyPondLiteral(r"\tag #'cello", "before")
        abjad.attach(literal, cello_staff)

        # make string quartet staff group
        string_quartet_staff_group = abjad.StaffGroup(
            [
                first_violin_staff,
                second_violin_staff,
                viola_staff,
                cello_staff,
            ],
            name="String_Quartet_Staff_Group",
            tag=tag,
        )

        # make string quartet score
        string_quartet_score = abjad.Score(
            [string_quartet_staff_group],
            name="String_Quartet_Score",
            tag=tag,
        )

        # return string quartet score
        return string_quartet_score
Example #23
0
    def __call__(self):
        picking_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Picking Rhythm')

        picking_staff = abjad.scoretools.Staff([],
                                               context_name='PickingStaff',
                                               name='Picking')

        fretting_staff = abjad.scoretools.Staff([],
                                                context_name='FrettingStaff',
                                                is_simultaneous=True,
                                                name='Fretting')

        fretting_rhythm_staff = abjad.scoretools.Staff(
            [], context_name='RhythmStaff', name='Fretting Rhythm')

        name = self.instrument.instrument_name.title()
        if name[-1] == 'i':
            name = name[0:-1] + 'I'

        subgroup = abjad.StaffGroup([picking_staff, fretting_staff],
                                    context_name='StaffSubgroup',
                                    name=name + ' Staff Subgroup')

        staff_list = [
            picking_rhythm_staff,
            subgroup,
            fretting_rhythm_staff,
        ]

        instrument_staff_group = abjad.scoretools.StaffGroup(
            staff_list,
            context_name='GuitarStaffGroup',
            name=name + ' Staff Group')

        # Naming

        abjad.setting(picking_staff).instrument_name = abjad.Markup('Picking')

        abjad.setting(picking_staff).short_instrument_name = \
            abjad.Markup('Picking')

        abjad.setting(fretting_staff).instrument_name = \
            abjad.Markup('Fretting')

        abjad.setting(fretting_staff).short_instrument_name = \
            abjad.Markup('Fretting')

        abjad.annotate(staff_list[0], 'instrument', name)
        abjad.annotate(staff_list[1][0], 'instrument', name)
        abjad.annotate(staff_list[1][1], 'instrument', name)
        abjad.annotate(staff_list[2], 'instrument', name)

        # Stem direction

        abjad.override(picking_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('UP')

        abjad.override(fretting_rhythm_staff).stem.direction = \
            abjad.schemetools.Scheme('DOWN')

        # Bar Line visibility
        abjad.override(picking_rhythm_staff).bar_line.transparent = True
        abjad.override(fretting_rhythm_staff).bar_line.transparent = True

        # Padding
        override.staff_space_after(picking_rhythm_staff, 2)
        override.staff_space_after(picking_staff, 4)
        override.staff_space_after(fretting_staff, 2)
        override.staff_space_after(fretting_rhythm_staff, 10)

        return instrument_staff_group
Example #24
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        tag = 'ins_wasser.ScoreTemplate.__call__'

        # GLOBAL CONTEXT
        global_context = self._make_global_context()

        # VIOLA 1
        markup_voice = abjad.Voice(
            name='Viola_I_Markup_Voice',
            tag=tag,
            )
        music_voice = abjad.Voice(
            name='Viola_I_Music_Voice',
            tag=tag,
            )
        dynamics_voice = abjad.Voice(
            name='Viola_I_Dynamics_Voice',
            tag=tag,
            )
        viola_1_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            is_simultaneous=True,
            name='Viola_I',
            tag=tag,
            )
        abjad.annotate(
            viola_1_staff,
            'default_instrument',
            ins_wasser.instruments['ViolaI'],
            )
        abjad.annotate(
            viola_1_staff,
            'default_clef',
            abjad.Clef('alto'),
            )

        # VIOLA 2
        markup_voice = abjad.Voice(
            name='Viola_II_Markup_Voice',
            tag=tag,
            )
        music_voice = abjad.Voice(
            name='Viola_II_Music_Voice',
            tag=tag,
            )
        dynamics_voice = abjad.Voice(
            name='Viola_II_Dynamics_Voice',
            tag=tag,
            )
        viola_2_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            is_simultaneous=True,
            name='Viola_II',
            tag=tag,
            )
        abjad.annotate(
            viola_2_staff,
            'default_instrument',
            ins_wasser.instruments['ViolaII'],
            )
        abjad.annotate(
            viola_2_staff,
            'default_clef',
            abjad.Clef('alto'),
            )

        # SCORE
        piano_staff = abjad.StaffGroup(
            [viola_1_staff, viola_2_staff],
            lilypond_type='PianoStaff',
            name='Piano_Staff',
            tag=tag,
            )
        score = abjad.Score(
            [global_context, piano_staff],
            name='Score',
            tag=tag,
            )
        self._assert_lilypond_identifiers(score)
        self._assert_unique_context_names(score)
        self._assert_matching_custom_context_names(score)
        return score
Example #25
0
    def __call__(self):
        """
        Calls string quartet score template.

        Returns score.
        """
        import abjad

        class_name = "abjad.StringQuartetScoreTemplate"

        # make first violin voice and staff
        first_violin_voice = abjad.Voice(
            [], name="First_Violin_Voice", tag=class_name
        )
        first_violin_staff = abjad.Staff(
            [first_violin_voice], name="First_Violin_Staff", tag=class_name
        )
        clef = abjad.Clef("treble")
        abjad.annotate(first_violin_staff, "default_clef", clef)
        violin = abjad.Violin()
        abjad.annotate(first_violin_staff, "default_instrument", violin)
        tag = abjad.LilyPondLiteral(r"\tag #'first-violin", "before")
        abjad.attach(tag, first_violin_staff)

        # make second violin voice and staff
        second_violin_voice = abjad.Voice(
            [], name="Second_Violin_Voice", tag=class_name
        )
        second_violin_staff = abjad.Staff(
            [second_violin_voice], name="Second_Violin_Staff", tag=class_name
        )
        clef = abjad.Clef("treble")
        abjad.annotate(second_violin_staff, "default_clef", clef)
        violin = abjad.Violin()
        abjad.annotate(second_violin_staff, "default_instrument", violin)
        tag = abjad.LilyPondLiteral(r"\tag #'second-violin", "before")
        abjad.attach(tag, second_violin_staff)

        # make viola voice and staff
        viola_voice = abjad.Voice([], name="Viola_Voice", tag=class_name)
        viola_staff = abjad.Staff(
            [viola_voice], name="Viola_Staff", tag=class_name
        )
        clef = abjad.Clef("alto")
        abjad.annotate(viola_staff, "default_clef", clef)
        viola = abjad.Viola()
        abjad.annotate(viola_staff, "default_instrument", viola)
        tag = abjad.LilyPondLiteral(r"\tag #'viola", "before")
        abjad.attach(tag, viola_staff)

        # make cello voice and staff
        cello_voice = abjad.Voice([], name="Cello_Voice", tag=class_name)
        cello_staff = abjad.Staff(
            [cello_voice], name="Cello_Staff", tag=class_name
        )
        clef = abjad.Clef("bass")
        abjad.annotate(cello_staff, "default_clef", clef)
        cello = abjad.Cello()
        abjad.annotate(cello_staff, "default_instrument", cello)
        tag = abjad.LilyPondLiteral(r"\tag #'cello", "before")
        abjad.attach(tag, cello_staff)

        # make string quartet staff group
        string_quartet_staff_group = abjad.StaffGroup(
            [
                first_violin_staff,
                second_violin_staff,
                viola_staff,
                cello_staff,
            ],
            name="String_Quartet_Staff_Group",
            tag=class_name,
        )

        # make string quartet score
        string_quartet_score = abjad.Score(
            [string_quartet_staff_group],
            name="String_Quartet_Score",
            tag=class_name,
        )

        # return string quartet score
        return string_quartet_score
Example #26
0
 def _make_performer_staff_group(
     self,
     clef_name=None,
     instrument=None,
     number=None,
 ):
     import abjad
     if number is not None:
         name = '{} {}'.format(
             instrument.name.title(),
             number,
         )
     else:
         name = instrument.name.title()
     pitch_range = instrument.pitch_range
     staff_group = abjad.StaffGroup(
         lilypond_type='StringPerformerStaffGroup',
         name='{} Staff Group'.format(name),
     )
     tag_name = name.replace(' ', '')
     tag_string = r"\tag #'{}".format(tag_name)
     tag_command = abjad.LilyPondLiteral(tag_string, 'before')
     abjad.attach(tag_command, staff_group)
     if self.split_hands:
         lh_voice = abjad.Voice(
             [],
             lilypond_type='FingeringVoice',
             name='{} Fingering Voice'.format(name),
         )
         abbreviation = lh_voice.name.lower().replace(' ', '_')
         self.voice_abbreviations[abbreviation] = lh_voice.name
         lh_staff = abjad.Staff(
             [lh_voice],
             lilypond_type='FingeringStaff',
             name='{} Fingering Staff'.format(name),
         )
         lh_staff.is_simultaneous = True
         abjad.annotate(lh_staff, 'pitch_range', pitch_range)
         abjad.annotate(lh_staff, 'default_clef', abjad.Clef(clef_name))
         rh_voice = abjad.Voice(
             [],
             lilypond_type='BowingVoice',
             name='{} Bowing Voice'.format(name),
         )
         abbreviation = rh_voice.name.lower().replace(' ', '_')
         self.voice_abbreviations[abbreviation] = rh_voice.name
         rh_staff = abjad.Staff(
             [rh_voice],
             lilypond_type='BowingStaff',
             name='{} Bowing Staff'.format(name),
         )
         rh_staff.is_simultaneous = True
         staff_group.extend([rh_staff, lh_staff])
     else:
         lh_voice = abjad.Voice(
             [],
             lilypond_type='FingeringVoice',
             name='{} Voice'.format(name),
         )
         lh_staff = abjad.Staff(
             [lh_voice],
             lilypond_type='FingeringStaff',
             name='{} Staff'.format(name),
         )
         lh_staff.is_simultaneous = True
         abjad.annotate(lh_staff, 'pitch_range', pitch_range)
         abjad.annotate(lh_staff, 'default_clef', abjad.Clef(clef_name))
         staff_group.append(lh_staff)
     return staff_group, tag_name
Example #27
0
    def __call__(self) -> abjad.Score:
        """
        Calls score template.
        """
        site = "arctic.ScoreTemplate.__call__()"
        tag = abjad.Tag(site)

        # GLOBAL CONTEXT
        #global_context = self._make_global_context()

        # Violin
        markup_voice = abjad.Voice(name="Violin_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Violin_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Violin_Dynamics_Voice", tag=tag)
        violin_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Violin",
            tag=tag,
        )
        abjad.annotate(
            violin_staff,
            "default_instrument",
            arctic.instruments["Violin"],
        )
        abjad.annotate(violin_staff, "default_clef", abjad.Clef("treble"))
        violin_tag = abjad.LilyPondLiteral(r"\tag #'violin", format_slot='before')
        abjad.attach(violin_tag, violin_staff)
        abjad.setting(violin_staff).midi_instrument = abjad.scheme.Scheme(
                'violin', force_quotes=True)

        # MonoSynth
        markup_voice = abjad.Voice(name="Monosynth_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="Monosynth_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="Monosynth_Dynamics_Voice", tag=tag)
        monosynth_staff = abjad.Staff(
            [markup_voice, music_voice, dynamics_voice],
            simultaneous=True,
            name="Monosynth",
            tag=tag,
        )
        abjad.annotate(
            monosynth_staff,
            "default_instrument",
            arctic.instruments["Monosynth"],
        )
        abjad.annotate(monosynth_staff, "default_clef", abjad.Clef("treble"))
        monosynth_tag = abjad.LilyPondLiteral(r"\tag #'monosynth", format_slot='before')
        abjad.attach(monosynth_tag, monosynth_staff)
        abjad.setting(monosynth_staff).midi_instrument = abjad.scheme.Scheme(
                'clarinet', force_quotes=True)

        ### RH PolySynth Voices ###
        markup_voice = abjad.Voice(name="RH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="RH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="RH_I_Dynamics_Voice", tag=tag)
        #rh_voice_2 = abjad.Voice(
        #            lilypond_type="RHVoiceII", name="RH_II_Music_Voice", tag=tag
        #            )
       
        # RH PolySynth Staff 
        polysynth_music_rh_staff = abjad.Staff(
                [markup_voice, music_voice, dynamics_voice],
                simultaneous=True,
                name="RH_Polysynth",
                tag=tag,
                )
        abjad.annotate(
                polysynth_music_rh_staff, "default_clef", abjad.Clef("treble")
                )
        
        ### LH PolySynth Voices ###
        markup_voice = abjad.Voice(name="LH_I_Markup_Voice", tag=tag)
        music_voice = abjad.Voice(name="LH_I_Music_Voice", tag=tag)
        dynamics_voice = abjad.Voice(name="LH_I_Dynamics_Voice", tag=tag)
        #        lh_voice_2 = abjad.Voice(
        #            lilypond_type="LHVoiceII", name="LH_II_Music_Voice", tag=tag
        #        )
        #
       
        # LH PolySynth Staff
        polysynth_music_lh_staff = abjad.Staff(
                [markup_voice, music_voice, dynamics_voice],
                simultaneous=True,
                name="LH_Polysynth",
                tag=tag,
                )
        abjad.annotate(
                polysynth_music_lh_staff, "default_clef", abjad.Clef("bass")
                )

        # Polysynth Staff Group
        polysynth_staff_group = abjad.StaffGroup(
                [polysynth_music_rh_staff, polysynth_music_lh_staff],
                simultaneous=True,
                lilypond_type="PianoStaff",
                name="Polysynth_Staff_Group",
                tag=tag,
                )
        polysynth_tag = abjad.LilyPondLiteral(r"\tag #'polysynth", format_slot='before')
        abjad.attach(polysynth_tag, polysynth_staff_group)
        abjad.setting(polysynth_staff_group).midi_instrument = abjad.scheme.Scheme(
                'organ', force_quotes=True)
        
        # Music Context
        music_context = abjad.Context(
                [
                    violin_staff,
                    monosynth_staff,
                    polysynth_staff_group,
                ],
                lilypond_type="MusicContext",
                simultaneous=True,
                name="Music_Context",
                tag=tag,
                )

        # Score
        score = abjad.Score(
                [music_context], name="Score", tag=tag
                )
        return score