lilypond-user
[Top][All Lists]
Advanced

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

How to get bar lines between measures programmatically


From: Jay Vara
Subject: How to get bar lines between measures programmatically
Date: Thu, 25 Sep 2014 17:39:58 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

I am using Completion_heads_engraver that break long notes and 
automatically tie them into the next measure. I have a compound measure, 
say ((3 4) (2 4) (2 4)). I need the Completion_heads to work not only 
after 7 quarter notes (which it does), but also after 3 and 5 notes. I 
also need bar lines at these spots.

I modified an engraver I was using to set the completionUnit variable to 
achieve breaking of long notes and automatically tie them after 3 and 5 
notes also. Now, my question is how to get the bar lines to print at 
these positions. I tried setting measurePosition to zero without success 
(lines 31-32, commented out now).

\version "2.18.2"

fs = #(ly:make-moment 3 4)
ss = #(ly:make-moment 5 4)
ts = #(ly:make-moment 7 4)
zs = #(ly:make-moment 0 4)


#(define SolfegeEngraver
   (list
    (cons 'acknowledgers
      (list
       (cons 'note-head-interface
         (lambda (engraver grob source-engraver)
           (let* ((context (ly:translator-context engraver))
                  (tonic-pitch (ly:context-property context 'tonic))
                  (measure-pos (ly:context-property context 
'measurePosition))
                  (measure-len (ly:context-property context 
'measureLength))
                  (cu (ly:context-property context 'completionUnit))
                  (ns (ly:context-now context))
                  (enna (ly:context-property context 'whichBar))
                  (tonic-name (ly:pitch-notename tonic-pitch))
                  (delta (- 7 tonic-name))
                  (solfege-base (circular-list "S" "R" "G" "M" "P" "D" 
"N"))
                  (solfege (take (drop solfege-base delta) 7))
                  (note-names (apply vector solfege))
                  )
             (if (ly:moment<?  measure-pos fs) (ly:context-set-property! 
context 'completionUnit fs)
                 (if (ly:moment<?  measure-pos ss) (ly:context-set-
property! context 'completionUnit ss)
                     (ly:context-set-property! context 'completionUnit 
ts) ))
            ; (if (= (ly:moment-main measure-pos) (ly:moment-main fs)) 
            ;     (ly:context-set-property! context 'measurePosition 
zs))
             (format #t "length ~a position ~a completionUnit ~a now-ns 
~a whichbar ~a ~%" measure-len measure-pos cu ts enna)
            
             (ly:grob-set-property! grob 'note-names (vector "S" "R" "G" 
"M" "P" "D" "N"))
             
             )


           )))))

   )


\score {
  \new Staff
  {

    \new Voice
    {
      \easyHeadsOn
      \compoundMeter #'((3 4) (2 4) (2 4) )


      \relative c' { c d e2  f2 g2 a2 b4 c2 c b4 a g f2 e d4 c}

    }


  }
  \layout {
    \context {
      \Voice
      \consists \SolfegeEngraver
      \remove Note_heads_engraver
      \remove Rest_engraver
      \consists Completion_heads_engraver
      \consists Completion_rest_engraver

    }
  }
}





reply via email to

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