]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/numbers-as-easy-note-heads.ly
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond
[lilypond.git] / Documentation / snippets / numbers-as-easy-note-heads.ly
1 % Do not edit this file; it is automatically
2 % generated from Documentation/snippets/new
3 % This file is in the public domain.
4 %% Note: this file works from version 2.13.11
5 \version "2.13.11"
6
7 \header {
8   lsrtags = "pitches"
9   texidoc = "
10 Easy notation note heads use the @code{note-names} property
11 of the @code{NoteHead} object to determine what appears inside
12 the note head.  By overriding this property, it is possible
13 to print numbers representing the scale-degree.
14
15 A simple engraver can be created to do this for every note head
16 object it sees.
17 "
18   doctitle = "Numbers as easy note heads"
19 } % begin verbatim
20
21
22 #(define Ez_numbers_engraver
23    (list
24     (cons 'acknowledgers
25           (list
26            (cons 'note-head-interface
27                  (lambda (engraver grob source-engraver)
28                    (let* ((context (ly:translator-context engraver))
29                           (tonic-pitch (ly:context-property context 'tonic))
30                           (tonic-name (ly:pitch-notename tonic-pitch))
31                           (grob-pitch
32                            (ly:event-property (event-cause grob) 'pitch))
33                           (grob-name (ly:pitch-notename grob-pitch))
34                           (delta (modulo (- grob-name tonic-name) 7))
35                           (note-names
36                            (make-vector 7 (number->string (1+ delta)))))
37                      (ly:grob-set-property! grob 'note-names note-names))))))))
38
39 #(set-global-staff-size 26)
40
41 \layout {
42   ragged-right = ##t
43   \context {
44     \Voice
45     \consists \Ez_numbers_engraver
46   }
47 }
48
49 \relative c' {
50   \easyHeadsOn
51   c4 d e f
52   g4 a b c \break
53
54   \key a \major
55   a,4 b cis d
56   e4 fis gis a \break
57
58   \key d \dorian
59   d,4 e f g
60   a4 b c d
61 }