On Wed 15 Dec 2010, 12:59 Nick Payne wrote:
> Here's a small example that demonstrates the problem. The lower of
> the two ties between bars 2 and 3 appears to go to the wrong note,
> and if you uncomment the override for the tie control points to get
> it correctly positioned vertically, the continuation of the tie in
> bar 3 starts at the left of the clef symbol.
Hi, Nick,

i've posted a function for shaping broken slurs (thanks to Neil and an
author of that snippet, see source attached), see here:
http://www.mail-archive.com/lilypond-user@gnu.org/msg57796.html

Now (see attached) here is modified version, which defines both \shapeSlur and
\shapeTie; these can shape both broken and unbroken curves.

Now, if broken one becomes unbroken, it will be "shaped" with defauls and
coloured in red; the same for unbroken which becomes broken. Change staff size
to smth like 16 to see the difference.

I have included your sample and attached a picture.

Sorry.. is that what you need?-)

"I can miss and/or mess virtually anything" (mt)^W(tm)

ps. Please, anyone, i am not sure i am doing things rigth! If you can suggest
better code, please do!

-- 
  Dmytro O. Redchuk
  Bug Squad

  Be careful! These are some commonly used abbreviations:
   • LM -- Learning Manual
   • NR -- Notation Reference
   • IR -- Internal Reference

  Look at LilyPond’s documentation to find more.
\version "2.13.43"

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% http://lsr.dsi.unimi.it/LSR/Snippet?id=639 :
%LSR Thanks to Neil Puttock for his help!

% http://lists.gnu.org/archive/html/lilypond-user/2007-08/msg00539.html
% http://lists.gnu.org/archive/html/lilypond-user/2009-09/msg00495.html
% thanks, Neil!!

#(define (grob-name grob)
         (assoc-get 'name
           (assoc-get 'meta
             (ly:grob-basic-properties grob))))


#(define ((alter-curve offsets) grob)
   ;; get default control-points
   (let* (
         (name (grob-name grob))
         (calculator (if (eq? name 'Slur)
                          ly:slur::calc-control-points
                          ly:tie::calc-control-points))
         (coords (calculator 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)))))
     (if (null? offsets)
         coords
         ;; return altered coordinates
         (begin
           (loop n)
           coords))))


#(define (brokeness-changed grob)
  ;; mark in red color and return defaults:
  (ly:grob-set-property! grob 'color red)
  ((alter-curve '()) grob))


#(define ((shape-curve offsets) grob)
   (let* (
          ;; have we been split?
          (orig (ly:grob-original grob))
          ;; if yes, get the split pieces (our siblings)
          (siblings (if (ly:grob? orig)
                        (ly:spanner-broken-into orig) '() ))
          (total-found (length siblings)))
     (if (>= total-found 2)
         ;; shape BROKEN
         ;; walk through siblings, find index in list
         ;; and apply offsets from list of offsets:
         (let loop ((n 0))
                   (if (eq? (list-ref siblings n) grob)
                       ;; return altered:
                       (if (list? (list-ref offsets n))
                          ((alter-curve (list-ref offsets n)) grob)
                          (brokeness-changed grob))
                       (if (< n total-found)
                           (loop (1+ n))
                           ;; end of list -- none found?!
                           ;; return defaults:
                           ((alter-curve '()) grob))))
         ;;
         ;; shape UNBROKEN
         (if (number? (car offsets))
             ((alter-curve offsets) grob)
             (brokeness-changed grob)))))

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

shapeTie =
#(define-music-function (parser location offsets)
                        (list?)
  #{
    \once \override Tie #'control-points = #(shape-curve $offsets)
  #})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


#(set-global-staff-size 24)

\relative c'' {
  \time 6/4
  << {
      a'8 g fis e dis e \acciaccatura e d4. c'8 b4 |
      c4 r2 s2. |
      dis8 b c b a g b2\rest <e gis,>4 |
    } \\ {
      fis,,,8 e' dis e fis b, c4. g8 a4 |
      dis2 r4 s2. |
      b2 r4 r2. |
    } \\ {
      fis4 s2 s2. |
      s8 e'' fis e g fis ~ fis4. gis8 a4 ~ |
      a4 c,2\rest s2. |
    } \\ {
      s1. |
      c8\rest b a g a c dis4. e,8
      % \once \override Tie #'control-points = #'((1 . -2) (2.5 . -2.5) (3.5 . 
-2.5) (5 . -2))
      \shapeTie#'(() (0 .7  0 .7  0 .7  0 .7))
      fis4 ~ |
      fis4 s2 fis'8 e dis cis dis b |
  } >>
}

\header {
  tagline = ""
}

<<attachment: test.png>>

_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to