Hi Stefan,

On Tue, Feb 20, 2024 at 9:49 AM Stefan Thomas <kontrapunktste...@gmail.com>
wrote:

> Dear community,
> is it possible to display the dynamics, also haipins and other things like
> crescendo etc., in coulour?
> Could someone could give me a hint?
>

Sure can. Most (if not all) grobs have a color property that can be
overridden. If you want to change all grobs of that type in a score to a
certain color, you can put the override into the layout block. Or, if you
want to change just one instance, you can put the override into the music
expression. Here's some sample code showing both:

\version "2.24.3"

mus = \relative c' {
  f4\p a4\< c8 d b4\f |
  \once \override DynamicText.color = #yellow f4\p a4\< c8 d b4\f
}

\score {
  \new Staff {
    \new Voice {
      \mus
    }
  }
}

\layout {
  \context {
    \Voice
    \override Hairpin.color = #red
    \override DynamicText.color = #blue
  }
}

producing:

[image: image.png]

The overrides in the layout block have gone into the Voice context, as
that's where they live by default. If, however, you put your dynamics into
a Dynamics context of their own you would need to modify the layout block
accordingly.

The override in the music expression is using the \once command, so that
only the next instance of that grob is affected. If you want to change
*all* the grobs of that type from that point onward, just omit the \once

Also, one of the (sometimes) tricky parts can be finding the right name for
the grob. The best resource I've found for that is:
https://lilypond.org/doc/v2.25/Documentation/ly-examples/visualindex.pdf
It's a 2 page PDF with an amazing amount of information. It's listed as
being in the 2.25 docs, but if you're using the 2.24 series it should still
be useful, as I'm pretty sure all the grob names, contexts, end engravers
are pretty much the same names.
-- 
Michael

Reply via email to