lilypond-user
[Top][All Lists]
Advanced

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

Re: Access grob name?


From: David Nalesnik
Subject: Re: Access grob name?
Date: Thu, 17 Sep 2015 07:51:31 -0500

Hi Simon,

On Thu, Sep 17, 2015 at 7:20 AM, David Kastrup <address@hidden> wrote:
Simon Albrecht <address@hidden> writes:

> Hello,
>
> I’ve written a music function which applies some tweaks on dynamics to
> offset them. Unfortunately, it’s not possible to use the offset music
> function on X-offset, because it is a mutable property.

You can use \offset on DynamicText.X-offset.

{
  c''\> g' -\offset DynamicText.X-offset 3 \f
}

Any property that accepts a number, number-pair, or number-pair-list and has a default value listed in the grob's page in the Internals Reference is offset-able.  (This documentation is taken directly from define-grobs.scm.)

Unofrtunately, DynamicLineSpanner has no default value; thus, there's nothing for offset to work with.

> Thus I have to add a displacement for DynamicText so that it is not
> aligned to its baseline, but to the ‘center’ like normally.  Now, it
> would help if the music function could find out by itself whether to
> apply this displacement, depending on which grob it is applied to. As
> an example (attached also): %%%%%%%%%% \version "2.19.27"
>
> test =
> #(define-music-function (ev) (ly:music?)
>    (tweak 'color red ev))
>
> {
>   c''-\test \> g'-\test \f
> }
> %%%%%%%%%%
> How can I modify the function so that only the DynamicText is colored,
> the Hairpin isn’t?

If you do need the name, try:

test =
#(define-music-function (ev) (ly:music?)
   (if (eq? (ly:music-property ev 'name) 'AbsoluteDynamicEvent)
       (tweak 'color red ev)
       ev))

{
  c''-\test \> g'-\test \f
}


Hope this is helpful--
David

reply via email to

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