Пример #1
0
def test_spannertools_Glissando___eq___01():
    r'''Spanner is strict comparator.
    '''

    spanner_1 = abjad.Glissando()
    spanner_2 = abjad.Glissando()

    assert not spanner_1 == spanner_2
Пример #2
0
def test_spannertools_Spanner_start_offset_01():
    r'''Returns start time of spanner in score.
    '''

    container = abjad.Container("c'8 d'8 e'8 f'8")
    beam = abjad.Beam()
    abjad.attach(beam, container[1:3])
    glissando = abjad.Glissando()
    abjad.attach(glissando, container[:])

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

    assert abjad.inspect(beam).get_timespan().start_offset == abjad.Duration(1, 8)
    assert abjad.inspect(glissando).get_timespan().start_offset == abjad.Duration(0)
def test_scoretools_Container__get_spanners_that_dominate_slice_03():
    r'''Get dominant spanners over four-component slice.
    '''

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

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

    receipt = voice._get_spanners_that_dominate_slice(0, 4)

    assert len(receipt) == 1
    assert (glissando, 0) in receipt
def test_lilypondparsertools_LilyPondParser__spanners__Glissando_01():

    target = abjad.Container([abjad.Note(0, 1), abjad.Note(0, 1)])
    glissando = abjad.Glissando()
    abjad.attach(glissando, target[:])
    parser = abjad.lilypondparsertools.LilyPondParser()
    result = parser(format(target))
    assert format(target) == format(result) and target is not result
def test_scoretools_Container___setitem___04():
    r'''Replaces in-score container with out-of-score tuplet.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 }")
    leaves = abjad.select(voice).leaves()
    abjad.attach(abjad.Beam(), leaves)
    abjad.attach(abjad.Glissando(), leaves)

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

    voice[1] = abjad.Tuplet(abjad.Multiplier(2, 3), "c'8 d'8 e'8")

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

    assert abjad.inspect(voice).is_well_formed()
Пример #6
0
def test_scoretools_Selection__get_dominant_spanners_01():
    r'''Returns Python list of (spanner, index) pairs.
    Each (spanner, index) pair gives a spanner which dominates
    all components in list, together with the start-index
    at which spanner abjad.attaches to subelement of first
    component in list.
    Beam and trill dominate first container.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

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

    receipt = voice[:1]._get_dominant_spanners()

    assert len(receipt) == 2
    assert (beam, 0) in receipt
    assert (trill, 0) in receipt
def test_scoretools_Container___setitem___02():
    r'''Replaces in-score leaf with out-of-score container.
    '''

    voice = abjad.Voice("c'8 [ d'8 ] e'8 f'8")
    leaves = abjad.select(voice).leaves()
    glissando = abjad.Glissando(allow_repeats=True)
    abjad.attach(glissando, leaves)

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

    voice[1] = abjad.Container("c'16 c'16 c'16")

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

    assert abjad.inspect(voice).is_well_formed()
Пример #8
0
def test_scoretools_Selection__get_dominant_spanners_07():
    r'''Only trill dominates voice.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

    receipt = abjad.select(voice)._get_dominant_spanners()

    assert len(receipt) == 1
    assert (trill, 0) in receipt
def test_scoretools_Container___delitem___08():
    r'''Deletes leaf from nested container.
    '''

    voice = abjad.Voice("c'8 [ { d'8 e'8 } f'8 ]")
    leaves = abjad.select(voice).leaves()
    abjad.attach(abjad.Glissando(), leaves)

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

    leaf = leaves[1]
    del (voice[1][0])

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

    assert abjad.inspect(voice).is_well_formed()
    assert abjad.inspect(leaf).is_well_formed()
def test_scoretools_Container___setitem___03():
    r'''Replaces in-score container with out-of-score leaf.
    '''

    voice = abjad.Voice("{ c'8 [ d'8 } { e'8 f'8 ] }")
    leaves = abjad.select(voice).leaves()
    abjad.attach(abjad.Glissando(), leaves)

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

    voice[1] = abjad.Note("c''8")

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

    assert abjad.inspect(voice).is_well_formed()
Пример #11
0
def test_scoretools_Selection__get_dominant_spanners_04():
    r'''Beam and trill dominate first two containers.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

    receipt = voice[:2]._get_dominant_spanners()

    assert len(receipt) == 2
    assert (beam, 0) in receipt
    assert (trill, 0) in receipt
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_03():
    r'''Glissando and trill both dominate crack at voice[2:2].
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

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

    pair = (voice[1], voice[2])
    receipt = voice._get_spanners_that_dominate_component_pair(*pair)

    assert len(receipt) == 2
    assert (glissando, 2) in receipt
    assert (trill, 4) in receipt
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_01():
    r'''Returns Python list of (spanner, index) pairs.
    Each spanner dominates an empty slice between components.
    No spanners dominate voice[0:0].
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

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

    receipt = voice._get_spanners_that_dominate_component_pair(None, voice[0])

    assert len(receipt) == 0
    assert receipt == []
Пример #14
0
def test_scoretools_Mutation_extract_02():
    r'''Extracts multiple notes.
    '''

    voice = abjad.Voice("c'8 d'8 e'8 f'8")
    beam = abjad.Beam()
    abjad.attach(beam, voice[:])
    glissando = abjad.Glissando()
    abjad.attach(glissando, voice[:])

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

    notes = voice[:2]
    for note in notes:
        abjad.mutate(note).extract()

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

    for note in notes:
        assert abjad.inspect(note).is_well_formed()

    assert abjad.inspect(voice).is_well_formed()
def test_scoretools_Parentage__get_spanners_that_dominate_component_pair_04():
    r'''No spanners dominate empty slice following voice.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves[:4])
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves[-4:])
    trill = abjad.TrillSpanner()
    abjad.attach(trill, leaves)

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

    pair = (voice[2], None)
    receipt = voice._get_spanners_that_dominate_component_pair(*pair)

    assert len(receipt) == 0
    assert receipt == []
Пример #16
0
 def _format_leaf(leaf, leaves):
     indicators = abjad.get.indicators(leaf)
     bow_contact_point = indicators[0]
     bow_motion_technique = indicators[1]
     if bow_contact_point is None:
         return
     if bow_contact_point.degrees is None:
         abjad.tweak(leaf.note_head).style = "#'cross"
         return
     if len(leaves) == 1:
         return
     _make_bow_contact_point_tweaks(leaf, bow_contact_point)
     if not _next_leaf_is_bowed(leaf, leaves):
         return
     glissando = abjad.Glissando()
     if bow_motion_technique is not None:
         style = f"#'{bow_motion_technique.glissando_style}"
         abjad.tweak(glissando).style = style
     abjad.attach(glissando, leaf, tag=tag)
     if not omit_bow_changes:
         _make_bow_change_contributions(leaf, leaves, bow_contact_point)
def test_spannertools_Glissando_01():

    staff = abjad.Staff([abjad.Note(n, (1, 8)) for n in range(8)])
    glissando = abjad.Glissando()
    abjad.attach(glissando, staff[:4])

    assert format(staff) == abjad.String.normalize(r'''
        \new Staff
        {
            c'8
            \glissando
            cs'8
            \glissando
            d'8
            \glissando
            ef'8
            e'8
            f'8
            fs'8
            g'8
        }
        ''')
Пример #18
0
def test_lilypondproxytools_LilyPondGrobNameManager___setattr___15():
    r'''Override LilyPond Glissando grob.
    '''

    voice = abjad.Voice("c'8 d'8 e'8 f'8")
    glissando = abjad.Glissando()
    abjad.attach(glissando, voice[:])
    abjad.override(glissando).glissando.thickness = 3

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            \override Glissando.thickness = #3
            c'8
            \glissando
            d'8
            \glissando
            e'8
            \glissando
            \revert Glissando.thickness
            f'8
        }
        ''')
Пример #19
0
def test_scoretools_Mutation_extract_04():
    r'''Extracts multiple containers.
    '''

    voice = abjad.Voice()
    voice.append(abjad.Container("c'8 d'8"))
    voice.append(abjad.Container("e'8 f'8"))
    voice.append(abjad.Container("g'8 a'8"))
    leaves = abjad.select(voice).leaves()
    beam = abjad.Beam()
    abjad.attach(beam, leaves)
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves)

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

    containers = voice[:2]
    for container in containers:
        abjad.mutate(container).extract()

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

    for container in containers:
        assert not container

    assert abjad.inspect(voice).is_well_formed()
def test_scoretools_Container___setitem___08():
    r'''Replaces note in one score with container from another score.
    '''

    notes = [
        abjad.Note("c'8"),
        abjad.Note("d'8"),
        abjad.Note("e'8"),
        abjad.Note("f'8"),
        abjad.Note("g'8"),
        abjad.Note("a'8"),
        abjad.Note("b'8"),
    ]
    voice_1 = abjad.Voice(notes[:3])
    abjad.attach(abjad.Beam(), voice_1[:])

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

    voice_2 = abjad.Voice(notes[3:])
    abjad.mutate(voice_2[1:3]).wrap(abjad.Container())
    leaves = abjad.select(voice_2).leaves()
    abjad.attach(abjad.Glissando(), leaves)
    leaves = abjad.select(voice_2[1]).leaves()
    abjad.attach(abjad.Slur(), leaves)

    assert format(voice_2) == abjad.String.normalize(r'''
        \new Voice
        {
            f'8
            \glissando
            {
                g'8
                \glissando
                (
                a'8
                )
                \glissando
            }
            b'8
        }
        ''')

    voice_1[1] = voice_2[1]

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

    assert abjad.inspect(voice_1).is_well_formed()

    assert format(voice_2) == abjad.String.normalize(r'''
        \new Voice
        {
            f'8
            \glissando
            b'8
        }
        ''')

    assert abjad.inspect(voice_2).is_well_formed()
Пример #21
0
    def __illustrate__(self):
        r"""
        Illustrates pitch range.

        ..  container:: example

            >>> pitch_range = abjad.PitchRange('[C3, C7]')
            >>> abjad.show(pitch_range) # doctest: +SKIP

            ..  docs::

                >>> lilypond_file = pitch_range.__illustrate__()
                >>> abjad.f(lilypond_file[abjad.Score])
                \new Score
                \with
                {
                    \override BarLine.stencil = ##f
                    \override Glissando.thickness = #2
                    \override SpanBar.stencil = ##f
                    \override TimeSignature.stencil = ##f
                }
                <<
                    \new PianoStaff
                    <<
                        \context Staff = "Treble Staff"
                        {
                            \clef "treble"
                            s1 * 1/4
                            s1 * 1/4
                        }
                        \context Staff = "Bass Staff"
                        {
                            \clef "bass"
                            c1 * 1/4
                            \glissando
                            \change Staff = "Treble Staff"
                            c''''1 * 1/4
                        }
                    >>
                >>

        Returns LilyPond file.
        """
        import abjad
        start_pitch_clef = abjad.Clef.from_selection(self.start_pitch)
        stop_pitch_clef = abjad.Clef.from_selection(self.stop_pitch)
        start_note = abjad.Note(self.start_pitch, 1)
        stop_note = abjad.Note(self.stop_pitch, 1)
        glissando = abjad.Glissando()
        if start_pitch_clef == stop_pitch_clef:
            if start_pitch_clef == abjad.Clef('bass'):
                bass_staff = abjad.Staff()
                abjad.attach(abjad.Clef('bass'), bass_staff)
                bass_staff.extend([start_note, stop_note])
                bass_leaves = abjad.select(bass_staff).leaves()
                abjad.attach(glissando, bass_leaves)
                score = abjad.Score([bass_staff])
            else:
                treble_staff = abjad.Staff()
                abjad.attach(abjad.Clef('treble'), treble_staff)
                treble_staff.extend([start_note, stop_note])
                treble_leaves = abjad.select(treble_staff).leaves()
                abjad.attach(glissando, treble_leaves)
                score = abjad.Score([treble_staff])
        else:
            result = abjad.Score.make_piano_score()
            score, treble_staff, bass_staff = result
            bass_staff.extend([start_note, stop_note])
            treble_staff.extend(abjad.Skip(1) * 2)
            bass_leaves = abjad.select(bass_staff).leaves()
            abjad.attach(glissando, bass_leaves)
            abjad.attach(abjad.StaffChange(treble_staff), bass_staff[1])
            abjad.attach(abjad.Clef('treble'), treble_staff[0])
            abjad.attach(abjad.Clef('bass'), bass_staff[0])
        for leaf in abjad.iterate(score).leaves():
            abjad.attach(abjad.Multiplier(1, 4), leaf)
        abjad.override(score).bar_line.stencil = False
        abjad.override(score).span_bar.stencil = False
        abjad.override(score).glissando.thickness = 2
        abjad.override(score).time_signature.stencil = False
        lilypond_file = abjad.LilyPondFile.new(score)
        return lilypond_file
Пример #22
0
 def card_11():
     notes = [abjad.Note("E4", (1, 4)), abjad.Note("F5", (1, 4))]
     abjad.attach(abjad.Glissando(), notes[0])
     return slur_all(notes)
Пример #23
0
 def card_1():
     notes = [abjad.Note("B4", (1, 4)), abjad.Note("E6", (1, 4))]
     abjad.override(notes[1]).NoteHead.style = "#'triangle"
     abjad.attach(abjad.Glissando(), notes[0])
     return slur_all(notes)
Пример #24
0
def test_scoretools_Mutation_swap_02():
    r'''Moves parentage, children and spanners from container to empty voice.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    voice.name = 'foo'
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves)
    beam = abjad.Beam()
    abjad.attach(beam, leaves)

    assert format(voice) == abjad.String.normalize(r'''
        \context Voice = "foo"
        {
            {
                c'8
                [
                \glissando
                d'8
                \glissando
            }
            {
                e'8
                \glissando
                f'8
                \glissando
            }
            {
                g'8
                \glissando
                a'8
                ]
            }
        }
        ''')

    new_voice = abjad.Voice()
    new_voice.name = 'foo'
    abjad.mutate(voice[1:2]).swap(new_voice)

    assert format(voice) == abjad.String.normalize(r'''
        \context Voice = "foo"
        {
            {
                c'8
                [
                \glissando
                d'8
                \glissando
            }
            \context Voice = "foo"
            {
                e'8
                \glissando
                f'8
                \glissando
            }
            {
                g'8
                \glissando
                a'8
                ]
            }
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
Пример #25
0
def test_scoretools_Mutation_swap_03():
    r'''Moves parentage, children and spanners from container to empty tuplet.
    '''

    voice = abjad.Voice("{ c'8 d'8 } { e'8 f'8 } { g'8 a'8 }")
    leaves = abjad.select(voice).leaves()
    glissando = abjad.Glissando()
    abjad.attach(glissando, leaves)
    beam = abjad.Beam()
    abjad.attach(beam, leaves)

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

    tuplet = abjad.Tuplet((3, 4), [])
    abjad.mutate(voice[1:2]).swap(tuplet)

    assert format(voice) == abjad.String.normalize(r'''
        \new Voice
        {
            {
                c'8
                [
                \glissando
                d'8
                \glissando
            }
            \tweak text #tuplet-number::calc-fraction-text
            \times 3/4 {
                e'8
                \glissando
                f'8
                \glissando
            }
            {
                g'8
                \glissando
                a'8
                ]
            }
        }
        ''')

    assert abjad.inspect(voice).is_well_formed()
def test_spannertools_Glissando___init___01():
    r'''Initialize empty glissando spanner.
    '''

    glissando = abjad.Glissando()
    assert isinstance(glissando, abjad.Glissando)