3

Is it possible to color the sharps (or flats) in a key signature using lilypond?

Notes can be individually colored:

\version "2.22.2"

\score {
  \relative {
 \key a \major 
 \omit Score.TimeSignature
 a b
 \override NoteHead #'color = #red
 cis  
  }
}

colored note

How about sharps in the key signature?

enter image description here

2
  • 1
    I think that if your goal is to create instructional music, it would be clearer to have arrows pointing at the items you're trying to emphasise. If a music symbol is coloured then you have to read it twice - first time to get the colour which has some significance that you're trying to emphasise, and a second time for its actual musical significance ("third sharp in the key signature is G#" or "don't forget to play me as C# rather than C natural" Apr 29, 2022 at 11:48
  • 1
    I think it depends on context. In this case the examples will be close together with multiple key signatures, so arrows might clutter it. Below I've found a solution, not sure if the best one but it works.
    – Vlad
    Apr 29, 2022 at 12:42

1 Answer 1

3
% Functions
prepare =  
{\omit Score.TimeSignature
 \omit Score.BarLine
 \omit NoteHead
}

color_it = \once \override Accidental.color = red
end_it = {g g \undo \omit Score.BarLine \bar "||"}

\score {
  \relative {\prepare 
    fis''1
    \color_it
    cis
    \end_it
  }
}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.