Now instead of the note name, I would like to write the numbers representing the scale-degree inside the note head. So I tried adding to the previous code the snippet I found in the documentation but it doesn't compile. This is code..
#(define Ez_numbers_engraver
((note-head-interface engraver grob source-engraver)
(let* ((context (ly:translator-context engraver))
(tonic-pitch (ly:context-property context 'tonic))
(tonic-name (ly:pitch-notename tonic-pitch))
(ly:event-property (event-cause grob) 'pitch))
(grob-name (ly:pitch-notename grob-pitch))
(delta (modulo (- grob-name tonic-name) 7))
(make-vector 7 (number->string (1+ delta)))))
(ly:grob-set-property! grob 'note-names note-names))))))
\consists \Ez_numbers_engraver
\new RhythmicStaff { a4 b8 a }
Thank you, g.