예제 #1
0
def music(
    location,
    rmaker,
    *args,
    forget=False,
    preprocessor=None,
    rewrite_meter=None,
):
    commands = []
    arguments = []
    for arg in args:
        if issubclass(arg.__class__, rmakers.Command):
            commands.append(arg)
        else:
            arguments.append(arg)
    if rewrite_meter is not None:
        stack = rmakers.stack(
            rmaker,
            *commands,
            rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
            rmakers.rewrite_rest_filled(
                lambda _: abjad.Selection(_).tuplets()),
            rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
            rmakers.extract_trivial(),
            rmakers.RewriteMeterCommand(
                boundary_depth=rewrite_meter,
                reference_meters=[
                    abjad.Meter((4, 4))
                ],  # reference meters is for constructing special offset inventories (i.e. akasha 6/8)
            ),
            preprocessor=preprocessor,
        )
        handler = RhythmHandler(
            stack,
            forget=forget,
        )
    else:
        stack = rmakers.stack(
            rmaker,
            *commands,
            rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
            rmakers.rewrite_rest_filled(
                lambda _: abjad.Selection(_).tuplets()),
            rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
            rmakers.extract_trivial(),
            preprocessor=preprocessor,
        )
        handler = RhythmHandler(
            stack,
            forget=forget,
        )

    out = MusicCommand(
        location,
        handler,
        *arguments,
    )
    return out
예제 #2
0
def make_single_attack(duration,
                       *,
                       measures: typings.SliceTyping = None) -> RhythmCommand:
    """
    Makes single attacks with ``duration``.
    """
    duration = abjad.Duration(duration)
    numerator, denominator = duration.pair
    return RhythmCommand(
        rmakers.stack(
            rmakers.incised(
                fill_with_rests=True,
                outer_divisions_only=True,
                prefix_talea=[numerator],
                prefix_counts=[1],
                talea_denominator=denominator,
            ),
            rmakers.beam(),
            rmakers.extract_trivial(),
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
예제 #3
0
def make_fused_tuplet_monads(
    *,
    measures: typings.SliceTyping = None,
    tuplet_ratio: typing.Tuple[int] = None,
) -> RhythmCommand:
    """
    Makes fused tuplet monads.
    """
    tuplet_ratios = []
    if tuplet_ratio is None:
        tuplet_ratios.append((1, ))
    else:
        tuplet_ratios.append(tuplet_ratio)
    return RhythmCommand(
        rmakers.stack(
            rmakers.tuplet(tuplet_ratios),
            rmakers.beam(),
            rmakers.rewrite_rest_filled(),
            rmakers.trivialize(),
            rmakers.extract_trivial(),
            rmakers.force_repeat_tie(),
            preprocessor=lambda _: classes.Sequence(
                [classes.Sequence(_).sum()]),
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
예제 #4
0
def intercalate_silences(rhythm_command_list, voice_names=None):
    global_timespan = abjad.Timespan(
        start_offset=0,
        stop_offset=max(_.timespan.stop_offset for _ in rhythm_command_list),
    )
    silence_maker = handlers.RhythmHandler(
        rmakers.stack(
            rmakers.NoteRhythmMaker(),
            rmakers.force_rest(
                lambda _: abjad.Selection(_).leaves(pitched=True)),
        ),
        name="silence_maker",
    )
    if voice_names is None:
        voice_names = sorted(set(_.voice_name for _ in rhythm_command_list))
    for voice_name in voice_names:
        timespan_list = abjad.TimespanList([
            _.timespan for _ in rhythm_command_list
            if _.voice_name == voice_name
        ])
        silences = abjad.TimespanList([global_timespan])
        for timespan in timespan_list:
            silences -= timespan
        for timespan in silences:
            new_command = RhythmCommand(
                voice_name,
                timespan,
                silence_maker,
            )
            rhythm_command_list.append(new_command)
예제 #5
0
파일: scoreTest.py 프로젝트: grrrr/rill
    def make_music(self, durations, denominator, divisions, pitches):
        # make rhythm with one tuplet per division
        stack = rmakers.stack(
            rmakers.talea(
                durations,
                denominator, 
                extra_counts=(0, 0, 0),
            ),
            rmakers.beam()
        )
        selection = stack(divisions)

        # attach time signature to first leaf in each tuplet
        assert len(divisions) == len(selection)
        for division, tuplet in zip(divisions, selection):
            time_signature = abjad.TimeSignature(division)
            leaf = abjad.select(tuplet).leaf(0)
            abjad.attach(time_signature, leaf)
 
        # apply pitch material
        cyclic_tuple = abjad.CyclicTuple(pitches) 
        iterator = abjad.iterate(selection).logical_ties(pitched=True) # make iterator out of selection using logical ties as virtual measures
        iterator = enumerate(iterator) # makes enum out of iterator  
        for index, logical_tie in iterator:
            print("entered the loop make_music")
            pitch = cyclic_tuple[index]
            print(pitch)
            for old_leaf in logical_tie:
                print("here is the old leaf: ", old_leaf)
                if isinstance(pitch, int):
                    print("in if pitch is still", pitch)
                    old_leaf.written_pitch = pitch
                    print(old_leaf)
                elif isinstance(pitch, list):
                    print("entered elif")
                    print("pitch is still", pitch)
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    print("this is the new leaf: ", new_leaf)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)
                elif isinstance(pitch, abjad.Chord):
                    print("entered elif")
                    print("pitch is still", pitch)
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    print("this is the new leaf: ", new_leaf)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)

        # remove trivial 1:1 tuplets
        self.staff.extend(selection)
        command = rmakers.extract_trivial()
        command(selection)
예제 #6
0
    def make_phrase(self, durations, denominator, divisions, pitches):
        # make rhythm with one tuplet per division
        stack = rmakers.stack(
            rmakers.talea(
                durations,
                denominator,
                extra_counts=(0, 0, 0),
            ),
            rmakers.beam()
        )
        selection = stack(divisions)

        # attach time signature to first leaf in each tuplet
        assert len(divisions) == len(selection)
        previous_time_signature = None
        for division, tuplet in zip(divisions, selection):
            time_signature = abjad.TimeSignature(division)
            leaf = abjad.select(tuplet).leaf(0)
            if time_signature != previous_time_signature:
                abjad.attach(time_signature, leaf)
                previous_time_signature = time_signature

        # apply pitch material
        cyclic_tuple = abjad.CyclicTuple(pitches)
        iterator = abjad.iterate(selection).logical_ties(pitched=True) # make iterator out of selection using logical ties as virtual measures
        iterator = enumerate(iterator) # makes enum out of iterator
        for index, logical_tie in iterator:
            pitch = cyclic_tuple[index]
            for old_leaf in logical_tie:
                if isinstance(pitch, int):
                    old_leaf.written_pitch = pitch
                elif isinstance(pitch, str):
    # warning: was formerly checking for list    import rill.tools.FuzzyHarmony as FuzzyHarmony
    #import rill.tools.PhraseMaker as PhraseMaker
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)
                elif isinstance(pitch, abjad.Chord):
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)

        # remove trivial 1:1 tuplets
        self.container.extend(selection)
        command = rmakers.extract_trivial()
        command(selection)
예제 #7
0
파일: rhythm.py 프로젝트: DaviRaubach/muda
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
예제 #8
0
파일: tests.py 프로젝트: DaviRaubach/muda
def material_test():
    print(
        "Running material test using ``muda.Material()`` class and its methods."
    )
    timespans = muda.alternating_timespans([[1, 1], [1, 1], [1, 1]], 2,
                                           ["matA", "matB"])
    durations = timespans.annotated_durations(subdivision=(2, 4))
    makers = {
        "matA":
        rmakers.stack(rmakers.talea([-1, 2, -1], 16),
                      rmakers.extract_trivial()),
        "matB":
        rmakers.stack(rmakers.talea([1, 1, 1, 1], 16),
                      rmakers.extract_trivial()),
    }
    mat = muda.Material("A")
    mat.alternating_materials(durations, makers)
    pitches = {
        "matA": abjad.PitchSegment("fs'"),
        "matB": abjad.PitchSegment("ds'"),
    }
    mat.write_pitches_by_name(pitches)
    mat.material_name_markups(["matA", "matB"])
예제 #9
0
파일: tests.py 프로젝트: DaviRaubach/muda
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()
예제 #10
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,
    )
예제 #11
0
def make_even_divisions(*,
                        measures: typings.SliceTyping = None) -> RhythmCommand:
    """
    Makes even divisions.
    """
    return RhythmCommand(
        rmakers.stack(
            rmakers.even_division([8]),
            rmakers.beam(),
            rmakers.extract_trivial(),
            tag=_site(inspect.currentframe()),
        ),
        annotation_spanner_color="#darkcyan",
        frame=inspect.currentframe(),
        measures=measures,
    )
예제 #12
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,
    )
예제 #13
0
 def _make_selection(
     self,
     time_signatures: typing.Sequence[abjad.IntegerPair],
     runtime: abjad.OrderedDict = None,
 ) -> abjad.Selection:
     """
     Calls ``RhythmCommand`` on ``time_signatures``.
     """
     rhythm_maker = self.rhythm_maker
     selection: abjad.Selection
     if isinstance(rhythm_maker, abjad.Selection):
         selection = rhythm_maker
         total_duration = sum([_.duration for _ in time_signatures])
         selection_duration = abjad.get.duration(selection)
         if (not self.do_not_check_total_duration
                 and selection_duration != total_duration):
             message = f"selection duration ({selection_duration}) does not"
             message += f" equal total duration ({total_duration})."
             raise Exception(message)
     else:
         rcommand: rmakers.Stack
         if isinstance(self.rhythm_maker, rmakers.Stack):
             rcommand = self.rhythm_maker
         else:
             rcommand = rmakers.stack(self.rhythm_maker)
         previous_segment_stop_state = self._previous_segment_stop_state(
             runtime)
         if isinstance(rcommand, rmakers.Stack):
             selection = rcommand(
                 time_signatures,
                 previous_state=previous_segment_stop_state)
             self._state = rcommand.maker.state
         else:
             selection = rcommand(
                 time_signatures,
                 previous_segment_stop_state=previous_segment_stop_state,
             )
             self._state = rcommand.state
     assert isinstance(selection, abjad.Selection), repr(selection)
     if self.attach_not_yet_pitched or not isinstance(
             self.rhythm_maker, abjad.Selection):
         container = abjad.Container(selection, name="Dummy")
         self._attach_not_yet_pitched_(container)
         container[:] = []
     self._attach_rhythm_annotation_spanner(selection)
     return selection
예제 #14
0
def rhythm(
    *arguments,
    frame=None,
    preprocessor: abjad.Expression = None,
    measures: typings.SliceTyping = None,
    persist: str = None,
    tag: abjad.Tag = None,
) -> RhythmCommand:
    """
    Makes rhythm command from ``argument``.
    """
    if tag is not None:
        assert isinstance(tag, abjad.Tag), repr(tag)
    argument = rmakers.stack(*arguments, preprocessor=preprocessor, tag=tag)
    return RhythmCommand(
        argument,
        attach_not_yet_pitched=True,
        frame=frame,
        measures=measures,
        persist=persist,
    )
예제 #15
0
파일: sketches.py 프로젝트: grrrr/rill
    def make_music(self, durations, denominator, divisions, pitches):
        # make rhythm with one tuplet per division
        stack = rmakers.stack(
            rmakers.talea(
                durations,
                denominator,
                extra_counts=None,
            ),
            rmakers.beam(),
        )
        selection = stack(divisions)

#        # attach time signature to first leaf in each tuplet
#        assert len(divisions) == len(selection)
#        for division, tuplet in zip(divisions, selection):
#            time_signature = abjad.TimeSignature(division)
#            leaf = abjad.select(tuplet).leaf(0)
#            abjad.attach(time_signature, leaf)
#
        # apply pitches
        cyclic_tuple = abjad.CyclicTuple(pitches)
        iterator = abjad.iterate(selection).logical_ties(pitched=True)
        iterator = enumerate(iterator)
        for index, logical_tie in iterator:
            pitch = cyclic_tuple[index]
            for old_leaf in logical_tie:
                if isinstance(pitch, int):
                    old_leaf.written_pitch = pitch
                elif isinstance(pitch, list):
                    new_leaf = abjad.Chord(pitch, old_leaf.written_duration)
                    indicators = abjad.inspect(old_leaf).indicators()
                    if indicators != None:
                        for indicator in indicators:
                            abjad.attach(indicator, new_leaf)
                    abjad.mutate(old_leaf).replace(new_leaf)

        # remove trivial 1:1 tuplets
        self.staff.extend(selection)
        command = rmakers.extract_trivial()
        command(selection)
예제 #16
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,
    )
예제 #17
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,
    )
예제 #18
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,
    )
예제 #19
0
import evans
from abjadext import rmakers

rmaker_one = evans.RTMMaker(rtm=[
    "(1 ((3 (1 1 1)) 1 2 2))",
    "(1 (1 2 2 3))",
    "(1 ((2 (1 1)) 2 3 1))",
    "(1 ((2 (1 1)) 3 1 2))",
])

rmaker_two = rmakers.stack(
    rmakers.talea(
        [3, -1, 2, -2, 3, 1, 2, 2, -3, 1, -2, 2],
        4,
        extra_counts=[0, 3, -1, 2, -2, 0, 3, 1, 2, 2, 0, -3, 1, -2, 2],
    ),
    rmakers.trivialize(abjad.select().tuplets()),
    rmakers.extract_trivial(abjad.select().tuplets()),
    rmakers.rewrite_rest_filled(abjad.select().tuplets()),
    rmakers.rewrite_sustained(abjad.select().tuplets()),
)

rmaker_three = evans.RTMMaker(rtm=[
    "(1 (2 2 1 3))",
    "(1 (2 2 1 4))",
    "(1 (3 3 3 5))",
    "(1 (4 4 4 5))",
    "(1 (4 4 3 4))",
    # "(1 (5 4 4 5))",
    "(1 (2 1 1 2))",
    # "(1 (5 5 5 5))",
# 4 _ _ _ 1 4 _ _ _ 1 4 _ _ _ 1 4 _ _ _ 1
#       3 _ _ 2 _ 3 _ _ 2 _
#           2 _ 2 _ 2 _ 2 _ 2

# 4 _ _ _ 4 _ \ _ _ 1 3 _ _ \ 1 3 _ _ 1 2 _ 1 2 _ 1 1
# 1 2 _ 1 2 _ \ 1 3 _ _ 1 3 \ _ _ 1 2 _ 1 2 _ 1 1
# 2 _ 3 _ _ 4 \ _ _ _ 1 3 _ \ _ 1 2 _ 1 2 _ 1 1

# TALEA RHYTHM MAKER
selector = abjad.select().tuplets()[:-1]
selector = selector.map(abjad.select().note(-1))
rhythm_maker_voice_two = rmakers.stack(
    rmakers.talea(
        [4, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1, 1],  # counts
        8,  # denominator
    ),
    # rmakers.beam(),
    rmakers.extract_trivial(),
    rmakers.tie(selector),
)

rhythm_maker_voice_three = rmakers.stack(
    rmakers.talea(
        [1, 2, 1, 2, 1, 3, 1, 3, 1, 2, 1, 2, 1, 1],  # counts
        8,  # denominator
    ),
    # rmakers.beam(),
    rmakers.extract_trivial(),
    rmakers.tie(selector),
)
예제 #21
0
import abjad
import abjadext.rmakers as rmakers
import evans
import random

# THOSE CHORDS IN VOICE FIVE (once was one)
rhythm_maker_voice_five = rmakers.stack(
    rmakers.talea(
        [2, 1, 3],  # counts
        8,  # denominator
    ),
    # rmakers.beam(),
    rmakers.extract_trivial(),
    # rmakers.tie(selector),
)

# MATERIAL FROM SEGMENT 2 AND 3
# REST LIST
rest_list = evans.e_dovan_cycle(n=2, iters=16, first=1, second=1, modulus=5)
rest_list.sort(reverse=True)

# NOTE LIST VOICE TWO
note_list_voice_two = [4, 1]
non_cyc_generator = evans.CyclicList(lst=note_list_voice_two,
                                     continuous=False,
                                     count=1)
new_note_list_voice_two = non_cyc_generator(r=40)

# NOTE + REST = TALEA VOICE TWO
note_and_rest_voice_two = []
note_sublist_voice_two = []
예제 #22
0
import abjad
import abjadext.rmakers as rmakers
import random
import organi

voz = abjad.Voice()
selector = abjad.select().tuplets()[:-1]
selector = selector.map(abjad.select().note(-1))
rhythm = rmakers.stack(
    rmakers.talea(
        [7, 7, 7, 7],  # counts
        8,  # denominator
    ),
    # rmakers.beam(),
    rmakers.denominator((1, 8)),
    rmakers.extract_trivial(),
    # rmakers.tie(selector),
)
divisions = [(4, 8)] * 7
measures = rhythm(divisions)
voz = abjad.Voice(
    measures)  # NEED TO PUT IN A CONTAINER TO SEPARATE WELL THE LOGICAL TIES
logical_ties = abjad.select(voz).leaves().logical_ties(pitched=True)
logical_ties

voz_time = abjad.Voice("s2 s2 s2 s2 s2 s2 s2 s2 s2 s2 s2 s2 s2 s2 s4 s1")
abjad.Staff(voz, voz_time)

time_signatures = []
for item in divisions:
    time_signatures.append(abjad.TimeSignature(item))
예제 #23
0
            abjad.detach(signature, skips[i])
            abjad.attach(new_signature, skips[i])

ts_staff = abjad.Staff(skips,
                       lilypond_type="TimeSignatureContext",
                       name="globalcontext")

selector = abjad.select().notes().exclude([0, 1, 3, 4, -1])
selector = abjad.select().tuplets().map(selector)
stack = rmakers.stack(
    rmakers.tuplet([(1, 2, 4, 1, 1, 1)]),
    rmakers.force_rest(selector),
    rmakers.before_grace_container(
        [1, 2, 1],
        abjad.select().tuplets().map(
            abjad.select().logical_ties(pitched=True).exclude([0, 3, 4, 5])),
    ),
    rmakers.rewrite_dots(abjad.select().tuplets().get([1])),
    rmakers.trivialize(abjad.select().tuplets()),
    rmakers.extract_trivial(abjad.select().tuplets()),
    rmakers.rewrite_rest_filled(abjad.select().tuplets()),
    rmakers.rewrite_sustained(abjad.select().tuplets()),
)
stack2 = rmakers.stack(
    rmakers.talea([3, 1, 4, -1, 5, 9], 8, extra_counts=[1, 3, 5]),
    rmakers.trivialize(abjad.select().tuplets()),
    rmakers.extract_trivial(abjad.select().tuplets()),
    rmakers.rewrite_rest_filled(abjad.select().tuplets()),
    rmakers.rewrite_sustained(abjad.select().tuplets()),
)

selection1 = stack([time_signatures[0]])
예제 #24
0
import abjad
import evans
from abjadext import rmakers

silence_maker = rmakers.stack(
    rmakers.NoteRhythmMaker(),
    rmakers.force_rest(abjad.select().leaves(pitched=True)),
)

silence_handler = evans.RhythmHandler(
    rmaker=silence_maker,
    forget=True,
    name="silence_handler",
)

##
##

note_maker = rmakers.stack(rmakers.NoteRhythmMaker(), )

note_handler = evans.RhythmHandler(
    rmaker=note_maker,
    forget=True,
    name="note_handler",
)

##
##

anuran_maker = rmakers.stack(
    evans.RTMMaker([
예제 #25
0
time_signatures = []
for item in durations:
    if isinstance(item, list):
        for i in item:
            time_signatures.append(abjad.TimeSignature(i))
    else:
        time_signatures.append(abjad.TimeSignature(item))

# time_signatures = timespans.time_signatures()

# It is a list of durations where each one is annotated with
# the material name.

# Rhythms of each material
makers = {
    "matL": rmakers.stack(rmakers.talea([2, 1, -1], 16), rmakers.extract_trivial()),
    "matK": rmakers.stack(
        rmakers.talea([1, 1, 1, 1, 1], 32, extra_counts=[1]),
        rmakers.extract_trivial(),
    ),
    "matJ": rmakers.stack(
        rmakers.talea([-1, 1, -1], 8, extra_counts=[1]), rmakers.extract_trivial()
    ),
    "matI": rmakers.stack(
        rmakers.talea([1, 1, 1], 4, extra_counts=[1]), rmakers.extract_trivial()
    ),
    "matH": rmakers.stack(
        rmakers.talea([-3, -2, 1, -3, -3], 16, extra_counts=[4]),
        rmakers.extract_trivial(),
    ),
    "matG": rmakers.stack(
예제 #26
0
    divisions = evans.BacaSequence(divisions).flatten(depth=-1)
    return divisions


commands = [
    rmakers.trivialize(lambda _: abjad.Selection(_).tuplets()),
    rmakers.rewrite_rest_filled(lambda _: abjad.Selection(_).tuplets()),
    rmakers.rewrite_sustained(lambda _: abjad.Selection(_).tuplets()),
    rmakers.extract_trivial(),
    rmakers.RewriteMeterCommand(
        boundary_depth=-1,
        reference_meters=[
            abjad.Meter((6, 8)),
            abjad.Meter((9, 8)),
        ],
    ),
]

stack = rmakers.stack(
    rmaker,
    *commands,
    preprocessor=quarters,
)

divisions = [(6, 8), (9, 8)]

selections = stack(divisions)

lilypond_file = rmakers.helpers.example(selections, divisions)
abjad.show(lilypond_file)
예제 #27
0
import abjad
import math
from abjadext import rmakers

selector = abjad.select().notes().exclude([0, 1, 3, 4, -1])
selector = abjad.select().tuplets().map(selector)
stack = rmakers.stack(
    rmakers.tuplet([(1, 2, 4, 1, 1, 1)]),
    rmakers.force_rest(selector),
    rmakers.before_grace_container([0, 2, 3],
                                   abjad.select().logical_ties(pitched=True)),
)
time_signatures = [
    abjad.TimeSignature((3, 4)),
    abjad.TimeSignature((7, 8)),
    abjad.TimeSignature((3, 8)),
    abjad.TimeSignature((4, 4)),
]
selection = stack(time_signatures)

skips = [abjad.Skip((1, 1)) for signature in time_signatures]

for skip, signature in zip(skips, time_signatures):
    skip.multiplier = abjad.Multiplier(signature.pair)
    abjad.attach(signature, skip)

ts_staff = abjad.Staff(skips,
                       lilypond_type="TimeSignatureContext",
                       name="globalcontext")

staff = abjad.Staff(selection, name="staffname")
예제 #28
0
import abjad
import abjadext.rmakers as rmakers
import muda

durations_general = [(4, 4)] * 32

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(
예제 #29
0
파일: voices.py 프로젝트: jgarte/evans
                    [
                        abjad.Voice(
                            "c'8 c'8 c'8 c'8 c'8 c'8 c'8 c'8",
                            name="Voice 2",
                        )
                    ],
                    name="Staff 2",
                ),
            ],
            name="group",
        )
    ],
    name="Score",
)

h = evans.IntermittentVoiceHandler(
    evans.RhythmHandler(
        rmakers.stack(evans.RTMMaker([
            "(1 (1 1 1))",
        ]), ),
        forget=False,
    ),
    direction=abjad.Up,
)

selector = abjad.select().leaf(1)
target = selector(score["Voice 1"])
h(target)

abjad.show(score)
예제 #30
0
    (5, 4),
    (6, 4),
    (5, 4),
    (4, 4),
    (3, 4),
    (2, 4),
]

nonlast_tuplets = abjad.select().tuplets()[:-1]
last_leaf = abjad.select().leaf(-1)

s = rmakers.stack(
    evans.RTMMaker(final_rtm_list),
    rmakers.force_rest(abjad.select().leaves().get([0, -2, -1])),
    rmakers.tie(nonlast_tuplets.map(last_leaf)),
    rmakers.trivialize(abjad.select().tuplets()),
    rmakers.extract_trivial(abjad.select().tuplets()),
    rmakers.rewrite_rest_filled(abjad.select().tuplets()),
    rmakers.rewrite_sustained(abjad.select().tuplets()),
    rmakers.beam(),
)
h = evans.RhythmHandler(s, forget=False)
voice_1_selections = h(durs)
staff_1 = abjad.Staff(name="Voice 1", lilypond_type="RhythmicStaff")
staff_1.extend(voice_1_selections)

quantizer = evans.RhythmTreeQuantizer()
final_rtm_list = [quantizer(_) for _ in final_rtm_list]

print("")

for _ in final_rtm_list: