lilypond-user
[Top][All Lists]
Advanced

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

Re: Letters as note heads


From: Aaron Hill
Subject: Re: Letters as note heads
Date: Tue, 08 Jan 2019 02:23:05 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-01-08 12:24 am, Gloops wrote:
Indeed it's what I wanted "ly: pitch-semitones" but there is a mistake at
the change of octave …

[ . . . ]

%No good
\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-semitones 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 c
}

The output from LilyPond exactly explains the issue:

In procedure list-ref in expression
  (list-ref notenames (ly:pitch-semitones pitch)):
Argument 2 out of range: 12

ly:pitch-semitones is returning 12 as opposed to 0. I'm not sure why this is expected behavior, but a simple modulus operation would be good enough to patch it:

    (modulo (ly:pitch-semitones pitch) 12)

By the way, you should remove the "\halign #0" as it overly compresses the spacing on the left side of a note, resulting in uneven spacing of notes within the measure.


-- Aaron Hill



reply via email to

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