Hi David,

2011/9/25 David Nalesnik <david.nales...@gmail.com>

>
> You could change the function to map ly:grob-set-property! onto the alist
> if a match is found:
>
>  \version "2.14.2"
>
> #(define ls '(
>     ("staccato" . ((color . (0 1 0))))
>     ("accent" . ((font-size . 4)(color . (1 0 0))))
>     ("tenuto" . ((rotation . (45 0 0)) (padding . 2)))
>     ("staccatissimo" . ((padding . -10) (color . (0 0 1))))
>     ))
>
> #(define ((custom-script-tweaks type) grob)
>    (map
>      (lambda (arg)
>        (let ((lst (assoc-ref ls arg)))
>          (if (equal? arg (ly:prob-property (assoc-ref (ly:grob-properties
> grob) 'cause) 'articulation-type))
>              (for-each (lambda (x) (ly:grob-set-property! grob (car x) (cdr
> x))) lst)
>              '())))
>      type))
>
>
> \relative c'' {
>   f1--
>   f1--
>   \override  Script #'before-line-breaking =
>       #(custom-script-tweaks '("staccato" "tenuto" "accent"
> "staccatissimo"))
>
>   f-. f-| f-> f-> f-- f-|
>
>   \revert Script #'before-line-breaking
>   f-> f-.
> }
>

thanks a lot!

I added ls as an argument to the definition to get the possibility to access
different alists in polyphonic situations:

\version "2.14.2"

#(define ls-1 '(
    ("staccato" . ((color . (0 1 0))(padding . 0.5)))
    ("accent" . ((font-size . 4)(color . (1 0 0))))
    ("tenuto" . ((rotation . (45 0 0)) (padding . 2)(font-size . 10)))
    ("staccatissimo" . ((padding . -10) (color . (0 0 1))))
    ))

#(define ls-2 '(
    ("staccato" . ((color . (0 1 0))))
    ("accent" . ((font-size . 4)(color . (0 1 0))(padding . 1.5)))
    ("tenuto" . ((rotation . (-45 0 0)) (padding . 2)(font-size . 10)))
    ("staccatissimo" . ((padding . -10) (color . (0 0 1))))
    ("coda" . ((color . (0 0 1))))
    ))

#(define ((custom-script-tweaks type ls) grob)
   (map
     (lambda (arg)
       (let ((lst (assoc-ref ls arg)))
         (if (equal? arg (ly:prob-property (assoc-ref (ly:grob-properties
grob) 'cause) 'articulation-type))
             (for-each (lambda (x) (ly:grob-set-property! grob (car x) (cdr
x))) lst)
             '())))
     type))

one =
\relative c'' {
  f1--
  f1--
  \override  Voice.Script #'before-line-breaking =
      #(custom-script-tweaks '("staccato" "tenuto" "accent" "staccatissimo")
ls-1)

  f-. f-| f-> f-> f-- f-|

  \revert Script #'before-line-breaking
  f-> f-.
}

two =
\relative c' {
  f1--->
  f1--
  \override  Voice.Script #'before-line-breaking =
      #(custom-script-tweaks '("staccato" "tenuto" "accent" "staccatissimo"
"coda") ls-2)

  f-. f-| f-> f-> f---> f-|

  %\revert Script #'before-line-breaking
  f-> f-.\coda
}

\new Staff <<
   \new Voice { \voiceOne \one }
   \new Voice { \voiceTwo \two }
   >>

Thanks,
  Harm
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to