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