Hi Jay,

On Sun, Sep 28, 2014 at 12:48 PM, David Nalesnik <david.nales...@gmail.com>
wrote:

>
>
> On Sun, Sep 28, 2014 at 10:30 AM, Jay Vara <j...@diljun.com> wrote:
>
>> I wanted to get bar lines after each sub-meter of a compound meter, and
>> to have Completion_heads_engraver recognize these bar lines and split
>> and tie notes as needed.
>>
>> Thanks to David and Jan-Peter, I was able to change their
>> doubleBarlinesAfterTimeSig engraver to achieve this effect. I still have
>> a little more work to do since some of the moment variables currently
>> have fixed values.
>
>
Here's an idea to make the engraver more flexible:

 \version "2.18.0"

meter = #'((3 4) (5 4) (2 4))

#(define (to-moment arg)
   (ly:make-moment (car arg) (cadr arg)))

alternateTiming =
#(lambda (sig)
   (lambda (context)
     (let ((last-bnum 0))
       `((process-music
          . ,(lambda (trans)
               (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))))

                 (format #t "bnum = ~a measurelength ~a ~%"
                   bnum
                   (ly:context-property context 'measureLength))

                 (ly:context-set-property! context 'measureLength
desired-measure-len)
                 (if (= pos-in-list 0)
                     (begin
                      (if (> bnum last-bnum)
                          (ly:context-set-property! context 'whichBar "||"))
                      (set! last-bnum bnum))))))))))

music = {
  \compoundMeter #meter
  \relative c' {c d e2 f g4 a2 b c4 b2 a g4 f2 e d c d e f g a b c d4}
}

\score {
  \new Staff \music
  \layout {
    \context {
      \Score
      \consists #(alternateTiming meter)
    }
    \context {
      \Voice
      \remove Note_heads_engraver
      \remove Rest_engraver
      \consists Completion_heads_engraver
      \consists Completion_rest_engraver
    }
  }
}

%%%%%%%%%%%%
Some notes:

I moved last-bnum into the engraver, as there's no need for it to be a
global variable.  Initialize it in the let-block.

The compound meter can be any length (well, there should be a guard against
0, I suppose).

It's easy enough to create the moments you need for measureLength with a
function.

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

Reply via email to