On 2019-01-07 6:37 am, Gloops wrote:
Hello!
I am also interested in this code, but is it possible to have a
"list-ref"
running on 12 rather than 7,
and remove the original alterations?
Do you believe that possible?
Thank you for all the help that everyone brings.
Musically
\relative c' {
\override NoteHead.stencil = #(lambda (grob)
(let* ((cause (ly:grob-property grob 'cause))
(pitch (ly:event-property cause 'pitch))
(notenames '("C" "C+" "D" "D+" "E" "F" "F+" "G" "G+" "A"
"A+"
"B"))
(notename (list-ref notenames (ly:pitch-notename pitch))))
(grob-interpret-markup grob #{ \markup
\halign #0 \vcenter \fontsize #-2 \sans \bold $notename #})))
\hide Stem
c4 cis d dis e f fis g gis a ais b
}
ly:pitch-notename returns a value from 0 to 6. You need to use
ly:pitch-alteration to retrieve the information about accidentals. It
will be a rational like -1/2 or 1/2 (for flat and sharp), but possibly
other values if you are doing microtonal work. I recommend using an
association-list:
%%%%
\version "2.19.82"
\relative c' {
\override NoteHead.stencil = #(lambda (grob)
(let* ((cause (ly:grob-property grob 'cause))
(pitch (ly:event-property cause 'pitch))
(alterations '((1/2 . "#")(-1/2 . "b")))
(alteration (assoc (ly:pitch-alteration pitch) alterations))
(notenames '("C" "D" "E" "F" "G" "A" "B"))
(notename (list-ref notenames (ly:pitch-notename pitch))))
(grob-interpret-markup grob #{ \markup
\vcenter \fontsize #-2 \sans \bold \concat {
$notename $(if alteration (cdr alteration) "") } #})))
\hide Stem \omit Accidental
c4 d e fis g a bes c
}
%%%%
NOTE: I got rid of the \halign from my original example as I realized it
was negatively affecting the positioning of the notes themselves.
-- Aaron Hill
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user