lilypond-user
[Top][All Lists]
Advanced

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

Re: Highlight specific pitch(es)


From: Jean Abou Samra
Subject: Re: Highlight specific pitch(es)
Date: Fri, 28 Jul 2023 17:43:32 +0200
User-agent: Evolution 3.48.4 (3.48.4-1.fc38)

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

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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