How to use the abjad.Staff function in abjad

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_Staff___init__.py View on Github external
def test_Staff___init___01():
    """
    Initialize with context name.
    """

    staff = abjad.Staff(lilypond_type="BlueStaff")
    assert staff.lilypond_type == "BlueStaff"
github Abjad / abjad / tests / test_Parentage__id_string.py View on Github external
def test_Parentage__id_string_02():
    """
    Returns component name if it exists. Otherwise Python ID.
    """

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    parentage = abjad.inspect(staff).parentage()
    staff.name = "foo"
    assert parentage._id_string(staff) == "Staff-'foo'"
github Abjad / abjad / tests / test_LilyPondParser__indicators__Dynamic.py View on Github external
def test_LilyPondParser__indicators__Dynamic_01():

    target = abjad.Staff(abjad.Note(-12, (1, 2)) * 6)
    dynamic = abjad.Dynamic("ppp")
    abjad.attach(dynamic, target[0])
    dynamic = abjad.Dynamic("mp")
    abjad.attach(dynamic, target[1])
    dynamic = abjad.Dynamic("rfz")
    abjad.attach(dynamic, target[2])
    dynamic = abjad.Dynamic("mf")
    abjad.attach(dynamic, target[3])
    dynamic = abjad.Dynamic("spp")
    abjad.attach(dynamic, target[4])
    dynamic = abjad.Dynamic("ff")
    abjad.attach(dynamic, target[5])

    string = r"""\new Staff { c2\ppp c\mp c2\rfz c\mf c2\spp c\ff }"""

    parser = abjad.parser.LilyPondParser()
github Abjad / abjad / tests / test_PhrasingSlur_direction.py View on Github external
def test_PhrasingSlur_direction_01():

    staff = abjad.Staff("c'8 d'8 e'8 f'8")
    slur = abjad.PhrasingSlur(direction=abjad.Up)
    abjad.attach(slur, staff[:])

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            c'8
            ^ \(
            d'8
            e'8
            f'8
            \)
        }
        """
        )
github Abjad / abjad / tests / test_Skip___init__.py View on Github external
def test_Skip___init___10():
    """
    Initialize skip from spanned rest.
    """

    staff = abjad.Staff(
        [abjad.Note(0, (1, 8)), abjad.Rest((1, 8)), abjad.Note(0, (1, 8))]
    )
    abjad.beam(staff[:])
    skip = abjad.Skip(staff[1])
    assert isinstance(skip, abjad.Skip)
    assert isinstance(staff[1], abjad.Rest)
    assert staff[1]._parent is staff
    assert skip._parent is None
github Abjad / abjad / tests / test_Mutation_copy.py View on Github external
def test_Mutation_copy_05():

    staff = abjad.Staff(
        "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(staff).leaves()
    abjad.beam(leaves)
    abjad.slur(leaves)

    assert format(staff) == abjad.String.normalize(
        r"""
        \new Staff
        {
            {
                \time 2/8
                c'8
                [
                (
                d'8
github Abjad / abjad / tests / test_Staff___setitem__.py View on Github external
def test_Staff___setitem___05():
    """
    Bark when user assigns a slice to an item.
    """

    staff = abjad.Staff(4 * abjad.Note("c'4"))

    with pytest.raises(AssertionError):
        staff[0] = [abjad.Note(2, (1, 4)), abjad.Note(2, (1, 4))]
github Abjad / abjad / abjad / demos / ligeti.py View on Github external
def make_desordre_staff(pitches):
    """
    Makes Désordre staff.
    """

    staff = abjad.Staff()
    for sequence in pitches:
        measure = make_desordre_measure(sequence)
        staff.append(measure)
    return staff
github Abjad / abjad / experimental / demos / bach / helpers.py View on Github external
def build_chorale():

    soprano = abjad.parse(r'\new Voice = "soprano" {{ {} }}'.format(
        es_ist_genug['soprano']))
    alto = abjad.parse(r'\new Voice = "alto" {{ {} }}'.format(
        es_ist_genug['alto']))
    tenor = abjad.parse(r'\new Voice = "tenor" {{ {} }}'.format(
        es_ist_genug['tenor']))
    bass = abjad.parse(r'\new Voice = "bass" {{ {} }}'.format(
        es_ist_genug['bass']))

    treble_staff = abjad.Staff([soprano, alto])
    bass_staff = abjad.Staff([tenor, bass])

    treble_staff.is_simultaneous = True
    bass_staff.is_simultaneous = True

    key_signature = abjad.KeySignature(*es_ist_genug['key'])
    #abjad.attach(key_signature, treble_staff)
    key_signature = abjad.KeySignature(*es_ist_genug['key'])
    #abjad.attach(key_signature, bass_staff)
    clef = abjad.Clef('bass')
    #abjad.attach(clef, bass_staff)

    bar_line = abjad.BarLine('|.')
    #attach(bar_line, treble_staff)
    bar_line = abjad.BarLine('|.')
    #abjad.attach(bar_line, bass_staff)
github Abjad / abjad / abjad / tools / indicatortools / TimeSignatureList.py View on Github external
\time 5/8
                            s1 * 5/8
                        }
                        {
                            \time 4/4
                            s1 * 1
                        }
                    }
                >>

        Returns LilyPond file.
        '''
        import abjad
        maker = abjad.MeasureMaker()
        measures = maker(self)
        staff = abjad.Staff(measures)
        staff.context_name = 'RhythmicStaff'
        score = abjad.Score([staff])
        lilypond_file = abjad.LilyPondFile.new(score)
        return lilypond_file