Hi all
Some time ago, I started colouring the tonic and dominant notes in my
choir scores. I realised that this helps singers who do not have
advanced music reading skills enormously. In pop arrangements in
particular, individual voices often revolve around a ‘key note’, e.g.
tenor or alto around the dominant (similar to a horn part in an
orchestra ;-) ). The colours serve as an visual anchor so it's easy/ier
to find their "way home".
As far as I remember, I got the \override NoteHead.color code here from
the mailing list, although I couldn't find it in the archive right now.
It is much simpler than
wiki.lilypond.community/wiki/Coloring_notes_depending_on_their_pitch or
https://wiki.lilypond.community/wiki/Coloring_notes_depending_on_their_pitch_(2),
which serve the same or similar purpose.
%%%
\version "2.24.4"
\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 7)
"green")
((eqv? semi 0)
"red")
(else "black"))))
}
}
melody = \relative c' {
c4^\markup \teeny \column {"tonic" "= red"} d e f g1^\markup \teeny
\column {"dominant" "= green"}
}
\score {
\new Staff {
\clef treble
\key c \major
\melody
\key d \major
\transpose c d \melody
}
}
%%%
However, in both cases, the pitch colour assignment is defined
globally/statically. In the MVE:
* Tonic = C = red (pitch MODULO 0)
* Dominant = g = green (pitch MODULO 7)
This means that in every song, I have to initially set the two pitch
numerical values for green and red depending on the key.
However, I would also like to colour the notes correctly when the song
transposes, i.e. changes key, during its course.
What would I need to do to be able to change the tonic/dominant
assignment during the song, e.g.
* tonic = D = red (pitch MODULO 2)
* dominant = A = green (pitch MODULO 9)
for bar 2
I suspect that this would have to be done using some kind of function
that can be called up with the appropriate parameters, or ideally simply
with the key. But that is beyond my (Scheme) programming skills.
Many thanks in advance for any helpful advice.
- Stephan