lilypond-user
[Top][All Lists]
Advanced

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

Re: Iterators in Scheme?


From: Niols
Subject: Re: Iterators in Scheme?
Date: Wed, 29 Jul 2020 16:48:15 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

Hi David,

On 29/07/2020 15:58, David Kastrup wrote:
Markup expressions are converted into stencils at a comparatively late
point of time.

So that means I could create the markups for the several bar numbers while I see them, and these markups would use a variable that contains the bar number of the end of the repeat, and by the time the markups are actually interpreted, I can have filled the variable with the right value?

 From what I understand, however, there are two passes: first the
iteration and then the engraving.

No, that's wrong.  It's just a single pass.  Iterators are strongly tied
to the sequence of music expressions in the source code (and only
persist while such an expression is being interpreted) while engravers
are tied to contexts and persist as long as the respective context
lives.  Iterators are driven by the music expressions and the advancing
time while engravers are driven by stream events announced in contexts.

But there is no separate pass involved.

Oh, OK, my bad. Thank you very much for the explanation!

For the problem of repeats, I read the code of the
Volta_repeat_iterator. In particular, it seems to read the
"repeat-count" property:

     rep_count_ = scm_to_int (get_property (get_music (), "repeat-count"));

but only uses it to detect the "first time" and the other times. The
first time:

     if (first_time_)
       {
         add_repeat_command (ly_symbol2scm ("start-repeat"));
         first_time_ = false;
       }

it adds a "start-repeat" command. As far as I understand, that means
that the engraving then only gets the repeat commands, which is
actually not enough information for what I am trying to achieve.

I am really motivated to read code and do my own research and write my
own Scheme code, but I do not really know where to look and if I
understood stuff correctly. If you had any pointer to understand more
(or better) about what I understood, and to achieve this in the end, I
would be very grateful.

In any case, I am already very grateful for the time you took to read
my message/s and answer me. Sorry for the long text.

I thought we had several options for bar numbering in connection with
repeats but don't know about the details.  There may be a more
specialised solution for your use case.

The only option of bar numbering with respect to repeat that I know of is with respect to the alternatives.

https://lilypond.org/doc/v2.18/Documentation/internals/bar_005fnumber_005fengraver

The Bar_number_engraver reads the alternativeNumberingStyle property that decides whether the numbers should keep increase, or be the same in all alternatives but with a letter, or just be the same in all alternatives.

If there is an other option, I have never found it in all the time I've crawled in the documentation.

Then there also is the recording-group-emulate function which you can
use for causing a complete pass of iteration just for event gathering
purposes.  It might be feasible to use that for collecting repeat count
information in advance.

So one can run the whole thing a first time, possibly with engravers gathering information, and then a second time with the acquired data. That sounds interesting. I am not sure about the repeat count information though.

Am I right to say the the music properties are accessible from iterators but not engravers? And thus that, unless an iterator puts the repeat count music property somewhere where an engraver can get it, I have no way of knowing how many times the repeat goes?

Thanks again for your time!

Best,
— Niols



reply via email to

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