summaryrefslogtreecommitdiff
path: root/Documentation/snippets/adding-extra-fingering-with-scheme.ly
blob: 3a7c32b0d9c5489ccfa1d69e46fcb13f3c24ef76 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
% DO NOT EDIT this file manually; it is automatically
% generated from Documentation/snippets/new
% Make any changes in Documentation/snippets/new/
% and then run scripts/auxiliar/makelsr.py
%
% This file is in the public domain.
%% Note: this file works from version 2.16.0
\version "2.18.0"

\header {
  lsrtags = "scheme-language"

  texidoc = "
You can add additional elements to notes using @code{map-some-music}. In this
example, an extra script is attached to a note.

In general, first do a @code{\\displayMusic} of the music you want to
create, then write a function that will work on the appropriate parts
of the music for you.
"
  doctitle = "Adding extra fingering with scheme"
} % begin verbatim


addScript =
#(define-music-function (parser location script music)
   (ly:event? ly:music?)
   (map-some-music
    (lambda (mus)
      (define (append-script-at! prop)
        (set! (ly:music-property mus prop)
              (append (ly:music-property mus prop)
                      (list (ly:music-deep-copy script))))
        mus)
      (case (ly:music-property mus 'name)
        ((EventChord)
         (append-script-at! 'elements))
        ((NoteEvent)
         (append-script-at! 'articulations))
        (else #f)))
    music))

\score {
  {
    \addScript _6 { c'4-3 <c' e' g'> }
  }
}