Hi Jan-Peter,

I got to thinking about this [awesome!] engraver you whipped up for me… and I 
realised that there are probably lots of places where someone might want an 
engraver that says

   when X then Y

where X could be any boolean and Y is one or more context or property changes.

How generic could you make an engraver, which allowed users with little or no 
Scheme experience to set up their own "switches"?

Thanks,
Kieren.

On 2013-Jan-23, at 02:49, Jan-Peter Voigt <jp.vo...@gmx.de> wrote:

> % engraver builder
> timeSigChangeEngraver =
> #(define-scheme-function (parser location proc)(procedure?)
>   (lambda (context)
>     (let ((last-fraction #f)) ; remember last time-sig-fraction in this 
> context
>       `(
>         (process-music
>          . ,(lambda (trans)
>               (let (; get current time-sig-fraction
>                     (frac (ly:context-property context 
> 'timeSignatureFraction)))
>                 ; compare the current with the last fraction
>                 (if (and (not (equal? last-fraction frac))
>                          (pair? frac))
>                     ; if they are not equal, do something ...
>                     (begin
>                      ; action for this engraver
>                      (proc context trans)
>                      ; set last-fraction
>                      (set! last-fraction frac)
>                      )))))
>         )
>       )))
> 
> % example
> \new Staff \with {
>  \consists \timeSigChangeEngraver #(lambda (context trans)
>                                      (let ((timingctx (ly:context-find 
> context 'Timing)))
>                                        (ly:context-set-property! timingctx 
> 'whichBar "||")
>                                        ))
> } \relative c'' {
>  bes a c b | bes a c b | \time 3/4 cis c b | cis c b |
> }

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

Reply via email to