Utilisateur:Psychoslave/lilypond
- https://lilypond.org/doc/v2.23/Documentation/notation/note-heads
- https://duckduckgo.com/?t=ffab&q=anatomie+d%27une+note+de+solf%C3%A8ge+hampe&iax=images&ia=images&iai=https%3A%2F%2Fwww.apprendrelesolfege.com%2F_dl%2Fimages%2Fanatomie-note-de-musique.png
- https://lilypond.org/doc/v2.23/Documentation/learning-big-page.fr.html
- https://lilypond.org/doc/v2.23/Documentation/snippets/pitches
- https://stackoverflow.com/questions/46796783/custom-note-heads-in-lilypond
- https://musicnotation.org/wiki/software/lilypond/
- https://lilypond.community/t/soucis-demail-sur-ce-forum/5777
\version "2.24.4"
%Association list of pitches to colors.
#(define color-mapping
(list
(cons (ly:make-pitch 0 0 NATURAL) (x11-color 'red))
(cons (ly:make-pitch 0 0 SHARP) (x11-color 'green))
(cons (ly:make-pitch 0 1 FLAT) (x11-color 'green))
(cons (ly:make-pitch 0 2 NATURAL) (x11-color 'red))
(cons (ly:make-pitch 0 2 SHARP) (x11-color 'green))
(cons (ly:make-pitch 0 3 FLAT) (x11-color 'red))
(cons (ly:make-pitch 0 3 NATURAL) (x11-color 'green))
(cons (ly:make-pitch 0 4 SHARP) (x11-color 'red))
(cons (ly:make-pitch 0 5 NATURAL) (x11-color 'green))
(cons (ly:make-pitch 0 5 FLAT) (x11-color 'red))
(cons (ly:make-pitch 0 6 SHARP) (x11-color 'red))
(cons (ly:make-pitch 0 1 NATURAL) (x11-color 'blue))
(cons (ly:make-pitch 0 3 SHARP) (x11-color 'blue))
(cons (ly:make-pitch 0 4 FLAT) (x11-color 'blue))
(cons (ly:make-pitch 0 5 SHARP) (x11-color 'blue))
(cons (ly:make-pitch 0 6 FLAT) (x11-color 'blue))))
%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
(and
(= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
(= (ly:pitch-notename p1) (ly:pitch-notename p2))))
#(define (pitch-to-color pitch)
(let ((color (assoc pitch color-mapping pitch-equals?)))
(if color
(cdr color))))
#(define (color-notehead grob)
(pitch-to-color
(ly:event-property (event-cause grob) 'pitch)))
\score {
\new Staff \relative c' {
\aikenHeads
\override NoteHead.color = #color-notehead
c8 b d dis ees f g aes
}
}
\score {
{
\aikenHeads
c''2 a' c' a
% Switch to thin-variant noteheads
\set shapeNoteStyles = ##(doThin reThin miThin
faThin sol laThin tiThin)
c'' a' c' a
}
}