[Top][All Lists]

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

problems with routine to adjust inner points of slur

From: David Nalesnik
Subject: problems with routine to adjust inner points of slur
Date: Fri, 16 Oct 2009 18:26:23 -0500

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


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

reply via email to

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