How to use abjad - 10 common examples

To help you get started, we’ve selected a few abjad examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Abjad / abjad / tests / test_Container___delitem__.py View on Github external
{
            c'8
            [
            \glissando
            {
                e'8
                \glissando
            }
            f'8
            ]
        }
        """
    )

    assert abjad.inspect(voice).wellformed()
    assert abjad.inspect(leaf).wellformed()
github Abjad / abjad / tests / test_PianoPedalSpanner.py View on Github external
assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            \set Staff.pedalSustainStyle = #'mixed
            c'8
            \unaCorda
            c'8
            c'8
            c'8
            \treCorde
        }
        """
        )

    assert abjad.inspect(staff).wellformed()
github Abjad / abjad / tests / test_Container___setitem__.py View on Github external
voice_1[1] = voice_2[1]

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

    assert abjad.inspect(voice_1).wellformed()

    assert format(voice_2) == abjad.String.normalize(
        r"""
        \new Voice
        {
            f'8
            [
            a'8
            ]
        }
        """
    ), print(format(voice_2))

    assert abjad.inspect(voice_2).wellformed()
github Abjad / abjad / tests / test_GraceContainer_parentage.py View on Github external
def test_GraceContainer_parentage_02():
    """
    Grace containers bound to leaf do have parent.
    """

    note = abjad.Note(1, (1, 4))
    grace_container = abjad.GraceContainer()
    abjad.attach(grace_container, note)
    grace_container = abjad.inspect(note).grace_container()
    assert isinstance(grace_container, abjad.GraceContainer)
    assert grace_container._main_leaf is note
    assert grace_container._main_leaf is note
github Abjad / abjad / tests / test_LogicalTie__preprolated_duration.py View on Github external
def test_LogicalTie__preprolated_duration_01():

    staff = abjad.Staff("c' ~ c'16")

    assert abjad.inspect(
        staff[0]
    ).logical_tie()._get_preprolated_duration() == abjad.Duration(5, 16)
github Abjad / abjad / tests / test_Inspection_timespan.py View on Github external
def test_Inspection_timespan_18():
    """
    Offsets works with nested voices.
    """

    staff = abjad.Staff(
        [abjad.Voice("c'8 d'8 e'8 f'8"), abjad.Voice("c'8 d'8 e'8 f'8")]
    )
    for i, voice in enumerate(staff):
        start_offset = abjad.inspect(voice).timespan().start_offset
        assert start_offset == i * abjad.Offset(4, 8)
github Abjad / abjad / tests / test_Spanner_format.py View on Github external
def test_Spanner_format_01():
    """
    Base Spanner class makes no format-time contributions.
    However, base spanner causes no explosions at format-time, either.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    spanner = abjad.Spanner()
    abjad.attach(spanner, staff[:])

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

    assert abjad.inspect(staff).wellformed()
github Abjad / abjad / tests / test_LilyPondParser__indicators__MetronomeMark.py View on Github external
def test_LilyPondParser__indicators__MetronomeMark_04():

    target = abjad.Score([abjad.Staff([abjad.Note(0, 1)])])
    mark = abjad.MetronomeMark(
        reference_duration=(1, 4),
        units_per_minute=60,
        textual_indication="Like a majestic swan, alive with youth and vigour!",
    )
    leaves = abjad.select(target).leaves()
    abjad.attach(mark, leaves[0], context="Staff")

    assert format(target) == abjad.String.normalize(
        r"""
        \new Score
        <<
            \new Staff
            {
                \tempo "Like a majestic swan, alive with youth and vigour!" 4=60
                c'1
            }
        >>
        """
    )

    parser = abjad.parser.LilyPondParser()
    result = parser(format(target))
    assert format(target) == format(result) and target is not result
    leaves = abjad.select(result).leaves()
github Abjad / abjad / tests / test_Mutation_replace.py View on Github external
def test_Mutation_replace_02():
    """
    Moves parentage from one old note to five new notes.

    Equivalent to staff[:1] = new_notes.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    abjad.beam(staff[:2])
    abjad.beam(staff[2:])

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

    old_notes = staff[:1]
github Abjad / abjad / tests / test_Leaf__set_duration.py View on Github external
r"""
        \new Voice
        {
            c'8
            [
            r8
            e'8
            ]
            f'8
        }
        """
    ), print(format(voice))

    voice[1]._set_duration(abjad.Duration(5, 32))

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

    assert abjad.inspect(voice).wellformed()