lilypond-user
[Top][All Lists]
Advanced

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

Re: Highlight specific pitch(es)


From: Stephan Schöll
Subject: Re: Highlight specific pitch(es)
Date: Fri, 28 Jul 2023 17:59:53 +0200
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

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

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