lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Passing \tweak-s to engravers


From: David Kastrup
Subject: Re: Passing \tweak-s to engravers
Date: Thu, 14 Jun 2018 15:45:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Urs Liska <address@hidden> writes:

> Am 14.06.2018 um 13:32 schrieb David Kastrup:
>
>>  From the Engraver tutorial in the Contributor's Guide (Acknowledging grobs):
>>
>>         Acknowledge functions are called in the order engravers are
>>      ‘\consist’-ed (the only exception is if you set ‘must-be-last’ to ‘#t’).
>>
>>         There will always be a call to ‘process-acknowledged ()’ whenever
>>      grobs have been created, and _reading_ stuff from grobs should be
>>      delayed until then since other acknowledgers might _write_ stuff into a
>>      grob even after your acknowledger has been called.  So the basic
>>      workflow is to use the various acknowledgers to _record_ the grobs you
>>      are interested in and _write_ stuff into them (or do read/write stuff
>>      that more or less is accumulative and/or really unrelated to other
>>      engravers), and then use the ‘process-acknowledged ()’ hook for
>>      processing (including _reading_) the grobs you had recorded.
>>
>>         You can create new grobs in ‘process-acknowledged ()’.  That will
>>      lead to a new cycle of ‘acknowledger ()’ calls followed by a new cycle
>>      of ‘process-acknowledged ()’ calls.
>>
>> Note that tweaks are applied by the acknowledger in the Tweak_engraver.
>
> OK, this seems to be the culprit. Do I get this right that the tweaks
> are applied to a grob only *after* my grob acknowledger sees the grob?
> Then it is relevant that ...
>
>>
>> I repeat my advice to read the Engraver tutorial.  Really.  In this
>> case, the central paragraph I quoted is very, very relevant.
>
> ... I did read that but it didn't help me. Nowhere did *I* write into
> grobs or even created new ones, so I couldn't actually know these
> paragraphs are relevant to my case.

Come again?

>>         There will always be a call to ‘process-acknowledged ()’ whenever
>>      grobs have been created, and _reading_ stuff from grobs should be
>>      delayed until then

You are reading stuff from grobs, so this should be delayed to the
process-acknowledged stage.  It says you should do this for _reading_.
Not for creating grobs or writing into grobs.  For _reading_.

> This is just another point for the case I'm often making that much of
> our documentation on that level is too complicated insofar as you're
> only getting to the point of understanding it when you don't really
> need it anymore.

I'll readily admit that Scheme engravers are underdocumented.  But the
engraver tutorial here, once you get pointed to it, is very clear about
the order of things and what to do when.

Can you point to anything that could be clearer here?

> However, I've now changed the example to record the note-heads (as per
> an example in scm/music-functions.scm):
>
> \version "2.19.80"
>
> testEngr =
> #(lambda (context)
>    (let ((note-heads '()))
>      (make-engraver
>       (acknowledgers
>        ((note-head-interface engraver grob source-engraver)
>         (set! note-heads (cons grob note-heads))
>         ))
>       ((process-acknowledged translator)
>        (for-each
>         (lambda (nh)
>           (ly:message "NoteHead color: ~a"
>             (ly:grob-property nh 'color)))
>         note-heads))
>       )))
>
> \layout {
>   \context {
>     % uncomment *one* of the following two lines
>     \Voice
>     %\Staff
>     %\Score
>     \consists #testEngr
>   }
> }
>
> \relative {
>   %\once \override NoteHead.color = #red c'
>   \tweak color #blue c'
> }
>
> =>
> Interpreting music...
> NoteHead color: ()
> NoteHead color: ()
> NoteHead color: (0.0 0.0 1.0)
> NoteHead color: (0.0 0.0 1.0)
>
> This shows that process-acknowledged is called four times

There is no guarantee that process-acknowledged is only called once per
time step, so once you have processed a head, you should clear your
list.  It is, however, getting called even before Tweaks_engraver had a
chance to do its job.

That would seem like a bug.

-- 
David Kastrup



reply via email to

[Prev in Thread] Current Thread [Next in Thread]