lilypond-user
[Top][All Lists]
Advanced

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

Re: Displaying variables and parameter values


From: David Sumbler
Subject: Re: Displaying variables and parameter values
Date: Fri, 22 Jan 2016 21:51:15 +0000

On Fri, 2016-01-22 at 22:33 +0100, Simon Albrecht wrote:
> On 22.01.2016 22:18, David Sumbler wrote:
> > On Tue, 2016-01-19 at 16:26 +0100, Simon Albrecht wrote:
> >> On 19.01.2016 16:20, David Sumbler wrote:
> >>> Is there a way of displaying the current value of particular variables
> >>> and parameters during Lilypond compilation?
> >> Of course, e.g. with
> >> #(format "Variable ‘foo’ currently has the value ~a\n" foo)
> >> where foo is the variable, ~a references the next argument after the
> >> string and \n outputs a newline.
> >> You should be able to insert this everywhere.
> > Trying this with a variable I have set myself, I find that within a
> > music expression it generates an error, and outside it produces nothing
> > at all.
> 
> I’m so sorry, I keep getting this wrong. It should have read
> #(format #t "Variable ‘foo’ currently has the value ~a\n" foo)
> (the #t tells format to display the formatted string on the commandline 
> instead of simply returning it).
> 
> > What I should really like to be able to do is to display the current
> > value of a variable such as Score.MetronomeMark.X-offset within a music
> > expression, but I can't seem to achieve this even with the #(display
> > var) form - I suspect that the variable has to be expressed in a
> > different format.
> 
> That’s more complicated, since this is not a variable but a grob property.
> Try
> %%%%%%%%%%%%%%
> \version "2.18.2"
> {
>    \once\override Score.MetronomeMark.X-offset = 5
>    \once\override Score.MetronomeMark.after-line-breaking =
>    #(lambda (grob)
>       (let ((off (ly:grob-property grob 'X-offset)))
>         (format #t "This MetronomeMark has an X-offset of ~a.\n" off)))
>    \tempo "Allegro"
>    c''1
> }
> %%%%%%%%%%%%%%
> This defines a /grob callback/, which is processed after line breaking, 
> retrieves the value for the grob property and sends it to the log.
> If you have questions about this, feel free to ask.

The revised #(format... works fine.

And the #(lambda... expression is also great.  Thanks for both of these
items.

David




reply via email to

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