lilypond-user
[Top][All Lists]
Advanced

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

Re: Scheme question: context from grob?


From: David Nalesnik
Subject: Re: Scheme question: context from grob?
Date: Thu, 19 May 2016 18:04:02 -0500

Hi Steven,

On Thu, May 19, 2016 at 4:01 PM, Steven Weber <address@hidden> wrote:
> Is there any way to get the context from a grob?

Not that I know of.

> Or is there another way to
> get the current bar number from a grob?

Yes, you can do this using the function grob::rhythmic-location which
will return a pair consisting of the bar number and the moment within
that bar of the passed-in grob.

Example of usage:

\version "2.19.30"

#(define after-break-function
   (lambda (grob)
     (let* ((loc (grob::rhythmic-location grob))
            (bar (car loc))
            (mom (cdr loc))
            (name (grob::name grob)))
       (format #t "~%~a at ~a of measure ~a" name mom bar))))

\relative c {
  \override NoteHead.after-line-breaking = #after-break-function
  \repeat unfold 20 { c2 d }
}

I don't remember when the function was introduced, but you will need
one of the development releases (2.19.something) to use it (and
grob::name as well).

Hope this gets you started--
David



reply via email to

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