On 13/01/2026 15:04, Stephan Schöll via LilyPond user discussion wrote:
Can anybody explain why adding both the Scale_degree_colored_notes_engraver and the Ambitus_engraver to a voice results in an "Exited with return code 1" error.

The Scale_degree_colored_notes engraver is trying to colour the ambitus' note heads, but some information is missing. Here is a fix to the engraver -- there may be a more elegant solution.

#(define Scale_degree_colored_notes_engraver
   (make-engraver
    (acknowledgers
     ((note-head-interface engraver grob source-engraver)
      (when (event-cause grob)
        (let* ((context (ly:translator-context engraver))
               (tonic-pitch (ly:context-property context 'tonic))
               (tonic-name (ly:pitch-notename tonic-pitch))
               (grob-pitch
                (ly:event-property (event-cause grob) 'pitch))
               (grob-name (ly:pitch-notename grob-pitch))
               (delta (modulo (- grob-name tonic-name) 7))

               ;; vector of colors indexed by scale degree (0–6)
               ;; red for tonic, green for dominant
               (colors
                (vector
                 (x11-color 'red)
                 (x11-color 'black)
                 (x11-color 'black)
                 (x11-color 'black)
                 (x11-color 'green)
                 (x11-color 'black)
                 (x11-color 'black)))

               ;; select color for this note
               (note-color (vector-ref colors delta)))

          ;; set notehead color
          (ly:grob-set-property! grob 'color note-color)))))))

--
Timothy Lanfear, Bristol, UK.

Reply via email to