Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abjad.VoiceNumber indicator #1135

Closed
trevorbaca opened this issue Oct 26, 2019 · 0 comments · Fixed by #1528
Closed

Add abjad.VoiceNumber indicator #1135

trevorbaca opened this issue Oct 26, 2019 · 0 comments · Fixed by #1528
Assignees
Milestone

Comments

@trevorbaca
Copy link
Member

trevorbaca commented Oct 26, 2019

These will model LilyPond \voiceOne, \voiceTwo, \voiceThree, \voiceFour and \oneVoice commands.

@trevorbaca trevorbaca self-assigned this Oct 26, 2019
@trevorbaca trevorbaca added this to the 3.14 milestone Oct 12, 2022
@trevorbaca trevorbaca changed the title Add abjad.VoiceNumber, abjad.OneVoice indicators Add abjad.VoiceNumber indicator Apr 6, 2023
trevorbaca added a commit that referenced this issue Apr 6, 2023
Set n to 1, 2, 3, 4 or none. Models LilyPond ``\voiceOne``,
``\voiceTwo``, ``\voiceThree``, ``\voiceFour``, ``\oneVoice`` commands.

    def make_staff():
        staff = abjad.Staff()
        voice_1 = abjad.Voice("g'8 a' b' c''")
        command = abjad.VoiceNumber(n=1)
        abjad.attach(command, voice_1[0])
        voice_2 = abjad.Voice("e'8 f' g' a'")
        command = abjad.VoiceNumber(n=2)
        abjad.attach(command, voice_2[0])
        container = abjad.Container([voice_1, voice_2], simultaneous=True)
        staff.append(container)
        voice = abjad.Voice("c''4 a'")
        command = abjad.VoiceNumber()
        abjad.attach(command, voice[0])
        staff.append(voice)

    >>> staff = make_staff()
    >>> string = abjad.lilypond(staff)
    >>> print(string)
    \new Staff
    {
        <<
            \new Voice
            {
                \voiceOne
                g'8
                a'8
                b'8
                c''8
            }
            \new Voice
            {
                \voiceTwo
                e'8
                f'8
                g'8
                a'8
            }
        >>
        \new Voice
        {
            \oneVoice
            c''4
            a'4
        }
    }

The abjad.VoiceNumber indicator is contexted at the level of
abjad.Voice. Use abjad.get.effective() to get the abjad.VoiceNumber
indicator in effect for any leaf:

    >>> for leaf in abjad.select.leaves(staff):
    ...     command = abjad.get.effective(leaf, abjad.VoiceNumber)
    ...     print(f"{leaf}, {command}")
    Note("g'8"), VoiceNumber(n=1)
    Note("a'8"), VoiceNumber(n=1)
    Note("b'8"), VoiceNumber(n=1)
    Note("c''8"), VoiceNumber(n=1)
    Note("e'8"), VoiceNumber(n=2)
    Note("f'8"), VoiceNumber(n=2)
    Note("g'8"), VoiceNumber(n=2)
    Note("a'8"), VoiceNumber(n=2)
    Note("c''4"), VoiceNumber(n=None)
    Note("a'4"), VoiceNumber(n=None)

Closes #1135.
@trevorbaca trevorbaca modified the milestones: 3.14, 3.17 Apr 7, 2023
trevorbaca added a commit that referenced this issue Apr 7, 2023
Set n to 1, 2, 3, 4 or none. Models LilyPond ``\voiceOne``,
``\voiceTwo``, ``\voiceThree``, ``\voiceFour``, ``\oneVoice`` commands.

    def make_staff():
        staff = abjad.Staff()
        voice_1 = abjad.Voice("g'8 a' b' c''")
        command = abjad.VoiceNumber(n=1)
        abjad.attach(command, voice_1[0])
        voice_2 = abjad.Voice("e'8 f' g' a'")
        command = abjad.VoiceNumber(n=2)
        abjad.attach(command, voice_2[0])
        container = abjad.Container([voice_1, voice_2], simultaneous=True)
        staff.append(container)
        voice = abjad.Voice("c''4 a'")
        command = abjad.VoiceNumber()
        abjad.attach(command, voice[0])
        staff.append(voice)

    >>> staff = make_staff()
    >>> string = abjad.lilypond(staff)
    >>> print(string)
    \new Staff
    {
        <<
            \new Voice
            {
                \voiceOne
                g'8
                a'8
                b'8
                c''8
            }
            \new Voice
            {
                \voiceTwo
                e'8
                f'8
                g'8
                a'8
            }
        >>
        \new Voice
        {
            \oneVoice
            c''4
            a'4
        }
    }

The abjad.VoiceNumber indicator is contexted at the level of
abjad.Voice. Use abjad.get.effective() to get the abjad.VoiceNumber
indicator in effect for any leaf:

    >>> for leaf in abjad.select.leaves(staff):
    ...     command = abjad.get.effective(leaf, abjad.VoiceNumber)
    ...     print(f"{leaf}, {command}")
    Note("g'8"), VoiceNumber(n=1)
    Note("a'8"), VoiceNumber(n=1)
    Note("b'8"), VoiceNumber(n=1)
    Note("c''8"), VoiceNumber(n=1)
    Note("e'8"), VoiceNumber(n=2)
    Note("f'8"), VoiceNumber(n=2)
    Note("g'8"), VoiceNumber(n=2)
    Note("a'8"), VoiceNumber(n=2)
    Note("c''4"), VoiceNumber(n=None)
    Note("a'4"), VoiceNumber(n=None)

Closes #1135.
trevorbaca added a commit that referenced this issue Apr 7, 2023
Set n to 1, 2, 3, 4 or none. Models LilyPond ``\voiceOne``,
``\voiceTwo``, ``\voiceThree``, ``\voiceFour``, ``\oneVoice`` commands.

    def make_staff():
        staff = abjad.Staff()
        voice_1 = abjad.Voice("g'8 a' b' c''")
        command = abjad.VoiceNumber(n=1)
        abjad.attach(command, voice_1[0])
        voice_2 = abjad.Voice("e'8 f' g' a'")
        command = abjad.VoiceNumber(n=2)
        abjad.attach(command, voice_2[0])
        container = abjad.Container([voice_1, voice_2], simultaneous=True)
        staff.append(container)
        voice = abjad.Voice("c''4 a'")
        command = abjad.VoiceNumber()
        abjad.attach(command, voice[0])
        staff.append(voice)

    >>> staff = make_staff()
    >>> string = abjad.lilypond(staff)
    >>> print(string)
    \new Staff
    {
        <<
            \new Voice
            {
                \voiceOne
                g'8
                a'8
                b'8
                c''8
            }
            \new Voice
            {
                \voiceTwo
                e'8
                f'8
                g'8
                a'8
            }
        >>
        \new Voice
        {
            \oneVoice
            c''4
            a'4
        }
    }

The abjad.VoiceNumber indicator is contexted at the level of
abjad.Voice. Use abjad.get.effective() to get the abjad.VoiceNumber
indicator in effect for any leaf:

    >>> for leaf in abjad.select.leaves(staff):
    ...     command = abjad.get.effective(leaf, abjad.VoiceNumber)
    ...     print(f"{leaf}, {command}")
    Note("g'8"), VoiceNumber(n=1)
    Note("a'8"), VoiceNumber(n=1)
    Note("b'8"), VoiceNumber(n=1)
    Note("c''8"), VoiceNumber(n=1)
    Note("e'8"), VoiceNumber(n=2)
    Note("f'8"), VoiceNumber(n=2)
    Note("g'8"), VoiceNumber(n=2)
    Note("a'8"), VoiceNumber(n=2)
    Note("c''4"), VoiceNumber(n=None)
    Note("a'4"), VoiceNumber(n=None)

Closes #1135.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant