grace_corner_cases

CORNER CASE 1.

Before-grace-to-on-beat-grace works correctly when before-grace container is attached first:

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.BeforeGraceContainer("gs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container(
...     "a'8 b' c'' b'", music_voice[1:3], grace_leaf_duration=(1, 24)
... )
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  

Before-grace-to-on-beat-grace works correctly when on-beat grace container is attached first:

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.on_beat_grace_container(
...     "a'8 b' c'' b'", music_voice[1:3], grace_leaf_duration=(1, 24)
... )
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> container = abjad.BeforeGraceContainer("gs'16")
>>> abjad.attach(container, music_voice[1][1][0])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  

CORNER CASE 2. After-grace-within-on-beat-grace works correctly:

>>> music_voice = abjad.Voice("c'4 d' e' f'", name="MusicVoice")
>>> container = abjad.AfterGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> container = abjad.on_beat_grace_container(
...     "a'8 b' c'' b'", music_voice[1:3], grace_leaf_duration=(1, 24)
... )
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  

CORNER CASE 3. After-grace-to-before-grace works correctly:

>>> music_voice = abjad.Voice("b4 d' e' f'", name="MusicVoice")
>>> container = abjad.AfterGraceContainer("c'16")
>>> abjad.attach(container, music_voice[0])
>>> container = abjad.BeforeGraceContainer("cs'16")
>>> abjad.attach(container, music_voice[1])
>>> staff = abjad.Staff([music_voice])
>>> abjad.show(staff)  
>>> for component in abjad.iterate.components(staff):
...     timespan = abjad.get.timespan(component)
...     print(f"{repr(component):30} {repr(timespan)}")
... 
Staff("{ b4 d'4 e'4 f'4 }")    Timespan(Offset((0, 1)), Offset((1, 1)))
Voice("b4 d'4 e'4 f'4", name='MusicVoice') Timespan(Offset((0, 1)), Offset((1, 1)))
Note('b4')                     Timespan(Offset((0, 1)), Offset((1, 4)))
AfterGraceContainer("c'16")    Timespan(Offset((1, 4), displacement=Duration(-1, 8)), Offset((1, 4), displacement=Duration(-1, 16)))
Note("c'16")                   Timespan(Offset((1, 4), displacement=Duration(-1, 8)), Offset((1, 4), displacement=Duration(-1, 16)))
BeforeGraceContainer("cs'16")  Timespan(Offset((1, 4), displacement=Duration(-1, 16)), Offset((1, 4)))
Note("cs'16")                  Timespan(Offset((1, 4), displacement=Duration(-1, 16)), Offset((1, 4)))
Note("d'4")                    Timespan(Offset((1, 4)), Offset((1, 2)))
Note("e'4")                    Timespan(Offset((1, 2)), Offset((3, 4)))
Note("f'4")                    Timespan(Offset((3, 4)), Offset((1, 1)))

CORNER CASE 4. After-grace-to-on-beat-grace works correctly:

>>> music_voice = abjad.Voice("b4 d' e' f'", name="MusicVoice")
>>> container = abjad.AfterGraceContainer("c'16")
>>> abjad.attach(container, music_voice[0])
>>> container = abjad.on_beat_grace_container(
...     "a'8 b' c'' b'", music_voice[1:3], grace_leaf_duration=(1, 24)
... )
>>> abjad.attach(abjad.Articulation(">"), container[0])
>>> staff = abjad.Staff([music_voice])
>>> lilypond_file = abjad.LilyPondFile([r'\include "abjad.ily"', staff])
>>> abjad.show(lilypond_file)  
>>> for component in abjad.iterate.components(staff):
...     timespan = abjad.get.timespan(component)
...     print(f"{repr(component):30} {repr(timespan)}")
... 
Staff("{ b4 { { <d' a'>8 * 1/3 b'8 * 1/3 c''8 * 1/3 b'8 * 1/3 } { d'4 e'4 } } f'4 }") Timespan(Offset((0, 1)), Offset((1, 1)))
Voice("b4 { { <d' a'>8 * 1/3 b'8 * 1/3 c''8 * 1/3 b'8 * 1/3 } { d'4 e'4 } } f'4", name='MusicVoice') Timespan(Offset((0, 1)), Offset((1, 1)))
Note('b4')                     Timespan(Offset((0, 1)), Offset((1, 4)))
AfterGraceContainer("c'16")    Timespan(Offset((1, 4), displacement=Duration(-1, 16)), Offset((1, 4)))
Note("c'16")                   Timespan(Offset((1, 4), displacement=Duration(-1, 16)), Offset((1, 4)))
Container("{ <d' a'>8 * 1/3 b'8 * 1/3 c''8 * 1/3 b'8 * 1/3 } { d'4 e'4 }") Timespan(Offset((1, 4)), Offset((3, 4)))
OnBeatGraceContainer("<d' a'>8 * 1/3 b'8 * 1/3 c''8 * 1/3 b'8 * 1/3") Timespan(Offset((1, 4)), Offset((1, 4), displacement=Duration(1, 6)))
Chord("<d' a'>8 * 1/3")        Timespan(Offset((1, 4)), Offset((1, 4), displacement=Duration(1, 24)))
Note("b'8 * 1/3")              Timespan(Offset((1, 4), displacement=Duration(1, 24)), Offset((1, 4), displacement=Duration(1, 12)))
Note("c''8 * 1/3")             Timespan(Offset((1, 4), displacement=Duration(1, 12)), Offset((1, 4), displacement=Duration(1, 8)))
Note("b'8 * 1/3")              Timespan(Offset((1, 4), displacement=Duration(1, 8)), Offset((1, 4), displacement=Duration(1, 6)))
Voice("d'4 e'4", name='MusicVoice') Timespan(Offset((1, 4)), Offset((3, 4)))
Note("d'4")                    Timespan(Offset((1, 4), displacement=Duration(1, 6)), Offset((1, 2)))
Note("e'4")                    Timespan(Offset((1, 2)), Offset((3, 4)))
Note("f'4")                    Timespan(Offset((3, 4)), Offset((1, 1)))
abjad.grace_corner_cases.grace_corner_cases()[source]

Read these module-level examples.