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

NEW. Added abjad.VoiceNumber(n=None) indicator. #1528

Merged
merged 1 commit into from
Apr 7, 2023

Commits on Apr 7, 2023

  1. NEW. Added abjad.VoiceNumber(n=None) indicator.

    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 committed Apr 7, 2023
    Configuration menu
    Copy the full SHA
    fc21bf5 View commit details
    Browse the repository at this point in the history