[Top][All Lists]

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

Re: Iterators in Scheme?

From: Niols
Subject: Re: Iterators in Scheme?
Date: Thu, 30 Jul 2020 18:22:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

Hello again,

On 29/07/2020 17:28, Jean-Julien Fleck wrote:
Le mer. 29 juil. 2020 à 15:44, Niols < <>> a écrit :

     > What do you want to achieve?

    This is actually follow-up research from my side after a previous
    to this list. I would like to print bar numbers that are "repeat
    that is such that if bars 9 to 12 repeat twice, then the bar numbers go

          1, 2, …, 9, …, 12, 17, 18, etc.

    with a jump after 12 that corresponds to the bars 13 to 16 that are
    actually 9 to 12. Even better, I would like to print the two bar
    for these bars (9/13, 10/14, etc.)

Perhaps this snippet could be of some use for you:

I have been playing with this solution and I find it very satisfactory for my use. I do not understand yet all the intrinsics (in particular with respect to the context-spec-music and the make-apply-context functions), but I understand roughly how it works.

There is just one thing that I would want to "improve" (that is, for my use): the solution needs to map on all the music in order to find all the VoltaRepeatedMusic and override their callbacks to a newly defined one. This is achieved by providing a function "unfoldBarNumbers" that can be applied to any music and that does it.

I would however be interested to have that for all the music in my file, without having to call that function. The different ideas that pop into my mind in such a situation are the following:

1. Maybe I could override the "\repeat" function so that it does the same thing as by default but, when it is a "volta" repeat, it also attaches the new callback to the created music. I believe I see how to achieve that, except I seem unsuccessful in overriding the default definition of "\repeat". Even if I do something like:

    #(define (repeat type num body alts)
      (display "\nrepeat\n"))

    { b4 \repeat volta 2 { b b } b }

it behaves as if I had not put the #(define ...) statement. I have played around this idea for a while without success. I have tried to see if "\repeat" had a special treatment (which it does, at least in the lexing/parsing), but I haven't been able to figure this out.

2. Maybe there is a way to define a function that will be ran before processing on any music? But this I have no idea if this is possible, or how to do it, and my research has proven ineffective so far.

3. Maybe there is a way to override the "make-volta-set" callback instead of creating a new one? Such that then, in LilyPond's normal execution, it uses the new definition and not and old one that then needs to be replaced?

If anyone has any idea on the topic, it would be really useful. In any case, I am quite interested in understanding how the execution works and thus where LilyPond finds the definition of "\repeat", since it is not where I was expecting it.

Thank you in advance, and thank you for your time!
— Niols

reply via email to

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