lilypond-user
[Top][All Lists]
Advanced

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

Re: Systematically Shortening Slurs


From: Nick Payne
Subject: Re: Systematically Shortening Slurs
Date: Sun, 23 Oct 2011 07:32:20 +1100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1

On 23/10/11 07:07, J Ruiz wrote:
I need to show a scale of notes, where every note has a slur to the next one.
Lilypond typesets the slurs with length to each notehead center, so my chain of slurs have ends that meet, not visually pleasing.
In this case, I'd like the slurs to be somewhat shortened, such that slur ends are some distance before the note head centers, but are still centralized between each note pair.
I can't seem to find a way to systematically override slur end-point location relative to note head destinations.

Can't remember where I got this function from, but it does what you want.

\version "2.15.14"

shapeSlur = #(define-music-function (parser location offsets) (list?)
    #{
        \override Slur #'control-points = #(alter-slur-curve $offsets)
    #})

#(define ((alter-slur-curve offsets) grob)
    ;; get default control-points
    (let ((coords (ly:slur::calc-control-points grob))
        (n 0))
    ;; add offsets to default coordinates
    (define loop (lambda (n)
        (set-car! (list-ref coords n)
            (+ (list-ref offsets (* 2 n))
                (car (list-ref coords n))))
        (set-cdr! (list-ref coords n)
            (+ (list-ref offsets (1+ (* 2 n)))
                (cdr (list-ref coords n))))
        (if (< n 3)
            (loop (1+ n)))))
    ;; return altered coordinates
    (loop n)
    coords))

\relative c'' {
    c4( d)( e)( f)
    \shapeSlur #'(0.2 0 0 0 0 0 0 -0.2)
    c( d)( e)( f)
    \revert Slur #'control-points
    c( d)( e)( f)
}

Attachment: shapeslur.png
Description: PNG image


reply via email to

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