X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Documentation%2Fsnippets%2Fnew%2Fnumbers-as-easy-note-heads.ly;fp=Documentation%2Fsnippets%2Fnew%2Fnumbers-as-easy-note-heads.ly;h=03e0578af27e012b19d97a9fa3ef3036eca76bd1;hb=941dff9d2a67080e0dd8474f1e70f0c72ace6424;hp=0000000000000000000000000000000000000000;hpb=5a22d6233a39d3164e1ca043244794c268be4ad0;p=lilypond.git diff --git a/Documentation/snippets/new/numbers-as-easy-note-heads.ly b/Documentation/snippets/new/numbers-as-easy-note-heads.ly new file mode 100644 index 0000000000..03e0578af2 --- /dev/null +++ b/Documentation/snippets/new/numbers-as-easy-note-heads.ly @@ -0,0 +1,56 @@ +\version "2.14.0" + +\header { + lsrtags = "pitches" + texidoc = " +Easy notation note heads use the @code{note-names} property +of the @code{NoteHead} object to determine what appears inside +the note head. By overriding this property, it is possible +to print numbers representing the scale-degree. + +A simple engraver can be created to do this for every note head +object it sees. +" + doctitle = "Numbers as easy note heads" +} + +#(define Ez_numbers_engraver + (list + (cons 'acknowledgers + (list + (cons 'note-head-interface + (lambda (engraver grob source-engraver) + (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)) + (note-names + (make-vector 7 (number->string (1+ delta))))) + (ly:grob-set-property! grob 'note-names note-names)))))))) + +#(set-global-staff-size 26) + +\layout { + ragged-right = ##t + \context { + \Voice + \consists \Ez_numbers_engraver + } +} + +\relative c' { + \easyHeadsOn + c4 d e f + g4 a b c \break + + \key a \major + a,4 b cis d + e4 fis gis a \break + + \key d \dorian + d,4 e f g + a4 b c d +}