Hi LilyPonders,
I'm trying to write a function which will make a slur more rounded by
adjusting its middle points while leaving the note-attachments the same.  I
came up with something that works--except that
when I try to modify two slurs, both slurs take on the new values for the
second one.  (If you uncomment the %\expandSlur #5 line you will see what I
mean.)
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!)

--David

\version "2.12.2"

\paper {
  indent = #0
  ragged-right = ##t
}

#(define internal-offset #f)

expandSlur =
  #(define-music-function (parser location input) (number?)
      (set! internal-offset input)
    #{
      \once \override  Slur #'control-points = #more-curve
    #}
)

#(define (more-curve grob)
        (let ((coords (ly:slur::calc-control-points grob))) ; get
control-points

        ; break list into component pairs
        (define first-pair (car coords))
        (define second-pair (car (cdr coords)))
        (define third-pair (car (cdr (cdr coords))))
        (define fourth-pair (car (cdr (cdr (cdr 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

Reply via email to