%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% ****************************************************************
% Start cut-&-pastable-section
% ****************************************************************

#(ly:set-option 'eps-box-padding 3.000000)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.000000) (* mm 1))
}

\layout {
  
}




% ****************************************************************
% ly snippet:
% ****************************************************************
\sourcefilename "snippets/overriding-articulations-by-type.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Wiki
%% (https://wiki.lilypond.community).
%%
%% Make any changes in the Wiki itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
%% Translation of GIT committish: 1abe87de51b9b00a391da1be4cf4b5ebe4021ca9
  texidocfr = "
On peut parfois vouloir modifier un seul type d'articulation. Bien que
ce soit tout à fait faisable avec un @code{\\tweak}, cela devient vite
fastidieux d'affiner chaque occurrence d'un même signe dans toute une
partition. Le code ci-dessous illustre la manière de modifier des
articulations grâce à une liste de réglages personnalisés. Ceci peut
servir à créer des feuilles de style.
"

  doctitlefr = "Personnalisation de certains types d'articulation"

%% Translation of GIT committish: 35d4cc1b78c4105643ca5fdcb44cb717578d6d4a
  texidoces = "
A veces queremos modificar un solo timpo de articulación.  Aunque
siempre es posible usar la instrucción @code{\\tweak}, podría
hacerse tedioso hacerlo para todos y cada uno de los símbolos de
una partitura completa.  El ejemplo muestra cómo trucar
articulaciones con una lista de ajustes personalizados.  Un caso
sería la creación de una hoja de estilos.

"
  doctitlees = "Modificación de articulaciones por tipo"

%% Translation of GIT committish: 98ac53591234404cd70c5eebd370a598ec74095b
  texidocca = "
A vegades volem modificar un sol temps d'articulació.  Tot i que
sempre és possible usar l'ordre @code{\\tweak}, podria fer-se tediós
fer-lo per a tots i cada un dels símbols d'una partitura completa.
L'exemple mostra com ajustar articulacions amb una llista
d'ajustaments personalitzats.  Un cas seria la creació d'un full d'estils.

Amb 2.16.2 és possible introduir la funció proposada,
@code{\\customScripts}, en un bloc @code{\\layout}.

"
  doctitleca = "Modificació d'articulacions de diversos tipus"

  categories = "Scheme, Tweaks and overrides"

  texidoc = "
Sometimes you may want to affect a single articulation type. Although
it is always possible to use @code{\\tweak}, it might become tedious to
do so for every single sign of a whole score. The following shows how
to tweak articulations with a list of custom settings. One use-case
might be to create a style sheet.
"

  doctitle = "Overriding articulations by type"
} % begin verbatim



#(define (custom-script-tweaks ls)
   (lambda (grob)
     (let* ((type (ly:event-property (ly:grob-property grob 'cause)
                                     'articulation-type))
           (tweaks (assoc-ref ls type)))
       (when tweaks
         (for-each
          (lambda (x) (ly:grob-set-property! grob (car x) (cdr x)))
          tweaks)))))

customScripts =
#(define-music-function (settings) (list?)
   #{
     \override Script.before-line-breaking =
       #(custom-script-tweaks settings)
   #})
revertCustomScripts = \revert Script.before-line-breaking


% Example

% Predefine two sets of desired tweaks.
#(define my-settings-1
   '((accent . ((font-size . 0)
                (color . (1 0 0))))
     (segno . ((font-size . 0)
               (color . (1 0 0))))
     (staccato . ((color . (1 0 0))
                  (padding . 0.5)))
     (staccatissimo . ((padding . 1)
                       (color . (1 0 0))))
     (tenuto . ((color . (1 0 0))
                (rotation . (45 0 0))
                (padding . 2)
                (font-size . 10)))
    ))

#(define my-settings-2
  '((accent . ((font-size . 4)
               (color . (0 1 0))
               (padding . 1.5)))
    (coda . ((color . (0 1 0))
             (padding . 1)))
    (staccato . ((color . (0 1 0))))
    (staccatissimo . ((padding . 2)
                      (color . (0 1 0))))
    (tenuto . ((color . (0 1 0))
               (font-size . 10)))
    ))

music = { f1-> | f\segno | f-. | f-! | f-- | f--\coda | f-!\fermata | }

block = {
  \music
  \break
  \revertCustomScripts \music
}

\new Staff <<
  \new Voice \with { \customScripts #my-settings-1 }
    \relative c''{ \voiceOne \block }
  \new Voice \with { \customScripts #my-settings-2 }
    \relative c' { \voiceTwo \block }
>>



% ****************************************************************
% end ly snippet
% ****************************************************************
