def test_Tuplet_get_timespan_01():

    staff = abjad.Staff(r"c'4 d'4 \times 2/3 { e'4 f'4 g'4 }")
    leaves = abjad.select(staff).leaves()
    score = abjad.Score([staff])
    mark = abjad.MetronomeMark((1, 4), 60)
    abjad.attach(mark, leaves[0])

    assert format(score) == abjad.String.normalize(r"""
        \new Score
        <<
            \new Staff
            {
                \tempo 4=60
                c'4
                d'4
                \times 2/3 {
                    e'4
                    f'4
                    g'4
                }
            }
        >>
        """)

    assert abjad.inspect(staff).timespan(in_seconds=True) == \
        abjad.Timespan(0, 4)
    assert abjad.inspect(staff[0]).timespan(in_seconds=True) == \
        abjad.Timespan(0, 1)
    assert abjad.inspect(staff[1]).timespan(in_seconds=True) == \
        abjad.Timespan(1, 2)
    assert abjad.inspect(staff[-1]).timespan(in_seconds=True) == \
        abjad.Timespan(2, 4)
Beispiel #2
0
 def __call__(self,
              counts,
              max_duration=None,
              translation=0,
              rotation=None,
              voice_name=None):
     if rotation:
         counts = counts[rotation:] + counts[:rotation]
     counts = self._ready_counts(counts, translation)
     denominator = self.denominator
     increment_total = 0 + translation
     timespan_list = abjad.TimespanList([])
     for count in counts:
         if count < 0:
             increment_total += abs(count)
             continue
         start = increment_total
         stop = start + count
         if max_duration is not None:
             stop = (max_duration + start) if count > max_duration else stop
         timespan_list.append(
             abjad.Timespan(
                 start_offset=(start, denominator),
                 stop_offset=(stop, denominator),
                 annotation=voice_name,
             ))
         increment_total += count
     return timespan_list
Beispiel #3
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)
    def __call__(self, timespan=None, offset=None):
        """
        Evaluates time relation:

            >>> offset = abjad.Offset(5)
            >>> timespan = abjad.Timespan(0, 10)
            >>> time_relation = abjad.timespans.offset_happens_during_timespan(
            ...     offset=offset,
            ...     timespan=timespan,
            ...     hold=True,
            ...     )
            >>> time_relation()
            True

        Raises value error is either ``offset`` or ``timespan`` is none.

        Otherwise returns boolean.
        """
        import abjad
        timespan = timespan or self.timespan
        offset = offset or self.offset
        if timespan is None or offset is None:
            message = 'time relation is not fully loaded.'
            raise ValueError(message)
        if not isinstance(timespan, abjad.Timespan):
            timespan = abjad.Timespan()._get_timespan(timespan)
        offset = abjad.Offset(offset)
        truth_value = self.inequality.evaluate_offset_inequality(
            timespan.start_offset, timespan.stop_offset, offset)
        return truth_value
Beispiel #5
0
def alternating_timespans(
    alternations=[
        [13, 5, 3],
        [8, 5, 3],
        [5, 5, 1],
        [3, 8, 1],
        [3, 13, 2],
        [2, 13, 8],
        [2, 8, 8],
        [1, 3, 13],
    ],
    denominator=4,
    annotations=["Mat_1", "Mat_2", "Rests"],
):
    """Make timespans to use with alternating materials."""
    n_annotations = len(annotations)
    timespans = TimespanList()
    counter_1 = []
    for a, alt in enumerate(alternations):
        for i in range(n_annotations):
            if alt[i] == 0:
                pass
            else:
                if a == 0 and i == 0:
                    timespans.append(
                        abjad.Timespan(
                            annotation=annotations[i],
                            start_offset=(0, denominator),
                            stop_offset=(alt[0], denominator),
                        )
                    )
                    counter_1.append(alt[0])
                    # print(0, alt[0])
                else:
                    start_offset_ = (sum(counter_1), denominator)
                    stop_offset_ = (sum(counter_1) + alt[i], denominator)
                    # print(start_offset_, stop_offset_)
                    timespans.append(
                        abjad.Timespan(
                            annotation=annotations[i],
                            start_offset=start_offset_,
                            stop_offset=stop_offset_,
                        )
                    )
                    counter_1.append(alt[i])
    return timespans
Beispiel #6
0
 def __init__(self, consecutive_leaves):
     self.proportion = None
     self.selection = abjad.select(consecutive_leaves)
     self.duration = sum([l.written_duration for l in self.selection])
     self.pitch = self.selection[0].written_pitch
     self.start_offset = self.get_leaf_offset(self.selection[0])
     self.stop_offset = self.get_offset_after_note_duration(self.selection[-1])
     self.timespan = abjad.Timespan(self.start_offset, self.stop_offset)
Beispiel #7
0
def test_Tuplet_timespan_01():

    staff = abjad.Staff(r"c'4 d'4 \times 2/3 { e'4 f'4 g'4 }")

    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            c'4
            d'4
            \times 2/3 {
                e'4
                f'4
                g'4
            }
        }
        """)

    assert abjad.get.timespan(staff) == abjad.Timespan(0, 1)
    assert abjad.get.timespan(staff[0]) == abjad.Timespan(0, (1, 4))
    assert abjad.get.timespan(staff[1]) == abjad.Timespan((1, 4), (1, 2))
    assert abjad.get.timespan(staff[-1]) == abjad.Timespan((1, 2), 1)
def test_scoretools_Tuplet_timespan_01():

    staff = abjad.Staff(r"c'4 d'4 \times 2/3 { e'4 f'4 g'4 }")

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            c'4
            d'4
            \times 2/3 {
                e'4
                f'4
                g'4
            }
        }
        ''')

    assert abjad.inspect(staff).get_timespan() == abjad.Timespan(0, 1)
    assert abjad.inspect(staff[0]).get_timespan() == abjad.Timespan(0, (1, 4))
    assert abjad.inspect(staff[1]).get_timespan() == abjad.Timespan((1, 4),
                                                                    (1, 2))
    assert abjad.inspect(staff[-1]).get_timespan() == abjad.Timespan((1, 2), 1)
Beispiel #9
0
 def _get_timespan(self, in_seconds=False):
     import abjad
     if in_seconds:
         self._update_now(offsets_in_seconds=True)
         if self._start_offset_in_seconds is None:
             raise MissingMetronomeMarkError
         return abjad.Timespan(
             start_offset=self._start_offset_in_seconds,
             stop_offset=self._stop_offset_in_seconds,
         )
     else:
         self._update_now(offsets=True)
         return self._timespan
Beispiel #10
0
 def __illustrate__(self, scale=None, target_timespan=None, **kwargs):
     target_timespan = target_timespan or abjad.Timespan(0, 16)
     assert isinstance(target_timespan, abjad.Timespan)
     assert 0 < target_timespan.duration
     scale = scale or 1.5
     music_specifiers = abjad.OrderedDict([
         ('A', 'A music'),
         ('B', 'B music'),
         ('C', 'C music'),
         ('D', 'D music'),
         ('E', 'E music'),
         ('F', 'F music'),
         ('G', 'G music'),
         ('H', 'H music'),
         ('I', 'I music'),
         ('J', 'J music'),
     ])
     timespan_list = self(
         layer=0,
         music_specifiers=music_specifiers,
         target_timespan=target_timespan,
     )
     ti_lilypond_file = timespan_list.__illustrate__(
         key='voice_name',
         range_=target_timespan,
         scale=scale,
     )
     ti_markup = ti_lilypond_file.items[-1]
     offset_counter = abjad.OffsetCounter(timespan_list)
     oc_lilypond_file = offset_counter.__illustrate__(
         range_=target_timespan,
         scale=scale,
     )
     oc_markup = oc_lilypond_file.items[-1]
     lilypond_file = abjad.LilyPondFile.new(
         default_paper_size=['tabloid', 'landscape'],
         date_time_token=False,
     )
     lilypond_file.items.extend([
         abjad.String.normalize('''
         % Backport for pre 2.19.20 versions of LilyPond
         #(define-markup-command (overlay layout props args)
             (markup-list?)
             (apply ly:stencil-add (interpret-markup-list layout props args)))
         '''),
         ti_markup,
         abjad.Markup.null().pad_around(2),
         oc_markup,
     ])
     lilypond_file.header_block.tagline = False
     return lilypond_file
Beispiel #11
0
 def __illustrate__(self, scale=None, target_timespan=None, **kwargs):
     target_timespan = target_timespan or abjad.Timespan(0, 16)
     assert isinstance(target_timespan, abjad.Timespan)
     assert 0 < target_timespan.duration
     scale = scale or 1.5
     music_specifiers = dict([
         ("A", "A music"),
         ("B", "B music"),
         ("C", "C music"),
         ("D", "D music"),
         ("E", "E music"),
         ("F", "F music"),
         ("G", "G music"),
         ("H", "H music"),
         ("I", "I music"),
         ("J", "J music"),
     ])
     timespan_list = self(
         layer=0,
         music_specifiers=music_specifiers,
         target_timespan=target_timespan,
     )
     ti_lilypond_file = timespan_list.__illustrate__(
         key="voice_name",
         range_=target_timespan,
         scale=scale,
     )
     ti_markup = ti_lilypond_file.items[-1]
     offset_counter = abjad.OffsetCounter(timespan_list)
     oc_lilypond_file = offset_counter.__illustrate__(
         range_=target_timespan,
         scale=scale,
     )
     oc_markup = oc_lilypond_file.items[-1]
     lilypond_file = abjad.LilyPondFile.new(
         default_paper_size=["tabloid", "landscape"],
         date_time_token=False,
     )
     lilypond_file.items.extend([
         abjad.String.normalize("""
         % Backport for pre 2.19.20 versions of LilyPond
         #(define-markup-command (overlay layout props args)
             (markup-list?)
             (apply ly:stencil-add (interpret-markup-list layout props args)))
         """),
         ti_markup,
         abjad.Markup.null().pad_around(2),
         oc_markup,
     ])
     lilypond_file.header_block.tagline = False
     return lilypond_file
Beispiel #12
0
    def opposite_timespan_list(self):
        """Todo."""
        for span1, span2 in zip(self, self[1:]):
            i = self.index(span1)
            if i == 0:
                if span1.start_offset == 0:
                    pass
                else:
                    new_initial_span = abjad.Timespan(
                        start_offset=(0, 1),
                        stop_offset=span1.start_offset,
                        annotation="Rests " + self[0].annotation,
                    )
                    self.append(new_initial_span)

            timespans = abjad.TimespanList([span1, span2])
            if timespans.all_are_contiguous is False:
                new_span = abjad.Timespan(
                    start_offset=span1.stop_offset,
                    stop_offset=span2.start_offset,
                    annotation="Rests " + self[i + 1].annotation,
                )
                self.append(new_span)
        return self
Beispiel #13
0
def add_silent_timespans(timespan_list, specifier=None):
    silent_timespans = abjad.TimespanList([
        abjad.Timespan(start_offset=0,
                       stop_offset=max(_.stop_offset for _ in timespan_list))
    ])
    for timespan in timespan_list:
        silent_timespans -= timespan
    for silent_timespan in silent_timespans:
        timespan_list.extend([
            SilentTimespan(
                start_offset=silent_timespan.start_offset,
                stop_offset=silent_timespan.stop_offset,
                annotation=specifier,
            )
        ])
    return timespan_list
Beispiel #14
0
 def __init__(self, name=None):
     import abjad
     self._indicators_are_current = False
     self._is_forbidden_to_update = False
     self._measure_number = None
     self._offsets_are_current = False
     self._offsets_in_seconds_are_current = False
     self._lilypond_grob_name_manager = None
     self._parent = None
     self._lilypond_setting_name_manager = None
     self._start_offset = None
     self._start_offset_in_seconds = None
     self._stop_offset = None
     self._stop_offset_in_seconds = None
     self._timespan = abjad.Timespan()
     self._wrappers = []
Beispiel #15
0
def talea_timespans(talea, advancement=0):
    talea = abjad.new(talea)
    talea = talea.advance(advancement)
    timespans = abjad.TimespanList([])
    total_duration = 0
    for duration in talea:
        start = total_duration
        stop = total_duration + abs(duration)
        if duration < 0:
            timespan = SilentTimespan(start_offset=start,
                                      stop_offset=stop,
                                      annotation=None)
        else:
            timespan = abjad.Timespan(start_offset=start,
                                      stop_offset=stop,
                                      annotation=None)
        timespans.append(timespan)
        total_duration += abs(duration)
    return timespans
Beispiel #16
0
def make_showable_list(timespan_lists):
    master_list = abjad.TimespanList([])
    for i, timespan_list in enumerate(timespan_lists):
        for timespan in timespan_list:
            if isinstance(timespan, SilentTimespan):
                new_span = SilentTimespan(
                    start_offset=timespan.start_offset,
                    stop_offset=timespan.stop_offset,
                    annotation=str(i + 1),
                )
            else:
                new_span = abjad.Timespan(
                    start_offset=timespan.start_offset,
                    stop_offset=timespan.stop_offset,
                    annotation=str(i + 1),
                )
            master_list.extend([new_span])
    master_list.sort()
    return master_list
Beispiel #17
0
 def __init__(self, name=None):
     import abjad
     self._dependent_wrappers = []
     self._indicator_wrappers = []
     self._indicators_are_current = False
     self._is_forbidden_to_update = False
     self._measure_number = None
     self._offsets_are_current = False
     self._offsets_in_seconds_are_current = False
     self._lilypond_grob_name_manager = None
     self._parent = None
     self._lilypond_setting_name_manager = None
     self._spanners = set()
     self._start_offset = None
     self._start_offset_in_seconds = None
     self._stop_offset = None
     self._stop_offset_in_seconds = None
     self._timespan = abjad.Timespan()
     self._name = None
     if name is not None:
         self.name = name  # name must be setup *after* parent
        voice_name="Voice 4",
    ),
])

# temp_list = abjad.TimespanList([
#     abjad.AnnotatedTimespan(_.start_offset, _.stop_offset, annotation=_.voice_name) for _ in rhythm_timespan_list
# ])
#
# abjad.show(temp_list, scale=0.7, key="annotation")
#
# raise Exception("Stop")

# ######
# pitch#
# ######
pitch_target_timespan = abjad.Timespan(0, 6)

pitch_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(
        counts=([15, 0, 24, 24]),
        denominator=4,
    ),
    playing_talea=rmakers.Talea(counts=([9, 8, 7]), denominator=4),
    silence_talea=rmakers.Talea(counts=([5, 1, 5, 1]), denominator=4),
)

pitch_timespan_list = pitch_timespan_maker(
    music_specifiers=music_specifiers, target_timespan=pitch_target_timespan)

# ######
# dynamic#
Beispiel #19
0
import abjad

ts_list = abjad.TimespanList()
spans = [abjad.Timespan(0, 2, "hello"), abjad.Timespan(0, 2, "world")]
for _ in spans:
    ts_list.append(_)
location = [abjad.Offset(1)]
ts_list.split_at_offsets(location)
# annotation is preserved through splitting!
from collections import OrderedDict

import abjad
import tsmakers
from abjadext import rmakers

from adumbration.materials.score_structure.instruments import instruments

music_specifiers = OrderedDict([(f"Voice {i+1}", None)
                                for i, name in enumerate(instruments)])
# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, 30)

rhythm_timespan_maker = tsmakers.TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(
        counts=([
            0,
        ]),
        denominator=4,
    ),
    playing_talea=rmakers.Talea(
        counts=([
            2,
            2,
            2,
            1,
            1,
            1,
            1,
Beispiel #21
0
                                         second=1,
                                         modulus=4)

pitch_padovan_1 = evans.Sequence.e_dovan_cycle(n=3,
                                               iters=5,
                                               first=3,
                                               second=5,
                                               modulus=5)

music_specifiers = OrderedDict([(f"Voice {i+1}", None)
                                for i, name in enumerate(instruments)])

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, 22)
# 1, 3, 2
rhythm_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=([0, 3, 2, 0]), denominator=8),
    # synchronize_step=True, #goes down voices instead of across? maybe not consistent...
    # synchronize_groupings=True, #goes down voices instead of across? maybe not consistent...
    playing_talea=rmakers.Talea(counts=(padovan_1), denominator=4),
    playing_groupings=(
        padovan_3),  # smashes timespans together without intermittent silence
    silence_talea=rmakers.Talea(counts=(padovan_2), denominator=4),
    # fuse_groups=False, #turns groups from multiple timespans into one large timespan
)

rhythm_timespan_list = rhythm_timespan_maker(
    music_specifiers=music_specifiers, target_timespan=rhythm_target_timespan)
Beispiel #22
0
from collections import OrderedDict

import abjad
from abjadext import rmakers as rmakers
from tsmakers.TaleaTimespanMaker import TaleaTimespanMaker

from sim.materials.score_structure.instruments import instruments

music_specifiers = OrderedDict([(f"Voice {i+1}", None)
                                for i, name in enumerate(instruments)])

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, 14)
# 4, 0, 1, 3
rhythm_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=([0]), denominator=2),
    playing_talea=rmakers.Talea(
        counts=([8, 10, 8, 6, 8, 8, 6, 8, 8, 10, 8, 8, 8, 8]), denominator=8),
    silence_talea=rmakers.Talea(counts=([0]), denominator=8),
)

rhythm_timespan_list = rhythm_timespan_maker(
    music_specifiers=music_specifiers, target_timespan=rhythm_target_timespan)

# ######
# pitch#
# ######
pitch_target_timespan = abjad.Timespan(0, 14)
Beispiel #23
0
from collections import OrderedDict

import abjad
from abjadext import rmakers as rmakers
from tsmakers.TaleaTimespanMaker import TaleaTimespanMaker

from adumbration.materials.score_structure.instruments import instruments

music_specifiers = OrderedDict([(f"Voice {i+1}", None)
                                for i, name in enumerate(instruments)])

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, (30, 8))

rhythm_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=([0]), denominator=8),
    playing_talea=rmakers.Talea(counts=([3, 4, 2, 1, 1]), denominator=4),
    # playing_groupings=([1, 2, 3, 2,]),
    silence_talea=rmakers.Talea(
        counts=([
            1,
            2,
            4,
            1,
        ]),
        denominator=8,
    ),
    # synchronize_step=True,
)
                                         first=2,
                                         second=3,
                                         modulus=3)
padovan_3 = evans.Sequence.e_dovan_cycle(n=2,
                                         iters=30,
                                         first=1,
                                         second=1,
                                         modulus=5)

music_specifiers = OrderedDict([(f"Voice {i+1}", None)
                                for i, name in enumerate(instruments)])

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, 81)

rhythm_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=([0, 0, 0, 0]), denominator=8),
    # synchronize_step=True,
    # synchronize_groupings=True,
    playing_talea=rmakers.Talea(counts=(padovan_1), denominator=2),
    playing_groupings=(padovan_3),
    silence_talea=rmakers.Talea(counts=(padovan_2), denominator=4),
)

rhythm_timespan_list = rhythm_timespan_maker(
    music_specifiers=music_specifiers, target_timespan=rhythm_target_timespan)

# ######
# pitch#
from collections import OrderedDict

import abjad
from abjadext import rmakers as rmakers
from tsmakers.TaleaTimespanMaker import TaleaTimespanMaker

from adumbration.materials.score_structure.instruments import instruments

music_specifiers = OrderedDict(
    [(f"Voice {i+1}", None) for i, name in enumerate(instruments)]
)

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, (25, 4))

rhythm_timespan_maker = TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=([0]), denominator=8),
    playing_talea=rmakers.Talea(counts=([5, 1, 2, 5, 3, 4, 5]), denominator=4),
    # playing_groupings=([1, 2, 3, 2,]),
    silence_talea=rmakers.Talea(
        counts=(
            [
                0,
            ]
        ),
        denominator=8,
    ),
    # synchronize_step=True,
)
from adumbration.materials.timespans.segment_18.make_timespans import (
    rhythm_timespan_list, )

from .make_timespans import music_specifiers

voice_names = [specifier for specifier in music_specifiers]

# #######
# rhythm#
# #######
rhythm_mat = evans.CyclicList(rhythm_material_list, forget=False)

for voice in voice_names:
    for span in rhythm_timespan_list:
        if span.voice_name == voice:
            span._handler = rhythm_mat(r=1)[0]

segment_18_rhythm_timespans = evans.timespan.make_split_list(
    rhythm_timespan_list, bounds)

rhythm_commands = []
for span in segment_18_rhythm_timespans:
    r_command = evans.RhythmCommand(
        voice_name=span.voice_name,
        timespan=abjad.Timespan(span.start_offset, span.stop_offset),
        handler=span.handler,
    )
    rhythm_commands.append(r_command)

evans.timespan.intercalate_silences(rhythm_commands)
Beispiel #27
0
    'Voice 7': voice_7_timespan_list,
    'Voice 8': voice_8_timespan_list,
    'Voice 9': voice_9_timespan_list,
    'Voice 10': voice_10_timespan_list,
    'Voice 11': voice_11_timespan_list,
    'Voice 12': voice_12_timespan_list,
    'Voice 13': voice_13_timespan_list,
    'Voice 14': voice_14_timespan_list,
    'Voice 15': voice_15_timespan_list,
    'Voice 16': voice_16_timespan_list,
}

# Determine the "global" timespan of all voices combined:

global_timespan = abjad.Timespan(
    start_offset=0,
    stop_offset=max(_.stop_offset for _ in all_timespan_lists.values()))

# Using the global timespan, create silence timespans for each timespan list.
# We don't need to create any silences by-hand if we now the global start and
# stop offsets of all voices combined:

for voice_name, timespan_list in all_timespan_lists.items():
    # Here is another technique for finding where the silence timespans are. We
    # create a new timespan list consisting of the global timespan and all the
    # timespans from our current per-voice timespan list. Then we compute an
    # in-place logical XOR. The XOR will replace the contents of the "silences"
    # timespan list with a set of timespans representing those periods of time
    # where only one timespan from the original was present. This has the
    # effect of cutting out holes from the global timespan wherever a per-voice
    # timespan was found, but also preserves any silence before the first
import abjad
import tsmakers
from abjadext import rmakers

timespan_maker = tsmakers.TaleaTimespanMaker(
    initial_silence_talea=rmakers.Talea(counts=(1, 4, 1), denominator=16),
    silence_talea=rmakers.Talea(counts=(0, 5), denominator=(32)))
abjad.f(timespan_maker)

music_specifiers = abjad.OrderedDict([
    ('Violin', None),
    ('Viola', None),
])

target_timespan = abjad.Timespan(0, 10)

timespan_list = timespan_maker(
    music_specifiers=music_specifiers,
    target_timespan=target_timespan,
)

abjad.f(timespan_list)
abjad.show(timespan_list)
from collections import OrderedDict

import abjad
from abjadext import rmakers as rmakers
from tsmakers.TaleaTimespanMaker import TaleaTimespanMaker

from chalk_line.materials.score_structure.instruments import instruments

music_specifiers = OrderedDict(
    [(f"Voice {i+1}", None) for i, name in enumerate(instruments)]
)

# #######
# rhythm#
# #######
rhythm_target_timespan = abjad.Timespan(0, (80, 4))

rhythm_timespan_maker = TaleaTimespanMaker(
    playing_talea=rmakers.Talea(
        counts=([1, 9, 2, 8, 3, 7, 4, 6, 5, 5, 4, 6, 3, 7, 2, 8]), denominator=8
    ),
    silence_talea=rmakers.Talea(counts=([0]), denominator=4),
)

rhythm_timespan_list = rhythm_timespan_maker(
    music_specifiers=music_specifiers, target_timespan=rhythm_target_timespan
)

print("Making timespans ...")
# ######
# pitch#
Beispiel #30
0
)

abjad.f(timespan_maker)

timespan_list = abjad.TimespanList([
    tsmakers.PerformedTimespan(
        voice_name='Viola Voice',
        start_offset=(1, 4),
        stop_offset=(1, 1),
    ),
    tsmakers.PerformedTimespan(
        voice_name='Viola Voice',
        start_offset=(3, 4),
        stop_offset=(3, 2),
    ),
])

music_specifiers = {
    'Violin Voice': None,
    'Cello Voice': None,
}
target_timespan = abjad.Timespan((1, 2), (2, 1))
timespan_list = timespan_maker(
    music_specifiers=music_specifiers,
    target_timespan=target_timespan,
    timespan_list=timespan_list,
)

abjad.f(timespan_list)
abjad.show(timespan_list, scale=0.65)