lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: placement sostenuto


From: Thomas Morley
Subject: Re: placement sostenuto
Date: Mon, 26 Sep 2011 01:24:48 +0200

Hi David,

2011/9/25 David Nalesnik <address@hidden>

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)) 

>\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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]