Last year it was asked how to get the horizontal position of the bar
lines (and first beats):
http://lists.gnu.org/archive/html/lilypond-user/2012-01/msg00762.html

I'd like to get each beat position as well. My first thought was
something along these lines:

========================
#(define (average a b)
  (/ (+ a b) 2))

#(define (create-print-x-offset tag)
  (lambda (grob)
    (let* ((system (ly:grob-system grob))
           (x-extent (ly:grob-extent grob system X))
           (x (average (car x-extent) (cdr x-extent))))
      (display (ly:grob-properties system))
      (newline)
      (display (string-append tag ":"))
      (display x)
      (newline))))

music = \relative c'
{
  \repeat unfold 3 {c2 c8 c4 c8 |}
}

outline =
{
  \override Score.BarLine.after-line-breaking = #(create-print-x-offset "bar")
  \repeat unfold 3
  {
    \repeat unfold 4
    {
      \once \override Score.NoteColumn.after-line-breaking =
#(create-print-x-offset "note")
      s4
    } |
  }
}

\score
{
  \new Staff
  <<
    \music
    \outline
  >>
}
========================

For the beats that don't have a note column it doesn't work. The
example above only has notes directly on the first and third beats:
{c2 c8 c4 c8 |}. Adding in hidden notes will affect the spacing so
that won't work. My only other thought is to equally space the missing
beats between the note columns that are found, but that could be
tricky. Any suggestions? Thanks.

-----Jay

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

Reply via email to