]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/snippets/overriding-articulations-of-destinct-type.ly
Doc-fr: updates texidocs
[lilypond.git] / Documentation / snippets / overriding-articulations-of-destinct-type.ly
1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
5 %%
6 %% This file is in the public domain.
7 \version "2.17.25"
8
9 \header {
10   lsrtags = "scheme-language, tweaks-and-overrides"
11
12   texidoc = "
13 Sometimes you may want to affect a single articulation-type. Although
14 it is always possible to use @code{\\tweak}, it might become tedious to
15 do so for every single sign of a whole score. The following shows how
16 to tweak articulations with a list of custom-settings. One use-case
17 might be to create a style-sheet.
18
19 With 2.16.2 it is possible to put the proposed function,
20 @code{\\customScripts}, into a @code{\\layout}-block.
21
22 "
23   doctitle = "Overriding articulations of destinct type"
24 } % begin verbatim
25
26 % Code by David Nalesnik and Thomas Morley
27
28 #(define (custom-script-tweaks ls)
29   (lambda (grob)
30     (let* ((type (ly:prob-property
31                     (assoc-ref (ly:grob-properties grob) 'cause)
32                     'articulation-type))
33            (tweaks (assoc-ref ls type)))
34       (if tweaks
35           (for-each
36             (lambda (x) (ly:grob-set-property! grob (car x) (cdr x)))
37             tweaks)))))
38
39 customScripts =
40 #(define-music-function (parser location settings)(list?)
41 #{
42   \override Script.before-line-breaking =
43     #(custom-script-tweaks settings)
44 #})
45
46 revertCustomScripts = { \revert Script.before-line-breaking }
47
48 %%%%%%%%%%%%%
49 % Example:
50 %%%%%%%%%%%%%
51
52 % Predefine a list of desired tweaks.
53 #(define my-settings-1
54   '(
55     ("staccato" . ((color . (1 0 0))(padding . 0.5)))
56     ("accent" . ((font-size . 0)(color . (1 0 0))))
57     ("tenuto" . ((rotation . (45 0 0)) (padding . 2)(font-size . 10)))
58     ("staccatissimo" . ((padding . 1) (color . (1 0 0))))
59     ("segno" . ((font-size . 0)(color . (1 0 0))))
60     ))
61
62 #(define my-settings-2
63   '(
64     ("staccato" . ((color . (0 1 0))))
65     ("accent" . ((font-size . 4)(color . (0 1 0))(padding . 1.5)))
66     ("tenuto" . ((font-size . 10)))
67     ("staccatissimo" . ((padding . 2) (color . (0 1 0))))
68     ("coda" . ((color . (0 1 0)) (padding . 1)))
69     ))
70
71 one =
72 \relative c'' {
73   f1--
74   \customScripts #my-settings-1
75   f-. f-! f-> f-- f-!\segno
76   \revertCustomScripts
77   f-> f-.
78 }
79
80 two =
81 \relative c' {
82   f1--
83   \customScripts #my-settings-2
84   f-. f-! f-> f---> f-!
85   f-> f-.\coda
86 }
87
88 \new Staff <<
89    \new Voice { \voiceOne \one }
90    \new Voice { \voiceTwo \two }
91    >>