示例#1
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     handler_commands,
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
示例#2
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
         abjad.Markup(
padovan_5 = evans.Sequence.e_dovan_cycle(n=2,
                                         iters=60,
                                         first=4,
                                         second=7,
                                         modulus=9)
padovan_6 = evans.Sequence.e_dovan_cycle(n=3,
                                         iters=60,
                                         first=2,
                                         second=3,
                                         modulus=7)

rmaker_six = abjadext.rmakers.stack(
    abjadext.rmakers.even_division([4, 2, 4, 8, 4], extra_counts=[0, 1, -1,
                                                                  1]),  # A
    abjadext.rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.extract_trivial(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_rest_filled(
        lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
)

# #####
rmaker_seven = abjadext.rmakers.stack(
    abjadext.rmakers.talea(padovan_5, 4, extra_counts=[0, 1, 0, 0, -1]),  # E
    abjadext.rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.extract_trivial(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_rest_filled(
        lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
)
示例#4
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
         abjad.Markup(
示例#5
0
def _slur_runs(selections):
    for run in abjad.Selection(selections).runs():
        if 1 < len(run):
            abjad.attach(abjad.StartSlur(), run[0])
            abjad.attach(abjad.StopSlur(), run[-1])
示例#6
0
    4,
    3,
    4,
    2,
    5,
    4,
    3,
    3,
    1,
    2,
    4,
    3,
    5,
    2,
    4,
    4,
    2,
    4,
    1,
    4,
    3,
]

rmaker_one = abjadext.rmakers.stack(
    abjadext.rmakers.talea(lor, 16, extra_counts=[0, 1, 0, -1]),
    abjadext.rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.extract_trivial(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_rest_filled(lambda _: abjad.Selection(_).tuplets()),
    abjadext.rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
)
示例#7
0
import abjad
import muda
staff = abjad.Staff("c4 c4 c4")
sel = abjad.Selection(staff)

sel = lambda _: abjad.Selection(_).leaves.get

# def test(sel, select):
#     staff = abjad.Staff("c4 c4 c4")
#     sel = muda.Selection(staff)

# sel = muda.Selection().leaves()
# s = sel(staff)
# print(s)

a = [_.leaves() for _ in sel]
print(a)
示例#8
0
 def selector(_):
     return abjad.Selection(_).leaf(0)
示例#9
0
    def __init__(
        self,
        location,
        *args,
        attachments=None,
        callables=None,
        preprocessor=None,
    ):
        self.location = location
        self.preprocessor = preprocessor
        self.attachments = []
        if attachments is not None:
            self.attachments = attachments
        self.callables = []
        if callables is not None:
            self.callables = callables
        self.threaded_commands = None

        for arg in args:
            if isinstance(arg, Attachment):
                self.attachments.append(arg)
            elif isinstance(arg, Callable):
                self.callables.append(arg)
            else:
                if not callable(arg):
                    if type(arg) == abjad.Articulation:

                        def selector(selections):
                            run_ties = (abjad.Selection(
                                selections).runs().logical_ties(pitched=True))
                            ties_first_leaves = abjad.Selection(
                                [_[0] for _ in run_ties])
                            return ties_first_leaves

                    else:

                        def selector(_):
                            return abjad.Selection(_).leaf(0, pitched=True)

                    new_attachment = Attachment(
                        arg,
                        selector,
                    )
                    self.attachments.append(new_attachment)
                elif callable(arg):
                    new_callable = Callable(
                        arg,
                        lambda _: abjad.Selection(_).leaves(),
                    )
                    self.callables.append(new_callable)

        if isinstance(self.location, list):
            threaded_commands = []
            for location_ in self.location:
                new_command = type(self)(
                    location_,
                    attachments=self.attachments,
                    callables=self.callables,
                    preprocessor=self.preprocessor,
                )
                threaded_commands.append(new_command)
            self.threaded_commands = threaded_commands
示例#10
0
    def write_indicators(
        self,
        material_name=None,
        dynamics=None,
        articulations=None,
        slur_up=None,
        slur_down=None,
        change_staffs_names=None,
        pitched=True,
    ):
        """Write indicators to leaves."""
        if material_name is not None:
            selection1 = abjad.Selection(self.container).components(
                abjad.Container)
            for container in selection1:
                if container.name is not None and (
                    (isinstance(material_name, list)
                     or material_name in container.name)):
                    selection2 = abjad.Selection(container).leaves(
                        pitched=pitched)
                    if dynamics:
                        for key in dynamics:
                            if dynamics[key] == "all":
                                for i, leaf in enumerate(selection2[0::2]):
                                    a = i
                                    b = i + 1
                                    abjad.hairpin(key, selection2[a:b])
                            else:
                                for i in dynamics[key]:
                                    if isinstance(i, tuple):
                                        a, b = i
                                        b = b + 1
                                        abjad.hairpin(key, selection2[a:b])
                                    else:
                                        abjad.hairpin(key, selection2[i])

                    # attach slurs
                    if slur_up:
                        for n in slur_up:
                            a, b = n
                            b = b
                            abjad.attach(abjad.StartSlur(), selection2[a])
                            abjad.attach(abjad.StopSlur(), selection2[b])

                    if slur_down:
                        for n in slur_down:
                            a, b = n
                            abjad.attach(abjad.StartSlur(direction=abjad.Down),
                                         selection2[a])
                            abjad.attach(abjad.StopSlur(), selection2[b])

                    if articulations:
                        for key in articulations:
                            for i in articulations[key]:
                                abjad.attach(abjad.Articulation(key),
                                             selection2[i])
        else:
            selection = abjad.Selection(self.container).leaves(pitched=pitched)

            if dynamics:
                for key in dynamics:
                    for i in dynamics[key]:
                        if isinstance(i, tuple):
                            a, b = i
                            b = b + 1
                            abjad.hairpin(key, selection[a:b])
                        else:
                            abjad.hairpin(key, selection[i])

            # attach slurs
            if slur_up:
                for n in slur_up:
                    a, b = n
                    b = b
                    abjad.attach(abjad.StartSlur(), selection[a])
                    abjad.attach(abjad.StopSlur(), selection[b])

            if slur_down:
                for n in slur_down:
                    a, b = n
                    abjad.attach(abjad.StartSlur(direction=abjad.Down),
                                 selection[a])
                    abjad.attach(abjad.StopSlur(), selection[b])

            if articulations:
                for key in articulations:
                    for i in articulations[key]:
                        abjad.attach(abjad.Articulation(key), selection[i])
示例#11
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
         abjad.Markup(
示例#12
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     handler_commands,
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
示例#13
0
def last_leaf(selections):
    return abjad.Selection(selections).leaf(-1)
示例#14
0
def nonlast_lts(selections):
    return abjad.Selection(selections).logical_ties()[:-1]
示例#15
0
 def _rhythm_cell(duration, rtm):
     rtm_parser = abjad.rhythmtrees.RhythmTreeParser()
     selection = abjad.Selection(rtm_parser(rtm)[0](duration))
     return selection
示例#16
0
 def selector(selections):
     run_ties = (abjad.Selection(
         selections).runs().logical_ties(pitched=True))
     ties_first_leaves = abjad.Selection(
         [_[0] for _ in run_ties])
     return ties_first_leaves
示例#17
0
def return_vertical_moment_ties(score):
    r"""

    ..  container:: example

        >>> staff_1 = abjad.Staff("c'4 c'2 c'4")
        >>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
        >>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
        >>> score = abjad.Score(
        ...     [
        ...         staff_1,
        ...         staff_2,
        ...         staff_3,
        ...     ]
        ... )
        >>> for tie in evans.return_vertical_moment_ties(score):
        ...     tie
        ...
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("c'4")])
        LogicalTie(items=[Note("cs'4")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("cs'4")])
        LogicalTie(items=[Note("c'2")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("cs'2")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("d'8")])
        LogicalTie(items=[Note("c'4")])
        LogicalTie(items=[Note("d'8")])

    ..  container:: example

        >>> staff_1 = abjad.Staff("c'4 c'2 c'4")
        >>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
        >>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
        >>> score = abjad.Score(
        ...     [
        ...         staff_1,
        ...         staff_2,
        ...         staff_3,
        ...     ]
        ... )
        ...
        >>> handler = evans.PitchHandler(
        ...     pitch_list=[0, 1, 2, 3, 4],
        ...     forget=False,
        ...     to_ties=True,
        ... )
        ...
        >>> vm_ties = evans.return_vertical_moment_ties(score)
        >>> numbers = [_ for _ in range(len(vm_ties))]
        >>> for i, tie in zip(numbers, vm_ties):
        ...     string = f"{i}"
        ...     markup = abjad.Markup(fr"\markup {string}", direction=abjad.Up)
        ...     abjad.attach(markup, tie[0])
        ...
        >>> handler(vm_ties)
        >>> moment = "#(ly:make-moment 1 25)"
        >>> abjad.setting(score).proportional_notation_duration = moment
        >>> file = abjad.LilyPondFile(
        ...     items=[
        ...         "#(set-default-paper-size \"a4\" \'portrait)",
        ...         r"#(set-global-staff-size 16)",
        ...         "\\include \'Users/gregoryevans/abjad/docs/source/_stylesheets/abjad.ily\'",
        ...         score,
        ...     ],
        ... )
        ...
        >>> abjad.show(file) # doctest: +SKIP

        .. docs::

            >>> print(abjad.lilypond(score))
            \new Score
            \with
            {
                proportionalNotationDuration = #(ly:make-moment 1 25)
            }
            <<
                \new Staff
                {
                    cs'4
                    ^ \markup 1
                    cs'2
                    ^ \markup 6
                    d'4
                    ^ \markup 12
                }
                \new Staff
                {
                    d'4
                    ^ \markup 2
                    c'4
                    ^ \markup 5
                    e'2
                    ^ \markup 9
                }
                \new Staff
                {
                    c'8
                    ^ \markup 0
                    ef'8
                    ^ \markup 3
                    e'8
                    ^ \markup 4
                    d'8
                    ^ \markup 7
                    ef'8
                    ^ \markup 8
                    c'8
                    ^ \markup 10
                    cs'8
                    ^ \markup 11
                    ef'8
                    ^ \markup 13
                }
            >>

    ..  container:: example

        >>> staff_1 = abjad.Staff("c'4 ~ c'2 c'4")
        >>> staff_2 = abjad.Staff("cs'4 cs'4 cs'2")
        >>> staff_3 = abjad.Staff("d'8 d'8 d'8 d'8 d'8 d'8 d'8 d'8")
        >>> score = abjad.Score(
        ...     [
        ...         staff_1,
        ...         staff_2,
        ...         staff_3,
        ...     ]
        ... )
        >>> handler = evans.PitchHandler(pitch_list=[0, 1, 2, 3, 4], forget=False)
        >>> vm_ties = evans.return_vertical_moment_ties(score)
        >>> numbers = [_ for _ in range(len(vm_ties))]
        >>> for i, tie in zip(numbers, vm_ties):
        ...     string = f"{i}"
        ...     markup = abjad.Markup(fr"\markup {string}", direction=abjad.Up)
        ...     abjad.attach(markup, tie[0])
        ...     handler(tie)
        ...
        >>> moment = "#(ly:make-moment 1 25)"
        >>> abjad.setting(score).proportional_notation_duration = moment
        >>> file = abjad.LilyPondFile(
        ...     items=[
        ...         "#(set-default-paper-size \"a4\" \'portrait)",
        ...         r"#(set-global-staff-size 16)",
        ...         "\\include \'Users/gregoryevans/abjad/docs/source/_stylesheets/abjad.ily\'",
        ...         score,
        ...     ],
        ... )
        ...
        >>> abjad.show(file) # doctest: +SKIP

        .. docs::

            >>> print(abjad.lilypond(score))
            \new Score
            \with
            {
                proportionalNotationDuration = #(ly:make-moment 1 25)
            }
            <<
                \new Staff
                {
                    d'4
                    ^ \markup 2
                    ~
                    d'2
                    cs'4
                    ^ \markup 11
                }
                \new Staff
                {
                    cs'4
                    ^ \markup 1
                    c'4
                    ^ \markup 5
                    ef'2
                    ^ \markup 8
                }
                \new Staff
                {
                    c'8
                    ^ \markup 0
                    ef'8
                    ^ \markup 3
                    e'8
                    ^ \markup 4
                    cs'8
                    ^ \markup 6
                    d'8
                    ^ \markup 7
                    e'8
                    ^ \markup 9
                    c'8
                    ^ \markup 10
                    d'8
                    ^ \markup 12
                }
            >>

    """
    moments = [_ for _ in abjad.iterate_vertical_moments(score)]
    new_moments = []
    for i, moment in enumerate(moments):
        new_moment = []
        new_moment_notes = []
        for note in moment.start_notes:
            new_moment_notes.append(note)
        if 0 < len(new_moment_notes):
            new_moment.append(
                [_ for _ in abjad.Selection(new_moment_notes).logical_ties()])
            new_moments.append(new_moment)
    flat_moments = flatten(new_moments)
    flat_moments.sort(key=lambda _: abjad.get.timespan(_))
    return flat_moments
示例#18
0
 def selector(_):
     return abjad.Selection(_).leaf(0, pitched=True)
示例#19
0
def piano_pedal(
    argument: Union[abjad.Component, abjad.Selection],
    *,
    half_pedal: bool = False,
    until_the_end: bool = False,
    omit_raise_pedal_glyph: bool = False,
    selector: abjad.Expression = abjad.select().leaves(),
    start_piano_pedal: abjad.StartPianoPedal = None,
    stop_piano_pedal: abjad.StopPianoPedal = None,
    tag: abjad.Tag = None,
) -> None:
    r"""Attaches piano pedal indicators. This function extends the capabilities
    of Abjad's built-in |abjad.piano_pedal()|.

    Basic usage:
        Basic usage is identical to Abjad's built-ind |abjad.piano_pedal()|:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:])
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-KaleXflNvL.png

    ..  note::

        Auxjad automatically replaces Abjad's built-in |abjad.piano_pedal()|
        with this function. Therefore it can be used either as
        :func:`abjad.piano_pedal()` or |abjad.piano_pedal()|, as shown below:

        >>> staff1 = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> staff2 = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff1[:])
        >>> auxjad.piano_pedal(staff2[:])
        >>> selections = [staff1[:], staff2[:]]
        >>> auxjad.get.selections_are_identical(selections)
        True

    ``until_the_end``:
        Call the function with ``until_the_end`` set to ``True`` to add an
        arrow to the initial pedal glyph:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   until_the_end=True,
        ...                   )
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                \once \override Staff.SustainPedal.stencil =
                    #(lambda (grob) (grob-interpret-markup grob
                        #{
                            \markup {
                                \concat {
                                    \musicglyph "pedal.Ped"
                                    \musicglyph "pedal.."
                                }
                                \raise #-0.3 "→"
                            }
                        #}))
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-rA7ZHeMrjf.png

    ``omit_raise_pedal_glyph``:
        Call the function with ``omit_raise_pedal_glyph`` set to ``True`` to
        remove the raise pedal glyph:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   omit_raise_pedal_glyph=True,
        ...                   )
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                c'4
                \sustainOn
                d'4
                e'4
                \once \override Staff.SustainPedal.stencil = ##f
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-p8S1KwHLIx.png

        Combined with ``until_the_end=True``:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   until_the_end=True,
        ...                   omit_raise_pedal_glyph=True,
        ...                   )
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                \once \override Staff.SustainPedal.stencil =
                    #(lambda (grob) (grob-interpret-markup grob
                        #{
                            \markup {
                                \concat {
                                    \musicglyph "pedal.Ped"
                                    \musicglyph "pedal.."
                                }
                                \raise #-0.3 "→"
                            }
                        #}))
                c'4
                \sustainOn
                d'4
                e'4
                \once \override Staff.SustainPedal.stencil = ##f
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-Fb5rE6QB1f.png

    ``half_pedal``:

        Call the function with ``half_pedal`` set to ``True`` to use the half
        pedalling glyph:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   half_pedal=True,
        ...                   )
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                \once \override Staff.SustainPedal.stencil =
                    #(lambda (grob) (grob-interpret-markup grob
                        #{
                            \markup {
                                \larger "½"
                                \concat {
                                    \musicglyph "pedal.Ped"
                                    \musicglyph "pedal.."
                                }
                            }
                        #}))
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-EYs495mi9K.png

        Combined with ``until_the_end=True``:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   half_pedal=True,
        ...                   until_the_end=True,
        ...                   )
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            {
                \once \override Staff.SustainPedal.stencil =
                    #(lambda (grob) (grob-interpret-markup grob
                        #{
                            \markup {
                                \larger "½"
                                \concat {
                                    \musicglyph "pedal.Ped"
                                    \musicglyph "pedal.."
                                }
                                \raise #-0.3 "→"
                            }
                        #}))
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-viOZdVeRs9.png

    Pedal style:
        The style of the sustain pedal can be tweaked using |abjad.setting()|
        as shown below:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:])
        >>> abjad.setting(staff).pedal_sustain_style = "#'mixed"
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            \with
            {
                pedalSustainStyle = #'mixed
            }
            {
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-6q9Swb2elq.png

        This tweak also works with ``until_the_end=True`` if desired:

        >>> staff = abjad.Staff(r"c'4 d'4 e'4 f'4")
        >>> abjad.piano_pedal(staff[:],
        ...                   until_the_end=True,
        ...                   )
        >>> abjad.setting(staff).pedal_sustain_style = "#'mixed"
        >>> abjad.show(staff)

        ..  docs::

            \new Staff
            \with
            {
                pedalSustainStyle = #'mixed
            }
            {
                \once \override Staff.SustainPedal.stencil =
                    #(lambda (grob) (grob-interpret-markup grob
                        #{
                            \markup {
                                \concat {
                                    \musicglyph "pedal.Ped"
                                    \musicglyph "pedal.."
                                }
                                \raise #-0.3 "→"
                            }
                        #}))
                c'4
                \sustainOn
                d'4
                e'4
                f'4
                \sustainOff
            }

        ..  figure:: ../_images/piano_pedal-cYyRwFvnFH.png
    """
    assert isinstance(selector, abjad.Expression)
    argument = selector(argument)
    leaves = abjad.Selection(argument).leaves()
    start_leaf = leaves[0]
    stop_leaf = leaves[-1]
    if not half_pedal and until_the_end:
        string = r"""
            \once \override Staff.SustainPedal.stencil =
                #(lambda (grob) (grob-interpret-markup grob
                    #{
                        \markup {
                            \concat {
                                \musicglyph "pedal.Ped"
                                \musicglyph "pedal.."
                            }
                            \raise #-0.3 "→"
                        }
                    #}))
            """
    elif half_pedal and not until_the_end:
        string = r"""
            \once \override Staff.SustainPedal.stencil =
                #(lambda (grob) (grob-interpret-markup grob
                    #{
                        \markup {
                            \larger "½"
                            \concat {
                                \musicglyph "pedal.Ped"
                                \musicglyph "pedal.."
                            }
                        }
                    #}))
            """
    elif half_pedal and until_the_end:
        string = r"""
            \once \override Staff.SustainPedal.stencil =
                #(lambda (grob) (grob-interpret-markup grob
                    #{
                        \markup {
                            \larger "½"
                            \concat {
                                \musicglyph "pedal.Ped"
                                \musicglyph "pedal.."
                            }
                            \raise #-0.3 "→"
                        }
                    #}))
            """
    if half_pedal or until_the_end:
        string = dedent(string).strip()
        pedal_tweak = abjad.LilyPondLiteral(string)
        abjad.attach(pedal_tweak, start_leaf)
    if omit_raise_pedal_glyph:
        omit_raise_pedal_glyph_tweak = abjad.LilyPondLiteral(
            r"\once \override Staff.SustainPedal.stencil = ##f")
        abjad.attach(omit_raise_pedal_glyph_tweak, stop_leaf)
    piano_pedal_(
        argument=argument,
        selector=selector,
        start_piano_pedal=start_piano_pedal,
        stop_piano_pedal=stop_piano_pedal,
        tag=tag,
    )
def test_Selection_are_contiguous_same_parent_04():
    """
    Empty selection returns true.
    """

    assert abjad.Selection().are_contiguous_same_parent()
示例#21
0
import abjad
import abjadext.rmakers
import evans

from chalk_line.materials.rhythm.segment_02.rhythm_makers import rmaker_one

silence_maker_ = abjadext.rmakers.stack(
    abjadext.rmakers.NoteRhythmMaker(),
    abjadext.rmakers.force_rest(
        lambda _: abjad.Selection(_).leaves(pitched=True)),
)

silence_maker = evans.RhythmHandler(rmaker=silence_maker_,
                                    name="silence maker")

rhythm_handler_one = evans.RhythmHandler(rmaker=rmaker_one,
                                         forget=False,
                                         name="rhythm_handler_one")
                i_staff.extend(list_)
            for _ in r_list:
                numbers = [n.number for n in _]
                list_ = []
                for note in numbers:
                    leaf = abjad.Note()
                    leaf.written_pitch = note
                    list_.append(leaf)
                r_staff.extend(list_)
            for _ in ri_list:
                numbers = [n.number for n in _]
                list_ = []
                for note in numbers:
                    leaf = abjad.Note()
                    leaf.written_pitch = note
                    list_.append(leaf)
                ri_staff.extend(list_)
            staff_group2.append(p_staff)
            staff_group2.append(i_staff)
            staff_group2.append(r_staff)
            staff_group2.append(ri_staff)
            staff_group1.append(staff_group2)
        score.append(staff_group1)
    sig = abjad.TimeSignature((n, 4))
    first_leaf = abjad.Selection(score).leaves()[0]
    abjad.attach(sig, first_leaf)
    abjad.persist.as_ly(
        score,
        f"/Users/gregoryevans/evans/research/pitch_patterns/divisions_of_{n}.ly",
    )
示例#23
0
import abjad
import abjadext.rmakers
import evans

from sim.materials.rhythm.segment_01.rhythm_makers import rmaker_one, rmaker_two

silence_maker_ = abjadext.rmakers.stack(
    abjadext.rmakers.NoteRhythmMaker(),
    abjadext.rmakers.force_rest(lambda _: abjad.Selection(_).leaves(pitched=True)),
)

silence_maker = evans.RhythmHandler(rmaker=silence_maker_, name="silence maker")

rhythm_handler_one = evans.RhythmHandler(
    rmaker=rmaker_one, forget=False, name="rhythm_handler_one"
)

rhythm_handler_two = evans.RhythmHandler(
    rmaker=rmaker_two, forget=False, name="rhythm_handler_two"
)
def test_Selection_are_contiguous_logical_voice_06():
    """
    Is true for empty selection.
    """

    assert abjad.Selection().are_contiguous_logical_voice()
示例#25
0
 def make_document_layout(self, path):
     score = self.make_score()
     leaves = abjad.Selection(score).leaves()
     no_breaks_literal = abjad.LilyPondLiteral(
         r"\autoPageBreaksOff", format_slot="before"
     )
     abjad.attach(no_breaks_literal, leaves[0])
     lbsd_values = self.lbsd(r=1)[0]
     lbsd_literal = abjad.LilyPondLiteral(
         rf"\evans-lbsd #{lbsd_values[0]} #'{lbsd_values[1]}", format_slot="before"
     )
     abjad.attach(lbsd_literal, leaves[0])
     x_offset = self.x_offsets(r=1)[0]
     x_offset_literal = abjad.LilyPondLiteral(
         rf"\evans-system-X-offset #{x_offset}", format_slot="before"
     )
     abjad.attach(x_offset_literal, leaves[0])
     for i, leaf in enumerate(leaves):
         # literal = abjad.LilyPondLiteral(r"\noBreak", format_slot="before")
         # abjad.attach(literal, leaf)
         test_case = i + 1
         if i in self.spacing_indices:
             space = self.spacing(r=1)[0][1]
             spacing_string = rf"\evans-new-spacing-section #{space[0]} #{space[1]}"
             spacing_literal = abjad.LilyPondLiteral(
                 spacing_string, format_slot="before"
             )
             abjad.attach(spacing_literal, leaf)
         else:
             if test_case in self.system_break_indices:
                 default_frac = Fraction(
                     self.default_spacing[0], self.default_spacing[1]
                 )
                 multiplier = Fraction(35, 24)
                 new_frac = default_frac * multiplier
                 spacing_string = rf"\evans-new-spacing-section #{new_frac.numerator} #{new_frac.denominator}"
             else:
                 spacing_string = rf"\evans-new-spacing-section #{self.default_spacing[0]} #{self.default_spacing[1]}"
             spacing_literal = abjad.LilyPondLiteral(
                 spacing_string, format_slot="before"
             )
             abjad.attach(spacing_literal, leaf)
     for page_break_index in self.page_break_indices:
         relevant_leaf = leaves[page_break_index - 1]
         literal = abjad.LilyPondLiteral(r"\pageBreak", format_slot="after")
         abjad.attach(literal, relevant_leaf)
     for system_break_index in self.system_break_indices:
         relevant_leaf = leaves[system_break_index - 1]
         literal = abjad.LilyPondLiteral(r"\break", format_slot="after")
         abjad.attach(literal, relevant_leaf)
         lbsd_values = self.lbsd(r=1)[0]
         lbsd_literal = abjad.LilyPondLiteral(
             rf"\evans-lbsd #{lbsd_values[0]} #'{lbsd_values[1]}",
             format_slot="after",
         )
         abjad.attach(lbsd_literal, relevant_leaf)
         x_offset = self.x_offsets(r=1)[0]
         x_offset_literal = abjad.LilyPondLiteral(
             rf"\evans-system-X-offset #{x_offset}", format_slot="after"
         )
         abjad.attach(x_offset_literal, relevant_leaf)
     for leaf in leaves:
         if not abjad.get.has_indicator(
             leaf, abjad.LilyPondLiteral(r"\break", format_slot="after")
         ):
             no_break = abjad.LilyPondLiteral(r"\noBreak", format_slot="after")
             abjad.attach(no_break, leaf)
     with open(f"{path}/layout.ly", "w") as fp:
         s = abjad.lilypond(score)
         fp.writelines(s)
示例#26
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     handler_commands,
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
示例#27
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     handler_commands,
     evans.call(
         "vertical",
         chorale_pitch_handler,
         evans.return_vertical_moment_ties,
     ),
     evans.call(
         "score",
示例#28
0
def ottava(argument: Union[abjad.Component, abjad.Selection],
           start_ottava: Union[int, abjad.Ottava, NumericOttava] = 1,
           stop_ottava: Union[int, abjad.Ottava, NumericOttava] = 0,
           *,
           numeric_ottava: bool = False,
           selector: abjad.Expression = abjad.select().leaves(),
           tag: abjad.Tag = None,
           ) -> None:
    r"""Attaches ottava indicators.

    Basic usage:
        Basic usage is identical to |abjad.ottava()|:

        >>> staff = abjad.Staff(r"c'''4 d'''4 e'''4 f'''4")
        >>> auxjad.ottava(staff[:])
        >>> abjad.f(staff)
        \new Staff
        {
            \ottava 1
            c'''4
            d'''4
            e'''4
            f'''4
            \ottava 0
        }

        .. figure:: ../_images/ottava-oVt2RCxQOv.png

    .. note::

        Auxjad automatically replaces its built-in |abjad.ottava()| with this
        function. Therefore it can be used either as :func:`auxjad.ottava()` or
        |abjad.ottava()|, as shown below:

        >>> staff1 = abjad.Staff(r"c'''4 d'''4 e'''4 f'''4")
        >>> staff2 = abjad.Staff(r"c'''4 d'''4 e'''4 f'''4")
        >>> auxjad.ottava(staff1[:])
        >>> abjad.ottava(staff2[:])
        >>> selections = [staff1[:], staff2[:]]
        >>> auxjad.inspect(selections).selections_are_identical()
        True

    Arguments:
        Second and third positional arguments can be :obj:`int`,
        |abjad.Ottava|, or :class:`auxjad.NumericOttava`:

        >>> staff = abjad.Staff(
        ...     r"c'''4 d'''4 e'''4 f'''4 g'''4 a'''4 b'''4 c''''4"
        ... )
        >>> auxjad.ottava(staff[:4], 1)
        >>> auxjad.ottava(staff[4:], 2)
        >>> abjad.f(staff)
        \new Staff
        {
            \ottava 1
            c'''4
            d'''4
            e'''4
            f'''4
            \ottava 0
            \ottava 2
            g'''4
            a'''4
            b'''4
            c''''4
            \ottava 0
        }

        .. figure:: ../_images/ottava-8kzdTxmmxR.png

    ``numeric_ottava``:
        Setting ``numeric_ottava`` to ``True`` will result in
        :class:`auxjad.NumericOttava` being used instead of the default
        |abjad.Ottava| when second argument is :obj:`int`:

        >>> staff = abjad.Staff(
        ...     r"c'''4 d'''4 e'''4 f'''4 g'''4 a'''4 b'''4 c''''4"
        ... )
        >>> auxjad.ottava(staff[:4], 1, numeric_ottava=True)
        >>> auxjad.ottava(staff[4:], 2, numeric_ottava=True)
        >>> abjad.f(staff)
        \new Staff
        {
            \ottava 1 \set Staff.ottavation = "8"
            c'''4
            d'''4
            e'''4
            f'''4
            \ottava 0
            \ottava 2 \set Staff.ottavation = "15"
            g'''4
            a'''4
            b'''4
            c''''4
            \ottava 0
        }

        .. figure:: ../_images/ottava-iYaIcOzIlk.png

        Numeric ottavation can also be used for ottava bassa notation:

        >>> staff = abjad.Staff(
        ...     r"\clef bass c,4 b,,4 a,,4 g,,4 f,,4 e,,4 d,,4 c,,4"
        ... )
        >>> auxjad.ottava(staff[:4], -1, numeric_ottava=True)
        >>> auxjad.ottava(staff[4:], -2, numeric_ottava=True)
        >>> abjad.f(staff)
        \new Staff
        {
            \ottava -1 \set Staff.ottavation = "8"
            \clef "bass"
            c,4
            b,,4
            a,,4
            g,,4
            \ottava 0
            \ottava -2 \set Staff.ottavation = "15"
            f,,4
            e,,4
            d,,4
            c,,4
            \ottava 0
        }

        .. figure:: ../_images/ottava-3iXC4vZmiu.png
    """
    if not isinstance(start_ottava, (int, abjad.Ottava, NumericOttava)):
        raise TypeError("'start_ottava' must be 'int', 'abjad.Ottava', or "
                        "'auxjad.NumericOttava'")
    if not isinstance(stop_ottava, (int, abjad.Ottava, NumericOttava)):
        raise TypeError("'stop_ottava' must be 'int', 'abjad.Ottava', or "
                        "'auxjad.NumericOttava'")
    if not isinstance(numeric_ottava, bool):
        raise TypeError("'numeric_ottava' must be 'bool'")
    assert isinstance(selector, abjad.Expression)
    if isinstance(start_ottava, int):
        if numeric_ottava:
            start_ottava = NumericOttava(start_ottava)
        else:
            start_ottava = abjad.Ottava(start_ottava)
    if isinstance(stop_ottava, int):
        if numeric_ottava:
            stop_ottava = NumericOttava(stop_ottava, format_slot='after')
        else:
            stop_ottava = abjad.Ottava(stop_ottava, format_slot='after')
    argument = selector(argument)
    leaves = abjad.Selection(argument).leaves()
    start_leaf = leaves[0]
    stop_leaf = leaves[-1]
    abjad.attach(start_ottava, start_leaf, tag=tag)
    abjad.attach(stop_ottava, stop_leaf, tag=tag)
示例#29
0
commands = [
    evans.detach(
        "Voice 1",
        abjad.Tie(),
        baca.selectors.leaf(26),
    ),
    evans.attach(
        "Voice 1",
        abjad.Dynamic("pp"),
        baca.selectors.leaf(26),
    ),
    evans.replace(
        "Voice 1",
        measure_30_trem,
        lambda _: abjad.Selection(_).tuplets().get([3]),
    ),
]

maker = evans.SegmentMaker(
    instruments=insts,
    names=[r'"Flute"'],
    score_template=score,
    time_signatures=time_signatures,
    clef_handlers=clef_handlers,
    commands=[
        rhythm_commands,
        evans.call(
            "score",
            evans.SegmentMaker.transform_brackets,
            lambda _: abjad.Selection(_).components(abjad.Score),
示例#30
0
     '"Viola"',
     '"Violoncello"',
 ],
 abbreviations=[
     '"vn. I"',
     '"vn. II"',
     '"va."',
     '"vc."',
 ],
 name_staves=True,
 commands=[
     rhythm_commands,
     evans.call(
         "score",
         evans.SegmentMaker.transform_brackets,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.call(
         "score",
         evans.SegmentMaker.rewrite_meter,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     "skips",
     evans.call(
         "score",
         evans.SegmentMaker.beam_score,
         lambda _: abjad.Selection(_).components(abjad.Score),
     ),
     evans.attach(
         "Global Context",
         abjad.Markup(