Hi David,

Thank you very much.  Now I know how to use the listeners!

With your change it seems to work for the two-staff example with (7 4) (1
4) (2 4) meter. This is the only case of compound metre that I commonly use
that has a (1 4) as one of the components.

Just to be sure, I did check a few other metres, and whenever there is a (1
4) an issue is possible. Typically the problems seem to be in the first few
measures. For example, the two staff example with meter = #'((1 4) (2 4))
gives the following.

[image: Inline image 2]
Best regards
Jay


On Mon, Sep 29, 2014 at 1:37 AM, David Nalesnik <david.nales...@gmail.com>
wrote:

> Hi Jay,
>
> On Sun, Sep 28, 2014 at 7:24 PM, David Nalesnik <david.nales...@gmail.com>
> wrote:
>>
>>
>> Possibly the problem is that the custom engraver is setting measureLength
>> too late for Completion_heads_engraver to use it?
>>
>>
> That just might be it.  The Completion_heads_engraver listens for
> note-events.  So, doing this same with the custom engraver gives us the
> code below:
>
>  alternateTiming =
> #(lambda (sig)
>    (lambda (context)
>      (let ((last-bnum 0))
>        (make-engraver
>         (listeners ((note-event engraver event)
>                     (let* ((bnum (ly:context-property context
> 'currentBarNumber))
>                            (len (length sig)) ; how many terms in compound
> meter
>                            (pos (modulo bnum len))
>                            (pos (if (= 0 pos) len pos)) ; first bar in
> pattern, second...
>                            (pos-in-list (1- pos)) ; because elements of
> list are numbered from 0
>                            (desired-measure-len (to-moment (list-ref sig
> pos-in-list))))
>                       (ly:context-set-property! context 'measureLength
> desired-measure-len)
>                       (format #t "bnum = ~a len ~a pos ~a measurelength ~a
> completion ~a~%"
>                         bnum len pos
>                         (ly:context-property context 'measureLength)
>                         (ly:context-property context 'completionUnit))
>                       (if (= pos-in-list 0)
>                           (begin
>                            (if (> bnum last-bnum)
>                                (ly:context-set-property! context 'whichBar
> "||"))
>                            (set! last-bnum bnum))))))))))
>
> %%%%%%%%%%%
>
> This appears to work with your two-staff example.  How it fares with
> others, I don't know.  Keep your fingers crossed.
>
> Note: You're using an older syntax for Scheme engravers.  I've adapted
> this one to use the make-engraver macro that David Kastrup introduced at
> some point.
>
> Best,
> David
>
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to