def test_lilypondparsertools_LilyPondParser__spanners__Slur_02():
    r'''Swapped start and stop.
    '''

    maker = abjad.NoteMaker()
    target = abjad.Container(maker([0] * 4, [(1, 4)]))
    slur = abjad.Slur()
    abjad.attach(slur, target[2:])
    slur = abjad.Slur()
    abjad.attach(slur, target[:3])

    assert format(target) == abjad.String.normalize(r'''
        {
            c'4
            (
            c'4
            c'4
            )
            (
            c'4
            )
        }
        ''')

    string = r"\relative c' { c ( c c () c ) }"

    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(string)
    assert format(target) == format(result) and target is not result
def test_lilypondparsertools_LilyPondParser__spanners__Slur_01():
    r'''Successful slurs, showing single leaf overlap.
    '''

    maker = abjad.NoteMaker()
    target = abjad.Container(maker([0] * 4, [(1, 4)]))
    slur = abjad.Slur()
    abjad.attach(slur, target[2:])
    slur = abjad.Slur()
    abjad.attach(slur, target[:3])

    assert format(target) == abjad.String.normalize(r'''
        {
            c'4
            (
            c'4
            c'4
            )
            (
            c'4
            )
        }
        ''')

    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(format(target))
    assert format(target) == format(result) and target is not result
def test_lilypondparsertools_LilyPondParser__spanners__Slur_07():
    r'''With direction.
    '''

    maker = abjad.NoteMaker()
    target = abjad.Container(maker([0] * 4, [(1, 4)]))
    slur = abjad.Slur(direction=abjad.Down)
    abjad.attach(slur, target[:3])
    slur = abjad.Slur(direction=abjad.Up)
    abjad.attach(slur, target[2:])

    assert format(target) == abjad.String.normalize(r'''
        {
            c'4
            _ (
            c'4
            c'4
            )
            ^ (
            c'4
            )
        }
        ''')

    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(format(target))
    assert format(target) == format(result) and target is not result
def test_spannertools_Slur___eq___01():
    r'''Spanner is strict comparator.
    '''

    spanner_1 = abjad.Slur()
    spanner_2 = abjad.Slur()

    assert not spanner_1 == spanner_2
Beispiel #5
0
def test_scoretools_Measure___add___01():
    r'''Add outside-of-score measures.
    '''

    measure_1 = abjad.Measure((1, 8), "c'16 d'16")
    beam = abjad.Beam()
    abjad.attach(beam, measure_1[:])
    measure_2 = abjad.Measure((2, 16), "c'16 d'16")
    slur = abjad.Slur()
    abjad.attach(slur, measure_2[:])
    new = measure_1 + measure_2

    assert format(new) == abjad.String.normalize(r'''
        {
            \time 2/8
            c'16 [
            d'16 ]
            c'16 (
            d'16 )
        }
        ''')

    assert new is not measure_1 and new is not measure_2
    assert len(measure_1) == 0
    assert len(measure_2) == 0
    assert abjad.inspect(new).is_well_formed()
Beispiel #6
0
def test_scoretools_Mutation_fuse_08():
    r'''Fuses fixed-multiplier tuplets with same multiplier in score.
    '''

    tuplet_1 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8")
    beam = abjad.Beam()
    abjad.attach(beam, tuplet_1[:])
    tuplet_2 = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8 f'8 g'8")
    slur = abjad.Slur()
    abjad.attach(slur, tuplet_2[:])
    voice = abjad.Voice([tuplet_1, tuplet_2])

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \times 2/3 {
                c'8
                [
                d'8
                e'8
                ]
            }
            \tweak edge-height #'(0.7 . 0)
            \times 2/3 {
                c'8
                (
                d'8
                e'8
                f'8
                g'8
                )
            }
        }
        ''')

    tuplets = voice[:]
    abjad.mutate(tuplets).fuse()

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \tweak edge-height #'(0.7 . 0)
            \times 2/3 {
                c'8
                [
                d'8
                e'8
                ]
                c'8
                (
                d'8
                e'8
                f'8
                g'8
                )
            }
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
Beispiel #7
0
 def get_attachment(self, attachment_name):
     if attachment_name in self.articulations_inventory:
         return abjad.Articulation(name=attachment_name)
     elif attachment_name in self.dynamics_inventory:
         return abjad.Dynamic(name=attachment_name)
     elif attachment_name in self.slurs_inventory:
         return abjad.Slur()
     elif attachment_name == "\<":
         return abjad.Crescendo()
     elif attachment_name == "\>":
         return abjad.Decrescendo()
     elif attachment_name in self.stem_tremolos_inventory:
         tremolo_flags = int(attachment_name[1:])
         return abjad.indicatortools.StemTremolo(tremolo_flags)
     elif attachment_name in self.tremolos_inventory:
         tremolo_count = int(attachment_name[8:])
         return abjad.indicatortools.Tremolo(beam_count=tremolo_count,
                                             is_slurred=True)
     elif attachment_name == "~":
         return abjad.spannertools.Tie()
     elif attachment_name == "8va":
         return abjad.spannertools.OctavationSpanner(start=1)
     elif attachment_name in self.colors_inventory:
         # return lambda x : abjad.agenttools.LabelAgent(x).color_leaves(attachment_name)
         pass
     elif not attachment_name in self.stop_spanners_inventory:
         if attachment_name[0] == "\\":
             return abjad.indicatortools.LilyPondCommand(
                 attachment_name[1:])
         else:
             return abjad.Markup(attachment_name, direction=Up)
def test_scoretools_Inspection_get_indicators_01():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(slur, staff[:])
    command_1 = abjad.LilyPondLiteral(r'\slurDotted')
    abjad.attach(command_1, staff[0])
    command_2 = abjad.LilyPondLiteral(r'\slurUp')
    abjad.attach(command_2, staff[0])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            \slurDotted
            \slurUp
            c'8
            (
            d'8
            e'8
            f'8
            )
        }
        '''), format(staff)

    indicators = abjad.inspect(staff[0]).get_indicators(abjad.LilyPondLiteral)
    assert command_1 in indicators
    assert command_2 in indicators
    assert len(indicators) == 2
Beispiel #9
0
def test_scoretools_Inspection_get_spanner_01():

    container = abjad.Container("c'8 d'8 e'8 f'8")
    beam = abjad.Beam()
    abjad.attach(beam, container[:-1])
    slur = abjad.Slur()
    abjad.attach(slur, container[:-1])

    assert format(container) == abjad.String.normalize(r'''
        {
            c'8
            [
            (
            d'8
            e'8
            ]
            )
            f'8
        }
        ''')

    string = 'inspect(container[0]).get_spanner()'
    assert pytest.raises(Exception, string)

    assert abjad.inspect(container[-1]).get_spanner() is None
def test_scoretools_Container__get_spanners_that_dominate_component_pair_02():
    '''Get spanners in improper parentage.
    '''

    container = abjad.Container("c'8 d'8 e'8 f'8")
    beam = abjad.Beam()
    abjad.attach(beam, container[:])
    slur = abjad.Slur()
    abjad.attach(slur, container[:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, container[:])

    assert format(container) == abjad.String.normalize(r'''
        {
            c'8
            [
            (
            \startTrillSpan
            d'8
            e'8
            f'8
            ]
            )
            \stopTrillSpan
        }
        ''')

    parentage = abjad.inspect(container).get_parentage(include_self=False)
    assert abjad.inspect(parentage).get_spanners() == []
def test_scoretools_Inspection_get_indicators_02():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(slur, staff[:])
    comment = abjad.LilyPondComment('beginning of note content')
    abjad.attach(comment, staff[0])
    command = abjad.LilyPondLiteral(r'\slurDotted')
    abjad.attach(command, staff[0])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            % beginning of note content
            \slurDotted
            c'8
            (
            d'8
            e'8
            f'8
            )
        }
        '''), format(staff)

    items = abjad.inspect(staff[0]).get_indicators()
    assert comment in items
    assert command in items
    assert len(items) == 2
def test_scoretools_Mutation_copy_02():
    r'''Copy one measure and fracture spanners.
    '''

    voice = abjad.Voice("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |")
    leaves = abjad.select(voice).leaves()
    slur = abjad.Slur()
    abjad.attach(slur, leaves)
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)
    beam = abjad.Beam()
    abjad.attach(beam, leaves)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            {   % measure
                \time 2/8
                c'8
                [
                (
                \startTrillSpan
                d'8
            }   % measure
            {   % measure
                e'8
                f'8
            }   % measure
            {   % measure
                g'8
                a'8
                ]
                )
                \stopTrillSpan
            }   % measure
        }
        ''')

    result = abjad.mutate(voice[1:2]).copy()
    new = abjad.Voice(result)

    assert format(new) == abjad.String.normalize(r'''
        \new Voice
        {
            {   % measure
                \time 2/8
                e'8
                [
                (
                \startTrillSpan
                f'8
                ]
                )
                \stopTrillSpan
            }   % measure
        }
        ''')
    assert abjad.inspect(voice).is_well_formed()
    assert abjad.inspect(new).is_well_formed()
def test_scoretools_Mutation_copy_07():

    voice = abjad.Voice("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 |"
                        "| 2/8 g'8 a'8 || 2/8 b'8 c''8 |")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves)
    slur = abjad.Slur()
    abjad.attach(slur, leaves)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            {   % measure
                \time 2/8
                c'8
                [
                (
                d'8
            }   % measure
            {   % measure
                e'8
                f'8
            }   % measure
            {   % measure
                g'8
                a'8
            }   % measure
            {   % measure
                b'8
                c''8
                ]
                )
            }   % measure
        }
        ''')

    result = abjad.mutate(voice[-2:]).copy()
    new_voice = abjad.Voice(result)
    for component in abjad.iterate(new_voice).components():
        abjad.detach(abjad.Spanner, component)

    assert format(new_voice) == abjad.String.normalize(r'''
        \new Voice
        {
            {   % measure
                \time 2/8
                g'8
                a'8
            }   % measure
            {   % measure
                b'8
                c''8
            }   % measure
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
    assert abjad.inspect(new_voice).is_well_formed()
def test_scoretools_Mutation_copy_01():
    r'''Deep copies components.
    Deep copies spanners that abjad.attach to client.
    Fractures spanners that abjad.attach to components not in client.
    Returns Python list of copied components.
    '''

    voice = abjad.Voice("abj: | 2/8 c'8 d'8 || 2/8 e'8 f'8 || 2/8 g'8 a'8 |")
    leaves = abjad.select(voice).leaves()
    slur = abjad.Slur()
    abjad.attach(slur, leaves)
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)
    beam = abjad.Beam()
    abjad.attach(beam, leaves)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            {   % measure
                \time 2/8
                c'8
                [
                (
                \startTrillSpan
                d'8
            }   % measure
            {   % measure
                e'8
                f'8
            }   % measure
            {   % measure
                g'8
                a'8
                ]
                )
                \stopTrillSpan
            }   % measure
        }
        ''')

    result = abjad.mutate(leaves[2:4]).copy()
    new = abjad.Voice(result)

    assert format(new) == abjad.String.normalize(r'''
        \new Voice
        {
            e'8
            [
            (
            \startTrillSpan
            f'8
            ]
            )
            \stopTrillSpan
        }
        ''')
    assert abjad.inspect(voice).is_well_formed()
    assert abjad.inspect(new).is_well_formed()
Beispiel #15
0
def test_scoretools_Inspection_get_spanner_02():

    staff = abjad.Staff(r"c'4 \times 2/3 { d'8 e'8 f'8 } g'2")
    leaves = abjad.select(staff).leaves()
    slur = abjad.Slur()
    abjad.attach(slur, leaves)
    for leaf in leaves:
        assert slur == abjad.inspect(leaf).get_spanner(abjad.Slur)
Beispiel #16
0
def test_scoretools_Container_extend_08():
    r'''Extend container with partial and spanned contents of other container.
    Covered span comes with components from donor container.
    '''

    voice_1 = abjad.Voice("c'8 d'8")
    beam = abjad.Beam()
    abjad.attach(beam, voice_1[:])

    voice_2 = abjad.Voice("c'8 d'8 e'8 f'8")
    beam = abjad.Beam()
    abjad.attach(beam, voice_2[:])
    slur = abjad.Slur()
    abjad.attach(slur, voice_2[-2:])

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

    voice_1.extend(voice_2[-2:])

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

    assert abjad.inspect(voice_1).is_well_formed()

    assert format(voice_2) == abjad.String.normalize(r'''
        \new Voice
        {
            c'8
            [
            d'8
            ]
        }
        ''')

    assert abjad.inspect(voice_2).is_well_formed()
Beispiel #17
0
def test_spannertools_Slur___init___03():
    '''You can span over liked named staves
    so long as the voices nested in the staves are named the same.
    '''

    container = abjad.Container(r'''
        \context Staff = "foo" {
            \context Voice = "bar" {
                c'8
                cs'8
                d'8
                ef'8
            }
        }
        \context Staff = "foo" {
            \context Voice = "bar" {
                e'8
                f'8
                fs'8
                g'8
            }
        }
        ''')

    slur = abjad.Slur()
    leaves = abjad.select(container).leaves()
    abjad.attach(slur, leaves)

    assert format(container) == abjad.String.normalize(r'''
        {
            \context Staff = "foo"
            {
                \context Voice = "bar"
                {
                    c'8
                    (
                    cs'8
                    d'8
                    ef'8
                }
            }
            \context Staff = "foo"
            {
                \context Voice = "bar"
                {
                    e'8
                    f'8
                    fs'8
                    g'8
                    )
                }
            }
        }
        ''')

    assert abjad.inspect(container).is_well_formed()
Beispiel #18
0
 def add_attachments(self, score):
     selection = abjad.select(score).components(abjad.Voice)
     for voice in selection:
         phrase_selection = abjad.select(voice).leaves().runs()
         for phrase in phrase_selection:
             if len(phrase) > 1:
                 slur = abjad.Slur()
                 abjad.attach(slur, phrase)
             accent = abjad.Articulation('accent')
             abjad.attach(accent, phrase[0])
     return score
Beispiel #19
0
def test_scoretools_Mutation_fuse_07():
    r'''Fuses tuplets with same multiplier in score.
    '''

    tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
    beam = abjad.Beam()
    abjad.attach(beam, tuplet_1[:])
    tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16")
    slur = abjad.Slur()
    abjad.attach(slur, tuplet_2[:])
    voice = abjad.Voice([tuplet_1, tuplet_2])

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \times 2/3 {
                c'8
                [
                d'8
                e'8
                ]
            }
            \times 2/3 {
                c'16
                (
                d'16
                e'16
                )
            }
        }
        ''')

    tuplets = voice[:]
    abjad.mutate(tuplets).fuse()

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \times 2/3 {
                c'8
                [
                d'8
                e'8
                ]
                c'16
                (
                d'16
                e'16
                )
            }
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
Beispiel #20
0
def test_scoretools_Mutation_fuse_11():
    r'''Fuses unicorporated measures carrying
    time signatures with power-of-two denominators.
    '''

    measure_1 = abjad.Measure((1, 8), "c'16 d'16")
    beam = abjad.Beam()
    abjad.attach(beam, measure_1[:])
    measure_2 = abjad.Measure((2, 16), "c'16 d'16")
    slur = abjad.Slur()
    abjad.attach(slur, measure_2[:])
    staff = abjad.Staff([measure_1, measure_2])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            {   % measure
                \time 1/8
                c'16
                [
                d'16
                ]
            }   % measure
            {   % measure
                \time 2/16
                c'16
                (
                d'16
                )
            }   % measure
        }
        ''')

    new = abjad.mutate(staff[:]).fuse()

    assert new is not measure_1 and new is not measure_2
    assert len(measure_1) == 0
    assert len(measure_2) == 0

    assert format(new) == abjad.String.normalize(r'''
        {   % measure
            \time 2/8
            c'16
            [
            d'16
            ]
            c'16
            (
            d'16
            )
        }   % measure
        ''')

    assert abjad.inspect(new).is_well_formed()
Beispiel #21
0
def test_scoretools_Mutation_fuse_06():
    r'''Fuses two unincorporated tuplets with same multiplier.
    '''

    tuplet_1 = abjad.Tuplet((2, 3), "c'8 d'8 e'8")
    beam = abjad.Beam()
    abjad.attach(beam, tuplet_1[:])
    tuplet_2 = abjad.Tuplet((2, 3), "c'16 d'16 e'16")
    slur = abjad.Slur()
    abjad.attach(slur, tuplet_2[:])

    assert format(tuplet_1) == abjad.String.normalize(r'''
        \times 2/3 {
            c'8
            [
            d'8
            e'8
            ]
        }
        ''')

    assert format(tuplet_2) == abjad.String.normalize(r'''
        \times 2/3 {
            c'16
            (
            d'16
            e'16
            )
        }
        ''')

    tuplets = abjad.select([tuplet_1, tuplet_2])
    new = abjad.mutate(tuplets).fuse()

    assert format(new) == abjad.String.normalize(r'''
        \times 2/3 {
            c'8
            [
            d'8
            e'8
            ]
            c'16
            (
            d'16
            e'16
            )
        }
        ''')

    assert len(tuplet_1) == 0
    assert len(tuplet_2) == 0
    assert new is not tuplet_1 and new is not tuplet_2
    assert abjad.inspect(new).is_well_formed()
Beispiel #22
0
def test_scoretools_Container_remove_01():
    r'''Containers remove leaves correctly.
    Leaf abjad.detaches from parentage.
    Leaf withdraws from crossing spanners.
    Leaf carries covered spanners forward.
    Leaf returns after removal.
    '''

    voice = abjad.Voice("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(slur, voice[:])
    beam = abjad.Beam()
    abjad.attach(beam, voice[1:2])

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

    note = voice[1]
    voice.remove(note)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            c'8
            (
            e'8
            f'8
            )
        }
        ''')

    "Note is now d'8 [ ]"

    assert format(note) == "d'8\n[\n]"

    assert abjad.inspect(voice).is_well_formed()
    assert abjad.inspect(note).is_well_formed()
Beispiel #23
0
def test_scoretools_Measure___add___02():
    r'''Add measures in score.
    '''

    measure_1 = abjad.Measure((1, 8), "c'16 d'16")
    beam = abjad.Beam()
    abjad.attach(beam, measure_1[:])
    measure_2 = abjad.Measure((2, 16), "c'16 d'16")
    slur = abjad.Slur()
    abjad.attach(slur, measure_2[:])
    staff = abjad.Staff([measure_1, measure_2])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            {
                \time 1/8
                c'16 [
                d'16 ]
            }
            {
                \time 2/16
                c'16 (
                d'16 )
            }
        }
        ''')

    new = measure_1 + measure_2

    assert new is not measure_1 and new is not measure_2
    assert len(measure_1) == 0
    assert len(measure_2) == 0

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            {
                \time 2/8
                c'16 [
                d'16 ]
                c'16 (
                d'16 )
            }
        }
        ''')

    assert abjad.inspect(staff).is_well_formed()
Beispiel #24
0
def test_scoretools_Selection__get_crossing_spanners_01():
    r'''Returns unordered set of spanners crossing
    over the begin- or end-bounds of logical-voice-contiguous
    components.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 }")
    leaves = abjad.select(voice).leaves()
    slur = abjad.Slur()
    abjad.attach(slur, voice[1][:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

    assert format(voice) == abjad.String.normalize(
        r'''
        \new Voice
        {
            {
                c'8
                \startTrillSpan
                d'8
            }
            {
                e'8
                (
                f'8
                )
                \stopTrillSpan
            }
        }
        '''
        )

    spanners = abjad.select(voice)._get_crossing_spanners()
    assert spanners == []

    spanners = abjad.select(leaves)._get_crossing_spanners()
    assert spanners == []

    spanners = voice[:1]._get_crossing_spanners()
    assert len(spanners) == 1
    assert trill in spanners

    spanners = abjad.select(leaves[:-1])._get_crossing_spanners()
    assert len(spanners) == 2
    assert slur in spanners
    assert trill in spanners
def test_scoretools_Container_pop_01():
    r'''Containers pop leaves correctly.
    Popped leaves abjad.detach from parent.
    Popped leaves withdraw from crossing spanners.
    Popped leaves carry covered spanners forward.
    '''

    voice = abjad.Voice("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(slur, voice[:])
    beam = abjad.Beam()
    abjad.attach(beam, voice[1:2])

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

    result = voice.pop(1)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            c'8
            (
            e'8
            f'8
            )
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()

    "Result is now d'8 [ ]"

    assert abjad.inspect(result).is_well_formed()
    assert format(result) == "d'8\n[\n]"
Beispiel #26
0
def test_scoretools_Mutation_fuse_10():
    r'''Dominant spanners on contents are preserved.
    '''

    tuplet_1 = abjad.Tuplet((2, 3), "c'8")
    tuplet_2 = abjad.Tuplet((2, 3), "c'4")
    voice = abjad.Voice([tuplet_1, tuplet_2, abjad.Note("c'4")])
    leaves = abjad.select(voice).leaves()
    slur = abjad.Slur()
    abjad.attach(slur, leaves)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \tweak edge-height #'(0.7 . 0)
            \times 2/3 {
                c'8
                (
            }
            \tweak edge-height #'(0.7 . 0)
            \times 2/3 {
                c'4
            }
            c'4
            )
        }
        ''')

    tuplets = voice[:2]
    abjad.mutate(tuplets).fuse()

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \times 2/3 {
                c'8
                (
                c'4
            }
            c'4
            )
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
    def make_spanner_score_06(self):
        r'''Make 200-note voice with slur spanner on every 100 notes.

        2.12 (r9724) initialization:        249,339 function calls

        2.12 (r9703) LilyPond format:       121,497 function calls
        2.12 (r9724) LilyPond format:       106,718 function calls

        '''
        import abjad
        voice = abjad.Voice(200 * abjad.Note("c'16"))
        for part in abjad.sequence(voice[:]).partition_by_counts(
            [100],
                cyclic=True,
        ):
            slur = abjad.Slur()
            abjad.attach(slur, part)
        return voice
Beispiel #28
0
    def make_spanner_score_05(self):
        """
        Make 200-note voice with slur spanner on every 20 notes.

        2.12 (r9724) initialization:        248,567 function calls

        2.12 (r9703) LilyPond format:       122,177 function calls
        2.12 (r9724) LilyPond format:       107,486 function calls

        """
        import abjad
        voice = abjad.Voice(200 * abjad.Note("c'16"))
        for part in abjad.sequence(voice[:]).partition_by_counts(
            [20],
                cyclic=True,
        ):
            slur = abjad.Slur()
            abjad.attach(slur, part)
        return voice
Beispiel #29
0
def make_desordre_cell(pitches):
    """
    Makes a Désordre cell.
    """

    notes = [abjad.Note(pitch, (1, 8)) for pitch in pitches]
    notes = abjad.Selection(notes)
    beam = abjad.Beam()
    abjad.attach(beam, notes)
    slur = abjad.Slur()
    abjad.attach(slur, notes)
    clef = abjad.Dynamic('f')
    abjad.attach(clef, notes[0])
    dynamic = abjad.Dynamic('p')
    abjad.attach(dynamic, notes[1])

    # make the lower voice
    lower_voice = abjad.Voice(notes)
    lower_voice.name = 'RH Lower Voice'
    command = abjad.LilyPondLiteral(r'\voiceTwo')
    abjad.attach(command, lower_voice)
    n = int(math.ceil(len(pitches) / 2.))
    chord = abjad.Chord([pitches[0], pitches[0] + 12], (n, 8))
    articulation = abjad.Articulation('>')
    abjad.attach(articulation, chord)

    # make the upper voice
    upper_voice = abjad.Voice([chord])
    upper_voice.name = 'RH Upper Voice'
    command = abjad.LilyPondLiteral(r'\voiceOne')
    abjad.attach(command, upper_voice)

    # combine them together
    container = abjad.Container([lower_voice, upper_voice])
    container.is_simultaneous = True

    # make all 1/8 beats breakable
    leaves = abjad.select(lower_voice).leaves()
    for leaf in leaves[:-1]:
        bar_line = abjad.BarLine('')
        abjad.attach(bar_line, leaf)

    return container
Beispiel #30
0
def test_scoretools_Inspection_get_markup_01():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.Slur()
    abjad.attach(slur, staff[:])
    markup_1 = abjad.Markup('foo')
    abjad.attach(markup_1, staff[0])
    markup_2 = abjad.Markup('bar')
    abjad.attach(markup_2, staff[0])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            c'8
            (
            - \markup {
                \column
                    {
                        \line
                            {
                                foo
                            }
                        \line
                            {
                                bar
                            }
                    }
                }
            d'8
            e'8
            f'8
            )
        }
        ''')

    markup = abjad.inspect(staff[0]).get_markup()
    assert len(markup) == 2
    assert markup_1 in markup
    assert markup_2 in markup