lilypond-user
[Top][All Lists]
Advanced

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

Re: change barline type with time signature change


From: Kieren MacMillan
Subject: Re: change barline type with time signature change
Date: Tue, 26 Feb 2013 14:54:02 -0500

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 <address@hidden> 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 |
> }



reply via email to

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