Perfectly what I've been looking for. Thanks a lot for the code as well
as for the hint to the callback explanation, Jean!

Am 28.07.2023 um 17:43 schrieb Jean Abou Samra:

Le vendredi 28 juillet 2023 à 16:46 +0200, Stephan Schöll a écrit :

Hi all

In order to ease pitch orientation for novice score readers I'd like
to highlight the fundamental / key note (tonika) and perhaps the 5th
throughout an entire piece. The most obvious marking might be by
coloring the note head (and stem).

In the following MVE I'd like to highlight alle the c's and g's:

\relative c' {    c4 d e c    e f g2 }

That's a good job for a simple callback.

|\version "2.24.1" \layout { \context { \Score \override
NoteHead.color = #(lambda (grob) (let* ((pitch (ly:event-property
(event-cause grob) 'pitch)) (semi (modulo (ly:pitch-semitones pitch)
12))) (cond ((eqv? semi 0) "red") ((eqv? semi 7) "blue") (else
"black")))) } } \relative c' { c d e f g f e d c b a g fis g a b c1 } |

There is a very similar example on
https://extending-lilypond.gitlab.io/fr/extending/backend.html#understanding-callbacks

HTH,

Jean

Reply via email to