Menu

#5740 Add \post to defer context actions to end of time step

Started
Dan Eble
None
needs_work
Enhancement
2020-04-13
2020-02-05
Dan Eble
No

I've carved this off of some experimental work that allows expressing
in ly code the post-increment of a context property without
sensitivity to the number of times the music that requests it is
iterated. That is something that the rehearsal-mark engraver does,
and I believe it can only be done currently by an engraver/performer.

The implementation of \post is similar to the way \once reverts an
effect at the end of the time step. In fact, I first implemented it
the same way for the sake of simplicity; but after testing, I decided
to complicate it. \once reversions naturally occur in reverse order,
but it seems more natural for \post actions to run in the order given
in the ly code. It also seems more natural for all \once reversions
to precede all \post actions regardless of their order in the ly code.
Because of those differences, they are handled separately.

TODOs and questions:

  • Is \post per se worthy to be merged, or should I wait until the
    whole group of post-increment features is ready, which is possibly
    much later or never? It would be easier for me to finish \post and
    merge it so that I have less to rebase on a regular basis. Can you
    think of places that \post would be useful right now?

  • Test coverage is insufficient. I've provided a few cases to show
    the basic idea.

  • Are there editor configs that I need to update to say that \post is
    a built-in command? Other similar things?

  • Should this be called \post, \atEndOfTimeStep, or something else?

https://codereview.appspot.com/581600043

Related

Issues: #1543

Discussion

  • Dan Eble

    Dan Eble - 2020-02-05
    • summary: /X: Add \post to defer context actions to end of time step --> Add \post to defer context actions to end of time step
    • Description has changed:

    Diff:

    
    
    • Needs: -->
     
  • David Kastrup

    David Kastrup - 2020-02-05

    "Dan Eble" eble@users.sourceforge.net writes:

    The implementation of \post is similar to the way \once reverts an
    effect at the end of the time step. In fact, I first implemented it
    the same way for the sake of simplicity; but after testing, I decided
    to complicate it. \once reversions naturally occur in reverse order,
    but it seems more natural for \post actions to run in the order given
    in the ly code. It also seems more natural for all \once reversions
    to precede all \post actions regardless of their order in the ly code.
    Because of those differences, they are handled separately.

    Does it work like once, setting a property on a stream event? That
    would seem important for quoted music and the part combiner.

    TODOs and questions:

    • Is \post per se worthy to be merged, or should I wait until the
      whole group of post-increment features is ready, which is possibly
      much later or never? It would be easier for me to finish \post and
      merge it so that I have less to rebase on a regular basis. Can you
      think of places that \post would be useful right now?

    • Test coverage is insufficient. I've provided a few cases to show
      the basic idea.

    • Are there editor configs that I need to update to say that \post is
      a built-in command? Other similar things?

    • Should this be called \post, \atEndOfTimeStep, or something else?

    Not yet have a good feeling for it. One application I can think of may
    be the end of a \cadenza coinciding with a new bar start. \partial 0*1
    does not work for that and it's super awkward to get this to work.
    Maybe that tool could help?

    --
    David Kastrup

     
    • Dan Eble

      Dan Eble - 2020-02-05

      Does it work like once, setting a property on a stream event? That
      would seem important for quoted music and the part combiner.

      Yes.

       
    • Dan Eble

      Dan Eble - 2020-02-06

      One application I can think of may be the end of a \cadenza coinciding with a new bar start. \partial 0*1 does not work for that and it's super awkward to get this to work.

      Thanks. I understand these words, but not enough to tell what you have in mind as the problem to be solved.

      I searched the issues for "cadenza" and came up with "Accidentals don't reset after explicit barlines" [#3640], but I don't see promise for a \post command to improve that.

       

      Related

      Issues: #3640

      • David Kastrup

        David Kastrup - 2020-02-06

        A cadenza halts LilyPond's timing. If you have a cadenza filling a bar, it doesn't actually fill the bar but only the moment at its start. Once \cadenzaOff happens, you are still at the start of the bar logically. \bar "|" changes the visuals but does not advance the bar number or trigger a threshold for new accidentals. That is a nuisance. I was wondering whether \post was able to smuggle something in that would allow LilyPond to think that the current bar has just ended, even though due to \cadenzaOn having stopped the timing up to \cadenzoOff, it is still at its start.

         
        • Dan Eble

          Dan Eble - 2020-02-06

          Looking at partial-iterator.cc, I think that \post might be the missing piece preventing \partial from being implemented with ly + scm. I'm going to experiment with that.

           

          Last edit: Dan Eble 2020-02-06
          • Dan Eble

            Dan Eble - 2020-02-17

            \post might be the missing piece preventing \partial from being implemented with ly + scm

            Not the only missing piece. It looks like expressing what Partial_iterator does would also require alternative music that is iterated conditionally based on a test that occurs in context, something like this:

            \context Timing \selectInContext #after-start <<
              {
                \once \set Timing.partialBusy = ##t
                \post \applyContext #apply-partial-after-start
              } {
                \applyContext #apply-partial-at-start
              }
            >>
            

            The effect of \selectInContext predicate << T F >> would be to iterate only T if the predicate is true, and only F if the predicate is false. In this example, the procedure after-start would return true if the current moment > 0.

             
            • David Kastrup

              David Kastrup - 2020-02-17

              Not the only missing piece.

              Well, it was probably a bit much to expect something that did not budge with hand-catered code to yield to a more generic tool. Still, worth a try.

               
  • Anonymous

    Anonymous - 2020-02-05
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-05

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-02-06
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-02-06

    Patch on tentative countdown for Feb 8th

     
  • Dan Eble

    Dan Eble - 2020-02-06
    • Patch: countdown --> waiting
     
  • Dan Eble

    Dan Eble - 2020-02-06

    "skipTypesetting doesn't behave well on its margins" [#1543] looks interesting.

     

    Related

    Issues: #1543

    • Dan Eble

      Dan Eble - 2020-02-17

      \post would indeed offer some options to a person irked by [#1543]. (I admit it's not the most compelling case.)

       

      Related

      Issues: #1543

  • Dan Eble

    Dan Eble - 2020-04-13
    • Patch: waiting --> needs_work