lilypond-user
[Top][All Lists]
Advanced

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

Re: Thanks to David Nalesnik and Jan-Peter Voigt


From: David Nalesnik
Subject: Re: Thanks to David Nalesnik and Jan-Peter Voigt
Date: Sun, 28 Sep 2014 14:39:06 -0500

Hi Jay,

On Sun, Sep 28, 2014 at 12:48 PM, David Nalesnik <address@hidden> wrote:


On Sun, Sep 28, 2014 at 10:30 AM, Jay Vara <address@hidden> 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


reply via email to

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