Ejemplo n.º 1
0
def test_LilyPondParser__containers__nesting_01():

    target = abjad.Container(
        [abjad.Container([]),
         abjad.Container([abjad.Container([])])])

    assert abjad.lilypond(target) == abjad.String.normalize(r"""
        {
            {
            }
            {
                {
                }
            }
        }
        """)

    parser = abjad.parser.LilyPondParser()
    result = parser(abjad.lilypond(target))
    assert abjad.lilypond(target) == abjad.lilypond(
        result) and target is not result
Ejemplo n.º 2
0
def test_WindowLooper_28():
    container = abjad.Container(r"c'4.\p( d'8 e'8\f) f'4.\p( ~ f'4 g'1\pp)")
    looper = auxjad.WindowLooper(container, step_size=(1, 4))
    notes = looper.output_n(6)
    staff = abjad.Staff(notes)
    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            c'4.
            \p
            (
            d'8
            e'8
            \f
            )
            f'4.
            \p
            c'8
            (
            d'8
            e'8
            \f
            )
            f'8
            \p
            ~
            f'2
            e'8
            \f
            f'8
            \p
            (
            ~
            f'2
            g'4
            \pp
            )
            f'2
            \p
            (
            g'2
            \pp
            )
            f'4
            \p
            (
            g'2.
            \pp
            )
            g'1
        }
        """)
Ejemplo n.º 3
0
def test_WindowLooper_04():
    container = abjad.Container(r"c'4 d'2 e'4 f'2 ~ f'8 g'1")
    looper = auxjad.WindowLooper(
        container,
        window_size=(3, 4),
        step_size=(5, 8),
        max_steps=2,
        repetition_chance=0.25,
        forward_bias=0.2,
        head_position=(2, 8),
        omit_time_signatures=False,
        fill_with_rests=False,
        boundary_depth=0,
        maximum_dot_count=1,
        rewrite_tuplets=False,
        process_on_first_call=True,
    )
    assert looper.window_size == abjad.Meter((3, 4))
    assert looper.step_size == abjad.Duration((5, 8))
    assert looper.max_steps == 2
    assert looper.repetition_chance == 0.25
    assert looper.forward_bias == 0.2
    assert looper.head_position == abjad.Duration((1, 4))
    assert not looper.omit_time_signatures
    assert not looper.fill_with_rests
    assert looper.boundary_depth == 0
    assert looper.maximum_dot_count == 1
    assert not looper.rewrite_tuplets
    assert looper.process_on_first_call
    looper.window_size = (5, 4)
    looper.step_size = (1, 4)
    looper.max_steps = 3
    looper.repetition_chance = 0.1
    looper.forward_bias = 0.8
    looper.head_position = 0
    looper.omit_time_signatures = True
    looper.fill_with_rests = True
    looper.boundary_depth = 1
    looper.maximum_dot_count = 2
    looper.rewrite_tuplets = True
    looper.process_on_first_call = False
    assert looper.window_size == abjad.Meter((5, 4))
    assert looper.step_size == abjad.Duration((1, 4))
    assert looper.max_steps == 3
    assert looper.repetition_chance == 0.1
    assert looper.forward_bias == 0.8
    assert looper.head_position == abjad.Duration(0)
    assert looper.omit_time_signatures
    assert looper.fill_with_rests
    assert looper.boundary_depth == 1
    assert looper.maximum_dot_count == 2
    assert looper.rewrite_tuplets
    assert not looper.process_on_first_call
Ejemplo n.º 4
0
def test_scoretools_Inspection_get_timespan_06():
    r'''Offset works with voices.
    '''

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_2 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_1.name = voice_2.name = 'voice'
    container = abjad.Container([voice_1, voice_2])
    leaves = abjad.select(container).leaves()
    for i, x in enumerate(leaves):
        assert abjad.inspect(
            x).get_timespan().start_offset == i * abjad.Offset(1, 8)
Ejemplo n.º 5
0
def test_scoretools_Inspection_get_timespan_17():
    r'''Prolated offset does NOT go across sequential staves.
    '''

    container = abjad.Container(
        [abjad.Staff("c'8 d'8 e'8 f'8"),
         abjad.Staff("c'8 d'8 e'8 f'8")])
    container[0].name = container[1].name = 'staff'
    start_offset = abjad.inspect(container[0]).get_timespan().start_offset
    assert start_offset == abjad.Offset(0)
    start_offset = abjad.inspect(container[1]).get_timespan().start_offset
    assert start_offset == abjad.Offset(1, 2)
Ejemplo n.º 6
0
def test_scoretools_Inspection_get_timespan_14():
    r'''Offset on leaves works in nested simultaneous and sequential contexts.
    '''

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_2 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_3 = abjad.Voice("c'8 d'8 e'8 f'8")
    staff = abjad.Staff([abjad.Container([voice_1, voice_2]), voice_3])
    staff[0].is_simultaneous = True
    for i, leaf in enumerate(voice_3):
        start_offset = abjad.inspect(leaf).get_timespan().start_offset
        assert start_offset == i * abjad.Offset(1, 8) + abjad.Offset(1, 2)
Ejemplo n.º 7
0
 def _apply_pitches(self, selections, pitches):
     leaf_maker = abjad.LeafMaker()
     container = abjad.Container(selections)
     old_ties = [tie for tie in abjad.iterate(
         container).logical_ties(pitched=True)]
     pitches, durations, old_leaves = self._collect_pitches_durations_leaves(
         old_ties, pitches)
     new_leaves = [leaf for leaf in leaf_maker(pitches, durations)]
     for old_leaf, new_leaf in zip(old_leaves, new_leaves):
         parent = abjad.inspect(old_leaf).parentage().parent
         parent[parent.index(old_leaf)] = new_leaf
     return [container[:]]
Ejemplo n.º 8
0
def test_Fader_19():
    random.seed(48915)
    container = abjad.Container(r"c'4 d'8 e'8 f'4 ~ f'8. g'16")
    fader = auxjad.Fader(container)
    assert fader.mask == [1, 1, 1, 1, 1]
    fader = auxjad.Fader(
        container,
        mode='in',
    )
    assert fader.mask == [0, 0, 0, 0, 0]
    fader()
    assert fader.mask == [0, 0, 0, 0, 0]
    fader()
    assert fader.mask == [0, 1, 0, 0, 0]
    fader()
    assert fader.mask == [0, 1, 1, 0, 0]
    staff = abjad.Staff(fader.current_window)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            r4
            d'8
            e'8
            r2
        }
        """)
    fader.mask = [1, 0, 1, 1, 0]
    assert fader.mask == [1, 0, 1, 1, 0]
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            c'4
            r8
            e'8
            f'4..
            r16
        }
        """)
    fader.reset_mask()
    assert fader.mask == [0, 0, 0, 0, 0]
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            R1
        }
        """)
Ejemplo n.º 9
0
def test_Fader_28():
    random.seed(17613)
    container = abjad.Container(
        r"<c' e'>4 ~ <c' e'>16 d'8. <gs e'>8 <bf f' a'>8 ~ <bf f' a'>4")
    fader = auxjad.Fader(container)
    staff = abjad.Staff(fader.output_all())
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            <c' e'>4
            ~
            <c' e'>16
            d'8.
            <gs e'>8
            <bf f' a'>4.
            <c' e'>4
            ~
            <c' e'>16
            d'8.
            gs8
            <bf f' a'>4.
            <c' e'>4
            ~
            <c' e'>16
            d'8.
            gs8
            <bf a'>4.
            c'4
            ~
            c'16
            d'8.
            gs8
            <bf a'>4.
            r4
            r16
            d'8.
            gs8
            <bf a'>4.
            r4
            r16
            d'8.
            gs8
            bf4.
            r2
            gs8
            bf4.
            r2
            r8
            bf4.
            R1
        }
        """)
Ejemplo n.º 10
0
def test_Container___init___01():
    """
    Initialize empty container.
    """

    container = abjad.Container([])

    assert isinstance(container, abjad.Container)
    assert abjad.lilypond(container) == abjad.String.normalize(r"""
        {
        }
        """)
Ejemplo n.º 11
0
def test_LeafLooper_02():
    container = abjad.Container(r"c'4 d'2 e'4 f'2 ~ f'8 g'4.")
    looper = auxjad.LeafLooper(
        container,
        window_size=3,
        step_size=1,
        max_steps=2,
        repetition_chance=0.25,
        forward_bias=0.2,
        head_position=0,
        end_with_max_n_leaves=True,
        omit_time_signatures=False,
        process_on_first_call=True,
        after_rest=(1, 8),
        after_rest_in_new_measure=True,
        use_multimeasure_rests=False,
    )
    assert looper.window_size == 3
    assert looper.step_size == 1
    assert looper.max_steps == 2
    assert looper.repetition_chance == 0.25
    assert looper.forward_bias == 0.2
    assert looper.head_position == 0
    assert looper.end_with_max_n_leaves
    assert not looper.omit_time_signatures
    assert looper.process_on_first_call
    assert looper.after_rest == abjad.Duration((1, 8))
    assert looper.after_rest_in_new_measure
    assert not looper.use_multimeasure_rests
    looper.window_size = 2
    looper.step_size = 2
    looper.max_steps = 3
    looper.repetition_chance = 0.1
    looper.forward_bias = 0.8
    looper.head_position = 2
    looper.end_with_max_n_leaves = False
    looper.omit_time_signatures = True
    looper.process_on_first_call = False
    looper.after_rest = 0
    looper.after_rest_in_new_measure = False
    looper.use_multimeasure_rests = True
    assert looper.window_size == 2
    assert looper.step_size == 2
    assert looper.max_steps == 3
    assert looper.repetition_chance == 0.1
    assert looper.forward_bias == 0.8
    assert looper.head_position == 2
    assert not looper.end_with_max_n_leaves
    assert looper.omit_time_signatures
    assert not looper.process_on_first_call
    assert looper.after_rest == abjad.Duration(0)
    assert not looper.after_rest_in_new_measure
    assert looper.use_multimeasure_rests
Ejemplo n.º 12
0
def test_Fader_29():
    container = abjad.Container(r"c'2 <d' e' f' g'>2")
    fader = auxjad.Fader(container, mask=[1, 0, 1, 1, 0])
    staff = abjad.Staff(fader())
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            c'2
            <e' f'>2
        }
        """)
Ejemplo n.º 13
0
def test_get_timespan_06():
    """
    Offset works with voices.
    """

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_2 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_1.name = voice_2.name = "voice"
    container = abjad.Container([voice_1, voice_2])
    leaves = abjad.select(container).leaves()
    for i, x in enumerate(leaves):
        assert abjad.get.timespan(x).start_offset == i * abjad.Offset(1, 8)
Ejemplo n.º 14
0
def test_CrossFader_10():
    fade_out_container = abjad.Container(r"\time 3/4 e2 \times 2/3 {fs8 gs4}")
    fade_in_container = abjad.Container(r"\time 3/4 c'8 d' e' f' g' a'")
    fader = auxjad.CrossFader(fade_out_container, fade_in_container)
    fader.fade_out_contents = abjad.Container(r"\time 3/4 a4. bf4.")
    assert format(fader) == abjad.String.normalize(r"""
        {
            %%% \time 3/4 %%%
            a4.
            bf4.
        }
        {
            %%% \time 3/4 %%%
            c'8
            d'8
            e'8
            f'8
            g'8
            a'8
        }
        """)
Ejemplo n.º 15
0
def test_LeafLooper_25():
    container = abjad.Container(r"c'16 d'4 e'8. f'4 g'16")
    looper = auxjad.LeafLooper(
        container,
        window_size=3,
    )
    notes = looper.output_n(3)
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 2/4
            c'16
            d'8.
            ~
            d'16
            e'8.
            \time 11/16
            d'4
            e'8.
            f'4
            \time 2/4
            e'8.
            f'16
            ~
            f'8.
            g'16
        }
        """)
    looper = auxjad.LeafLooper(
        container,
        window_size=3,
        disable_rewrite_meter=True,
    )
    notes = looper.output_n(3)
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 2/4
            c'16
            d'4
            e'8.
            \time 11/16
            d'4
            e'8.
            f'4
            \time 2/4
            e'8.
            f'4
            g'16
        }
        """)
Ejemplo n.º 16
0
def test_Fader_03():
    container = abjad.Container(r"c'4 d'2 e'4 f'2 ~ f'8 g'4.")
    fader = auxjad.Fader(
        container,
        mode='in',
        max_steps=2,
        repetition_chance=0.7,
        disable_rewrite_meter=True,
        omit_time_signatures=True,
        use_multimeasure_rests=False,
        mask=[1, 0, 1, 1, 0],
        boundary_depth=0,
        maximum_dot_count=1,
        rewrite_tuplets=False,
        process_on_first_call=True,
        include_empty_measures=False,
    )
    assert fader.mode == 'in'
    assert fader.max_steps == 2
    assert fader.repetition_chance == 0.7
    assert fader.disable_rewrite_meter
    assert fader.omit_time_signatures
    assert not fader.use_multimeasure_rests
    assert fader.mask == [1, 0, 1, 1, 0]
    assert fader.boundary_depth == 0
    assert fader.maximum_dot_count == 1
    assert not fader.rewrite_tuplets
    assert fader.process_on_first_call
    assert not fader.include_empty_measures
    fader.mode = 'out'
    fader.max_steps = 1
    fader.repetition_chance = 0.23
    fader.disable_rewrite_meter = False
    fader.omit_time_signatures = False
    fader.use_multimeasure_rests = True
    fader.mask = [0, 1, 1, 0, 1]
    fader.boundary_depth = 1
    fader.maximum_dot_count = 2
    fader.rewrite_tuplets = True
    fader.process_on_first_call = False
    fader.include_empty_measures = True
    assert fader.mode == 'out'
    assert fader.max_steps == 1
    assert fader.repetition_chance == 0.23
    assert not fader.disable_rewrite_meter
    assert not fader.omit_time_signatures
    assert fader.use_multimeasure_rests
    assert fader.mask == [0, 1, 1, 0, 1]
    assert fader.boundary_depth == 1
    assert fader.maximum_dot_count == 2
    assert fader.rewrite_tuplets
    assert not fader.process_on_first_call
    assert fader.include_empty_measures
Ejemplo n.º 17
0
def test_PitchRandomiser_11():
    container = abjad.Container(r"c'8 d'8 e'8 f'8 g'8 a'8 b'8 c'8")
    pitches = r"fs' gs' a' b'"
    randomiser = auxjad.PitchRandomiser(
        container,
        pitches,
        weights=[100.0, 1.0, 1.0, 1.0],
    )
    randomiser.pitches = r"c'' d'' e'' f'' g'' a'' b''"
    assert randomiser.pitches == abjad.PitchSegment(
        r"c'' d'' e'' f'' g'' a'' b''")
    assert randomiser.weights is None
def test_lilypondparsertools_LilyPondParser__comments_01():

    target = abjad.Container([abjad.Note(0, (1, 4))])

    string = r'''
    { c'4 }
    % { d'4 }
    % { e'4 }'''  # NOTE: no newline should follow the final brace

    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(string)
    assert format(target) == format(result)
Ejemplo n.º 19
0
def test_CrossFader_05():
    random.seed(10711)
    fade_out_container = abjad.Container(r"e'8 fs'4. r2")
    fade_in_container = abjad.Container(r"c''2 ~ c''8 d''4.")
    fader = auxjad.CrossFader(fade_out_container, fade_in_container)
    selection_a, selection_b = fader.output_n(3)
    score = abjad.Score([
        abjad.Staff(selection_a),
        abjad.Staff(selection_b),
    ])
    assert format(score) == abjad.String.normalize(r"""
        \new Score
        <<
            \new Staff
            {
                \time 4/4
                e'8
                fs'4.
                r2
                e'8
                fs'4.
                r2
                e'8
                r2..
            }
            \new Staff
            {
                \time 4/4
                R1
                c''2
                ~
                c''8
                r4.
                c''2
                ~
                c''8
                r4.
            }
        >>
        """)
Ejemplo n.º 20
0
def test_Shuffler_05():
    random.seed(18332)
    container = abjad.Container(r"c'8. d'4 r8 r8. e'16 f'8.")
    shuffler = auxjad.Shuffler(container, preserve_rest_position=True)
    notes = shuffler()
    staff = abjad.Staff(notes)
    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            d'4
            e'16
            r8.
            r8
            f'8
            ~
            f'16
            c'8.
        }
        """)
    container = abjad.Container(r"c'8. d'4 r8 r8. e'16 f'8.")
    shuffler = auxjad.Shuffler(
        container,
        pitch_only=True,
        preserve_rest_position=True,
    )
    notes = shuffler()
    staff = abjad.Staff(notes)
    assert format(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            d'8.
            f'4
            r8
            r8.
            c'16
            e'8.
        }
        """)
Ejemplo n.º 21
0
def test_Selection_are_logical_voice_31():
    """
    Logical voice can not extend across differently named implicit voices.
    """

    notes = [abjad.Note(n, (1, 8)) for n in range(4)]
    voice_1 = abjad.Voice(abjad.Note(12, (1, 8)) * 4)
    voice_2 = abjad.Voice(abjad.Note(0, (1, 8)) * 4)
    container = abjad.Container([voice_1, voice_2])
    container.is_simultaneous = True
    container = abjad.Container(notes + [container])

    assert format(container) == abjad.String.normalize(r"""
        {
            c'8
            cs'8
            d'8
            ef'8
            <<
                \new Voice
                {
                    c''8
                    c''8
                    c''8
                    c''8
                }
                \new Voice
                {
                    c'8
                    c'8
                    c'8
                    c'8
                }
            >>
        }
        """)

    leaves = abjad.select(container).leaves()
    assert not leaves[:8].are_logical_voice()
    assert not leaves[4:].are_logical_voice()
Ejemplo n.º 22
0
def test_CrossFader_14():
    random.seed(75991)
    fade_out_container = abjad.Container(r"fs'4 g'2 bf'4")
    fade_in_container = abjad.Container(r"\times 4/5 {cs''4 d''1}")
    fader = auxjad.CrossFader(
        fade_out_container,
        fade_in_container,
        omit_time_signatures=True,
    )
    selection_a, selection_b = fader.output_n(3)
    score = abjad.Score([
        abjad.Staff(selection_a),
        abjad.Staff(selection_b),
    ])
    assert format(score) == abjad.String.normalize(r"""
        \new Score
        <<
            \new Staff
            {
                fs'4
                g'2
                bf'4
                fs'4
                g'2
                r4
                fs'4
                g'2
                r4
            }
            \new Staff
            {
                R1
                R1
                \times 4/5 {
                    cs''4
                    r1
                }
            }
        >>
        """)
Ejemplo n.º 23
0
def test_mutate_split_14():
    """
    Cyclically splits all components in container.
    """

    voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8")])
    leaves = abjad.select(voice).leaves()
    abjad.beam(leaves)
    abjad.slur(leaves)

    assert abjad.lilypond(voice) == abjad.String.normalize(r"""
        \new Voice
        {
            {
                c'8
                [
                (
                d'8
                e'8
                f'8
                )
                ]
            }
        }
        """), print(abjad.lilypond(voice))

    container = voice[0]
    abjad.mutate.split(container, [abjad.Duration(1, 8)], cyclic=True)

    assert abjad.lilypond(voice) == abjad.String.normalize(r"""
        \new Voice
        {
            {
                c'8
                [
                (
            }
            {
                d'8
            }
            {
                e'8
            }
            {
                f'8
                )
                ]
            }
        }
        """), print(abjad.lilypond(voice))

    assert abjad.wf.wellformed(voice)
Ejemplo n.º 24
0
def test_Mutation_split_19():
    """
    Cyclically splits all components in container.
    """

    voice = abjad.Voice([abjad.Container("c'8 d'8 e'8 f'8")])
    leaves = abjad.select(voice).leaves()
    abjad.beam(leaves)
    abjad.slur(leaves)

    assert format(voice) == abjad.String.normalize(r"""
        \new Voice
        {
            {
                c'8
                [
                (
                d'8
                e'8
                f'8
                )
                ]
            }
        }
        """), print(format(voice))

    container = voice[0]
    result = abjad.mutate(container).split([abjad.Duration(1, 8)], cyclic=True)

    assert format(voice) == abjad.String.normalize(r"""
        \new Voice
        {
            {
                c'8
                [
                (
            }
            {
                d'8
            }
            {
                e'8
            }
            {
                f'8
                )
                ]
            }
        }
        """), print(format(voice))

    assert abjad.inspect(voice).wellformed()
Ejemplo n.º 25
0
def test_Fader_14():
    random.seed(19941)
    container = abjad.Container(r"c'4 d'4 e'4 f'4")
    fader = auxjad.Fader(container, mode='in', mask=[0, 1, 1, 0])
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            r4
            d'4
            e'4
            r4
        }
        """)
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            c'4
            d'4
            e'4
            r4
        }
        """)
    fader.reset_mask()
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            R1
        }
        """)
    fader.mode = 'out'
    fader.reset_mask()
    notes = fader()
    staff = abjad.Staff(notes)
    assert abjad.lilypond(staff) == abjad.String.normalize(r"""
        \new Staff
        {
            \time 4/4
            c'4
            d'4
            e'4
            f'4
        }
        """)
def test_Parentage_logical_voice_06():
    """
    Returns logical voice giving the root and first voice, staff and score in
    parentage of component.
    """

    container = abjad.Container([
        abjad.Staff([abjad.Voice("c'8 d'8")]),
        abjad.Staff([abjad.Voice("e'8 f'8")]),
    ])
    container[0].name = 'staff1'
    container[1].name = 'staff2'
    container[0][0].name = 'voicefoo'
    container[1][0].name = 'voicefoo'
    leaves = abjad.select(container).leaves()
    abjad.beam(leaves[:2])
    abjad.beam(leaves[2:])

    assert format(container) == abjad.String.normalize(r"""
        {
            \context Staff = "staff1"
            {
                \context Voice = "voicefoo"
                {
                    c'8
                    [
                    d'8
                    ]
                }
            }
            \context Staff = "staff2"
            {
                \context Voice = "voicefoo"
                {
                    e'8
                    [
                    f'8
                    ]
                }
            }
        }
        """)

    signatures = [
        abjad.inspect(leaf).parentage().logical_voice() for leaf in leaves
    ]

    signatures[0] == signatures[1]
    signatures[0] != signatures[2]

    signatures[2] != signatures[2]
    signatures[2] == signatures[3]
Ejemplo n.º 27
0
def test_WindowLooper_21():
    container = abjad.Container(r"c'1")
    looper = auxjad.WindowLooper(
        container,
        window_size=(4, 4),
        step_size=(1, 16),
    )
    assert len(looper) == 16
    container = abjad.Container(r"c'1")
    looper = auxjad.WindowLooper(
        container,
        window_size=(4, 4),
        step_size=(1, 4),
    )
    assert len(looper) == 4
    container = abjad.Container(r"c'2..")
    looper = auxjad.WindowLooper(
        container,
        window_size=(2, 4),
        step_size=(1, 4),
    )
    assert len(looper) == 4
Ejemplo n.º 28
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
Ejemplo n.º 29
0
def test_get_timespan_14():
    """
    Offset on leaves works in nested simultaneous and sequential contexts.
    """

    voice_1 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_2 = abjad.Voice("c'8 d'8 e'8 f'8")
    voice_3 = abjad.Voice("c'8 d'8 e'8 f'8")
    staff = abjad.Staff([abjad.Container([voice_1, voice_2]), voice_3])
    staff[0].simultaneous = True
    for i, leaf in enumerate(voice_3):
        start_offset = abjad.get.timespan(leaf).start_offset
        assert start_offset == i * abjad.Offset(1, 8) + abjad.Offset(1, 2)
Ejemplo n.º 30
0
def test_Inspection_timespan_17():
    """
    Prolated offset does NOT go across sequential staves.
    """

    container = abjad.Container(
        [abjad.Staff("c'8 d'8 e'8 f'8"),
         abjad.Staff("c'8 d'8 e'8 f'8")])
    container[0].name = container[1].name = "staff"
    start_offset = abjad.inspect(container[0]).timespan().start_offset
    assert start_offset == abjad.Offset(0)
    start_offset = abjad.inspect(container[1]).timespan().start_offset
    assert start_offset == abjad.Offset(1, 2)