2009/10/17 David Nalesnik <[email protected]>:
> Can you tell me why this is happening, and what I can do to fix it? (Also,
> please let me know if there's a more elegant way to structure this...I'm
> sure that's part of the problem!)
You're setting a parser variable (internal-offset) in the music to two
different values, but this process happens before the slurs exist; by
the time they're getting the result of the 'control-points callback,
the value of internal-offset is its last setting (5).
Pass the input value directly to the callback instead:
expandSlur =
#(define-music-function (parser location input) (number?)
#{
\once \override Slur #'control-points = #(more-curve $input)
#}
)
Use currying (or partial application) for the callback:
#(define ((more-curve internal-offset) grob)
(define first-pair (car coords))
If you change let to let*, you won't need to use define.
(define second-pair (car (cdr coords)))
(define third-pair (car (cdr (cdr coords))))
(define fourth-pair (car (cdr (cdr (cdr coords)))))
You could replace these with cadr, caddr and cadddr respectively.
Regards,
Neil
\version "2.12.2"
\paper {
indent = #0
ragged-right = ##t
}
expandSlur =
#(define-music-function (parser location input) (number?)
#{
\once \override Slur #'control-points = #(more-curve $input)
#}
)
#(define ((more-curve internal-offset) grob)
(let* ((coords (ly:slur::calc-control-points grob)) ; get control-points
;; break list into component pairs
(first-pair (car coords))
(second-pair (cadr coords))
(third-pair (caddr coords))
(fourth-pair (cadddr coords)))
;; adjust y-coordinates of middle points
(set-cdr! second-pair (+ internal-offset (cdr second-pair)))
(set-cdr! third-pair (+ internal-offset (cdr third-pair)))
;; reassemble control-point list
(list first-pair second-pair third-pair fourth-pair)))
top = \relative c'' {
\clef treble
\time 3/4
\key c \major
%default slur
c2 ( d4 e8 d c b a g )
\expandSlur #2
c2 ( d4 e8 d c b a g )
\expandSlur #5
c2 ( d4 e8 d c b a g )
}
\score {
\new Staff <<
\new Voice { \top }
>>
}_______________________________________________
lilypond-user mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-user