]> git.donarmstrong.com Git - lilypond.git/blob - input/test/add-text-script.ly
6d66b21fe73d9f19d9e9e83725f1b0c400138810
[lilypond.git] / input / test / add-text-script.ly
1 \version "2.9.7"
2 \sourcefilename "add-text-script.ly"
3
4 \header {
5 texidoc= "@cindex make-music Fingering
6 You can add various stuff to notes using @code{make-music}.
7 In this example, an extra fingering is attached to a note. 
8 "
9
10
11 #(define (make-text-script x) 
12    (make-music 'TextScriptEvent
13                'direction DOWN
14                'text (make-simple-markup x)))
15
16 #(define (add-text-script m x)
17    (if (equal? (ly:music-property m 'name) 'EventChord)
18        (set! (ly:music-property m 'elements)
19              (cons (make-text-script x)
20                   (ly:music-property m 'elements)))       
21        (let ((es (ly:music-property m 'elements))
22              (e (ly:music-property m 'element)))
23          (map (lambda (y) (add-text-script y x)) es)
24          (if (ly:music? e)
25              (add-text-script e x))))
26    m)
27
28 addScript =
29 #(define-music-function (parser location script music )
30                                         ( string? ly:music? )
31                 (add-text-script music script))
32
33 \score {
34   {
35     \addScript "6" { c'4-3 }
36   }
37 }
38