Пример #1
0
def silence_and_rhythm_maker(maker, annotated_divisions, *commands):
    rest_maker = rmakers.stack(rmakers.note(), rmakers.force_rest(abjad.select()))

    my_stack_voice = abjad.Container()

    for dur in annotated_divisions:
        if dur.annotation.startswith("Rests ") is True:
            rests = rest_maker([dur])
            my_stack_voice.extend(rests)
        else:
            selection = maker([dur], *commands)
            my_stack_voice.extend(selection)
    return my_stack_voice
Пример #2
0
def guitar_bitones_test():
    print(
        "Running guitar bitones test using ``muda.Material.guitar_bitones()`` method."
    )
    timespans = muda.alternating_timespans([[1, 1], [1, 1], [1, 1]], 4,
                                           ["matA", "matB"])
    durations = timespans.annotated_durations(subdivision=(2, 4))
    makers = {
        "matA": rmakers.stack(rmakers.note()),
        "matB": rmakers.stack(rmakers.note())
    }
    mat = muda.Material("A")
    mat.alternating_materials(durations, makers)
    pitches = {
        "matA": abjad.PitchSegment("fs'"),
        "matB": abjad.PitchSegment("ds'"),
    }
    pitched_leaves = lambda _: abjad.select.leaves(_)
    mat.write_pitches_by_name(pitches)
    mat.attach(abjad.StringNumber([2]), pitched_leaves, "matA")
    mat.attach(abjad.StringNumber([3]), pitched_leaves, "matB")
    mat.guitar_bitones(pitched_leaves, "matA", hammering=True)
    mat.print()
Пример #3
0
def make_rests(*, measures: typings.SliceTyping = None) -> RhythmCommand:
    """
    Makes rests.
    """
    return RhythmCommand(
        rmakers.stack(
            rmakers.note(),
            rmakers.force_rest(classes.select().lts()),
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
Пример #4
0
def make_tied_notes(*, measures: typings.SliceTyping = None) -> RhythmCommand:
    """
    Makes tied notes; rewrites meter.
    """
    return RhythmCommand(
        rmakers.stack(
            rmakers.note(),
            rmakers.beam(classes.select().plts()),
            rmakers.tie(classes.select().ptails()[:-1]),
            rmakers.rewrite_meter(),
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
Пример #5
0
def make_tied_repeated_durations(
    durations: typing.Sequence[abjad.DurationTyping],
    *,
    measures: typings.SliceTyping = None,
) -> RhythmCommand:
    """
    Makes tied repeated durations; does not rewrite meter.
    """
    specifiers: typing.List[rmakers.Command] = []
    if isinstance(durations, abjad.Duration):
        durations = [durations]
    elif isinstance(durations, tuple):
        assert len(durations) == 2
        durations = [abjad.Duration(durations)]
    tie_specifier: rmakers.Command
    tie_specifier = rmakers.repeat_tie(classes.select().pheads()[1:])
    specifiers.append(tie_specifier)
    tie_specifier = rmakers.force_repeat_tie()
    specifiers.append(tie_specifier)

    def preprocessor(divisions):
        divisions = classes.Sequence(divisions)
        divisions = divisions.fuse()
        divisions = divisions.split_divisions(durations, cyclic=True)
        return divisions

    return RhythmCommand(
        rmakers.stack(
            rmakers.note(),
            *specifiers,
            preprocessor=preprocessor,
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
Пример #6
0
def make_repeated_duration_notes(
    durations: typing.Sequence[abjad.DurationTyping],
    *specifiers: rmakers.Command,
    do_not_rewrite_meter: bool = None,
    measures: typings.SliceTyping = None,
) -> RhythmCommand:
    """
    Makes repeated-duration notes; rewrites meter.
    """
    if isinstance(durations, abjad.Duration):
        durations = [durations]
    elif isinstance(durations, tuple):
        assert len(durations) == 2
        durations = [abjad.Duration(durations)]

    def preprocessor(divisions):
        divisions = classes.Sequence(divisions)
        divisions = divisions.fuse()
        divisions = divisions.split_divisions(durations, cyclic=True)
        return divisions

    rewrite_specifiers: typing.List[rmakers.Command] = []
    if not do_not_rewrite_meter:
        rewrite_specifiers.append(rmakers.rewrite_meter())
    return RhythmCommand(
        rmakers.stack(
            rmakers.note(),
            *specifiers,
            *rewrite_specifiers,
            rmakers.force_repeat_tie(),
            preprocessor=preprocessor,
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
Пример #7
0
def make_notes(
    *specifiers,
    measures: typings.SliceTyping = None,
    repeat_ties: bool = False,
) -> RhythmCommand:
    """
    Makes notes; rewrites meter.
    """
    if repeat_ties:
        repeat_tie_specifier = [rmakers.force_repeat_tie()]
    else:
        repeat_tie_specifier = []
    return RhythmCommand(
        rmakers.stack(
            rmakers.note(),
            *specifiers,
            rmakers.rewrite_meter(),
            *repeat_tie_specifier,
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
Пример #8
0
rmaker_afluteA = rmakers.stack(
    rmakers.talea([4, -2, 1], 8),
    rmakers.extract_trivial(),  # counts  # denominator
    tag=abjad.Tag("Mat_A"),
)

rmaker_afluteB = rmakers.stack(
    rmakers.talea([1], 8, extra_counts=[1]),
    rmakers.beam(),
    rmakers.extract_trivial(),  # counts  # denominator
    # rmakers.rewrite_meter(),
    tag=abjad.Tag("Mat_B"),
)

rest_maker = rmakers.stack(rmakers.note(),
                           rmakers.force_rest(abjad.select()),
                           tag=abjad.Tag("Rests"))

rmaker_bclarinetA = rmakers.stack(
    rmakers.talea([-4, 2], 8),  # counts  # denominator
    rmakers.beam(),
    rmakers.extract_trivial(),
    tag=abjad.Tag("Mat_A"),
)
rmaker_bclarinetB = rmakers.stack(
    rmakers.talea([1], 8, extra_counts=[1]),
    rmakers.beam(),
    rmakers.extract_trivial(),  # counts  # denominator
    # rmakers.rewrite_meter(),
    tag=abjad.Tag("Mat_B"),
Пример #9
0
def make_repeat_tied_notes(
    *specifiers: rmakers.Command,
    do_not_rewrite_meter: bool = None,
    measures: typings.SliceTyping = None,
) -> RhythmCommand:
    r"""
    Makes repeat-tied notes; rewrites meter.

    ..  container:: example

        REGRESSION. All notes below are tagged NOT_YET_PITCHED_COLORING (and
        colored gold), even tied notes resulting from meter rewriting:

        >>> maker = baca.SegmentMaker(
        ...     score_template=baca.SingleStaffScoreTemplate(),
        ...     spacing=baca.minimum_duration((1, 12)),
        ...     time_signatures=[(10, 8)],
        ...     )

        >>> maker(
        ...     'Music_Voice',
        ...     baca.make_repeat_tied_notes(),
        ...     )

        >>> lilypond_file = maker.run(environment='docs')
        >>> abjad.show(lilypond_file) # doctest: +SKIP

        ..  docs::

            >>> string = abjad.lilypond(lilypond_file[abjad.Score])
            >>> print(string)
            <BLANKLINE>
            \context Score = "Score"
            <<
            <BLANKLINE>
                \context GlobalContext = "Global_Context"
                <<
            <BLANKLINE>
                    \context GlobalSkips = "Global_Skips"
                    {
            <BLANKLINE>
                        % [Global_Skips measure 1]
                        \baca-new-spacing-section #1 #12
                        \time 10/8
                        \baca-time-signature-color #'blue
                        s1 * 5/4
            <BLANKLINE>
                        % [Global_Skips measure 2]
                        \baca-new-spacing-section #1 #4
                        \time 1/4
                        \baca-time-signature-transparent
                        s1 * 1/4
                        \once \override Score.BarLine.transparent = ##t
                        \once \override Score.SpanBar.transparent = ##t
            <BLANKLINE>
                    }
            <BLANKLINE>
                >>
            <BLANKLINE>
                \context MusicContext = "Music_Context"
                <<
            <BLANKLINE>
                    \context Staff = "Music_Staff"
                    {
            <BLANKLINE>
                        \context Voice = "Music_Voice"
                        {
            <BLANKLINE>
                            % [Music_Voice measure 1]
                            \baca-not-yet-pitched-coloring
                            b'4.
                            - \abjad-dashed-line-with-hook
                            - \baca-text-spanner-left-text "make_repeat_tied_notes()"
                            - \tweak bound-details.right.padding 2.75
                            - \tweak color #darkcyan
                            - \tweak staff-padding 8
                            \bacaStartTextSpanRhythmAnnotation
                            - \tweak stencil ##f
                            ~
            <BLANKLINE>
                            \baca-not-yet-pitched-coloring
                            b'4
                            \repeatTie
                            - \tweak stencil ##f
                            ~
            <BLANKLINE>
                            \baca-not-yet-pitched-coloring
                            b'4.
                            \repeatTie
                            - \tweak stencil ##f
                            ~
            <BLANKLINE>
                            \baca-not-yet-pitched-coloring
                            b'4
                            \repeatTie
                            <> \bacaStopTextSpanRhythmAnnotation
            <BLANKLINE>
                            <<
            <BLANKLINE>
                                \context Voice = "Music_Voice"
                                {
            <BLANKLINE>
                                    % [Music_Voice measure 2]
                                    \abjad-invisible-music-coloring
                                    %@% \abjad-invisible-music
                                    \baca-not-yet-pitched-coloring
                                    b'1 * 1/4
                                    %@% ^ \baca-duration-multiplier-markup #"1" #"4"
            <BLANKLINE>
                                }
            <BLANKLINE>
                                \context Voice = "Rest_Voice"
                                {
            <BLANKLINE>
                                    % [Rest_Voice measure 2]
                                    \once \override Score.TimeSignature.X-extent = ##f
                                    \once \override MultiMeasureRest.transparent = ##t
                                    \stopStaff
                                    \once \override Staff.StaffSymbol.transparent = ##t
                                    \startStaff
                                    R1 * 1/4
                                    %@% ^ \baca-duration-multiplier-markup #"1" #"4"
            <BLANKLINE>
                                }
            <BLANKLINE>
                            >>
            <BLANKLINE>
                        }
            <BLANKLINE>
                    }
            <BLANKLINE>
                >>
            <BLANKLINE>
            >>

    """
    specifier: rmakers.Command
    specifiers_ = list(specifiers)
    specifier = rmakers.beam(classes.select().plts())
    specifiers_.append(specifier)
    specifier = rmakers.repeat_tie(classes.select().pheads()[1:])
    specifiers_.append(specifier)
    if not do_not_rewrite_meter:
        command = rmakers.rewrite_meter()
        specifiers_.append(command)
    specifier = rmakers.force_repeat_tie()
    specifiers_.append(specifier)
    return RhythmCommand(
        rmakers.stack(rmakers.note(),
                      *specifiers_,
                      tag=_site(inspect.currentframe())),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
    )