lilypond-user
[Top][All Lists]
Advanced

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

Re: How to print measure position as each note prints


From: Neil Puttock
Subject: Re: How to print measure position as each note prints
Date: Tue, 23 Sep 2014 11:47:09 +0100

On 23 September 2014 11:16, Jay Vara <address@hidden> wrote:
>>I am not top-posting
>
> I am trying to figure out how measure position and measure length work
> so that I can change them to work properly with compound metres with
> appropriate bar lines, notes on bars split and tied etc.
>
> Two issues I have are:
> 1) Where to place the function that prints measure position and measure
> length. By looking at a few snippets, I thought I would put an override
> on the NoteHead stencil as in the code below.
>
> 2) How to retrieve the measure position and length. Again, looking at a
> few snippets I came up with the code below.
>
> As it would be obvious to the experts, the code is not working. It
> prints nothing. Can someone suggest what I should change?

There's a debug callback for PaperColumn which will print this
information automatically.

Add this to your \layout block:

\context {
\Score
\override PaperColumn.stencil = #ly:paper-column::print
}

If you're using Frescobaldi, there's an option to turn this on automatically.

>
> \version "2.18.2"
>
> myNoteHeadTry =
> #(lambda (grob)
>    (let* (
>            ;; bindings
>            (measure-pos (ly:context-property grob 'measurePosition))
>            (measure-len (ly:context-property grob 'measureLength))

ly:context-property takes a context as first argument.  This is not
available from a grob callback - it passes the grob instead.

>            )
>      ;; body
>      (format "Position ~a Length ~a ~%" measure-pos measure-len)

You don't set this to anything that the grob will read (see below).

>      (ly:text-interface::print grob)

ly:text-interface::print grob looks at the 'text property.

Unless the grob supports text-interface (which NoteHead doesn't) you
should use the helper function grob-interpret-markup instead which
takes the grob and a markup as arguments.

Cheers,
Neil



reply via email to

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