Modificació d’articulacions de diversos tipus

A vegades volem modificar un sol temps d’articulació. Tot i que sempre és possible usar l’ordre \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, \customScripts, en un bloc \layout.

#(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 }
>>
[image of music]

Fragments del LilyPond v2.25.32 (development-branch).