Re: Possible source of beam properties confusion

2016-07-15 Thread Andrew Bernard
Hi David,

Thanks so much for this. That particular MWE does indeed print neatly
backward to the order, but precisely as you say, I was seeing random
ordering in my much larger set of examples. Being completely unaware
of this situation that you have here so clearly described, I was
having trouble coding, as the values I was seeing in my debug output
seemed to vary in unintelligible ways, due to my totally naive
assumption that the ordering was linear and the same as the score. Not
so. So now I know.

Your help very much appreciated.

Andrew



On 16 July 2016 at 02:21, David Kastrup wrote:

> The order in which callbacks are called is pretty much arbitrary.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Possible source of beam properties confusion

2016-07-15 Thread David Nalesnik
> Andrew Bernard  writes:
>
>> I use debug print statements when developing scheme music functions. I
>> have this evening noticed for the first time that my complete
>> perplexity regarding various properties may actually come from the
>> following problem. When I run a function several times in a row, the
>> print output comes out in backwards order to the score note order. [No
>> wonder I have been confused.] The MWE here shows this.

The order might not be strictly backwards, and you'll save yourself
plenty of headaches by
using grob::rhythmic-location to let you know which grob is which:

(I can attest that "out-of-order" display was a big motivation for
writing it :) )


slashDbg =
#(define-music-function (ang stem-fraction protrusion)
   (number? number? number?)
   #{
 \once \override Stem #'stencil =
 #(lambda (grob)
(let* (
   (beam (ly:grob-object grob 'beam))
   (beam-X-pos (ly:grob-property beam 'X-positions))
   (beam-Y-pos (ly:grob-property beam 'positions))

   (stil (ly:stem::print grob)))
  (format #t "positions of ~a at ~a: ~a~%"
grob (grob::rhythmic-location grob) beam-Y-pos)
  stil))
   #})


--DN

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Possible source of beam properties confusion

2016-07-15 Thread David Kastrup
Andrew Bernard  writes:

> I use debug print statements when developing scheme music functions. I
> have this evening noticed for the first time that my complete
> perplexity regarding various properties may actually come from the
> following problem. When I run a function several times in a row, the
> print output comes out in backwards order to the score note order. [No
> wonder I have been confused.] The MWE here shows this.

No, it doesn't.  You don't put display statements into the music
function (which is run at the time it is encountered in the source) but
into a callback.

The order in which callbacks are called is pretty much arbitrary.  In
fact, callbacks may be called more than once in unpure-pure-containers
(I think that's the basic remaining point of duplicity) for different
line break configurations.  Or not at all, depending on when LilyPond
decides that it does not need the particular stencil for typesetting.

Or earlier than you expect when some other grob needs some
callback-triggered property of a different grob in order to figure out
some details.

So when you put debug output in callbacks, the time of call is unknown,
it is not known whether you get called at all, and depending on the
callback type, you might be called several times.  Spanners are often
active in several systems at once, at each of the spanner parts gets its
own callback calls.

-- 
David Kastrup

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user