Am 27.04.2012 19:30, schrieb David Nalesnik:
Hi Urs,

On Fri, Apr 27, 2012 at 11:46 AM, Urs Liska <li...@ursliska.de <mailto:li...@ursliska.de>> wrote:

    Hi David,

    thank you for now. I'll look into it.
    But isn't it very likely that I have to reshape a slur anyway when
    it changes from  broken to unbroken?
    In that case I'd even say the errors are a 'feature' so you notice
    it ...
    Provided it is documented enough not to drive you crazy ...


Sure, that's true. Presumably when you're looking for that fine control, you've settled on the layout in all but the tiny details!
it's not only this. I think that with any slur that one might decide to shape manually a change in line break will spoil it anyway. So I'm not so sure it's a useful goal to make such a function fool-proof in this respect.
Without the modification, though, the error would cause the file to fail and the error message is a little opaque. (Well, it's quite exact, but it takes some study to figure out how it happened.)
Well, the file fails (at least lilypond says so), but it actually compiles, it's only the function that isn't applied. But you're right to assume that the normal user can't cope with the error messages ;-)
I could create a warning here, something like: "slur is not broken anymore".
If that's possible in such functions, I'd find it very useful. Even better: tell the user: "The slur has now X parts, please adapt the function call"
One thing you can do is
\shapeSlur #'( ... list of offsets ...)
or
\shapeSlur #'(( ... list of offsets ...))

without the file failing.

Since this function has come up again, I wonder if I could get your (and other people's) opinion on syntax. When I first wrote the offsetting function (http://lsr.dsi.unimi.it/LSR/Item?id=639)I <http://lsr.dsi.unimi.it/LSR/Item?id=639%29I> thought that alists were a bother to type. But 'control-pojnts _is_ an alist '((x1 . y1) (x2 . y2) ... )) , so shouldn't we have something like this?

\shapeSlur #'((dx1 . dy1) (dx2 . dy2) ...)

I realize that there's more to type, but wouldn't this be clearer to use? (As well as being more consistent with how LilyPond represents this type of data)?
First: I think this is a _very_ useful function that should even be made more widely known. The need to shape slurs is one of the most important issues when it comes to the major problems of a LilPond score. Not because it's a deficit of LilyPond but because it's a very complex topic that needs human intervention in most cases.

Second: your syntax suggestion looks very good to me.
Of course it is more to type. But that is more than outweighed by the advantages. it's easier to write and it's especially much easier to read. When changing the offsets (which you do multiple times until you get a good result ...) I'm always finding me counting params (in order to find the right item to change) which surely takes more time and concentration than typing (once) a few brackets and points.

Third: I suggest to add support for PhrasingSlurs and Ties in order to make it more general. For PhrasingSlurs it's just a matter of writing a new entrance function, but for Ties you need new shape-ties and alter-tie-curve subroutines. See the attached file that is the result of an earlier enquiry on this mailing list. The functions themselves don't incorporate your newest additions (sorry, it's still a bit over my head), but you'll see what I mean.

Any thoughts?
to sum up what I said:
If you'd volunteer to do the following it would be a very valuable contribution to LilyPond's usability ;-) - let the function check the number of arguments and give meaningful warnings instead of errors
(count arguments and compare against number of slur siblings)
- don't try to make the function robust so that it accepts wrong input. This may be trivial from a programmer's perspective but I can't imagine that it makes sense aesthetically.
- add support for phrasingSlurs and ties
- make all this visible, at least through an updated snippet in the LSR. Personally I think this should also be in the docs.


With best wishes
Urs

-David


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

%{
  shapeXXX.ily
  base include file with typographic tweaks
  modifing the shapes of Bezier curved spanners.
  
  Provided by Urs Liska (m...@ursliska.de)
  
  Exported functions:
  - shapeSlur
  - shapePhrasingSlur
  - shapeTie
  
  This version works also with line broken curves
  and modifies the shapes of the siblings individually
  
  Usage: \shapeXXX (offsets) music
  offset is a list of eight numbers indicating the x and y offsets
  for the four control-points of the curve
  for each part of a broken slur one can give a separate list.
  An empty list means that the respective slur isn't altered
  
  in contrast to overriding the control-points property
  this function takes offsets relative to LilyPond's 
  default decision. So the function can often be left
  unaltered even when the layout changes slightly
  
  example for a single slur:
    \shapeSlur #'( 0 0  3 -1  6 2  -5 0 ) ...
  example for a broken phrasing slur
    \shapePhrasingSlur #'(
      (0 1  0 0  0 -4  0 2)
      (4 3  2 5  -1 4  0 0)
      () % Don't change the third part
      ) ...  
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  The first version of a shapeSlur function was developed by Neil Puttock
    (see http://lists.gnu.org/archive/html/lilypond-user/2009-09/msg00495.html)
  Another version was added to the Lilypond Snippet Repository
    (see http://lsr.dsi.unimi.it/LSR/Snippet?id=639)
  Later the function was enhanced to deal with broken slurs
  by Dmytro O. Redchuk and David Nalesnik (don't know exactly how)
    (see http://permalink.gmane.org/gmane.comp.gnu.lilypond.general/65612)
  With the help of the lilypond-user mailing list I finally 
  adapted the function to also work with Ties and polished the file to 
  export the three functions
  
  One thing which is still missing is the ability of the function to
  automatically react when a slur is broken / unbroken 
  as a reaction to changed line breaks
  
  At the moment (August 2011) there seems to be a discussion about 
  whether to include this function to the LSR or the docs
  or even to LilyPond
  
%}

\version "2.14.0"


#(define ((alter-slur-curve offsets) grob)
   ;; get default control-points
   (let ((coords (ly:slur::calc-control-points grob)))
     ;; add offsets to default coordinates
     (define (add-offsets coords offsets)
       (if (null? coords)
       '()
       (cons
         (cons (+ (caar coords) (car offsets))
               (+ (cdar coords) (cadr offsets)))
         (add-offsets (cdr coords) (cddr offsets)))))

     (if (null? offsets)
         coords
         (add-offsets coords offsets))))


#(define ((shape-slur 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:
                       ((alter-slur-curve (list-ref offsets n)) grob)
                       (if (< n total-found)
                           (loop (1+ n))
                           ;; end of list -- none found?!
                           ;; return defaults:
                           ((alter-slur-curve '()) grob))))
         ;;
         ;; shape UNBROKEN
         ((alter-slur-curve offsets) grob))))

% Changed function to shape ties

#(define ((alter-tie-curve offsets) grob)
   ;; get default control-points
   (let ((coords (ly:tie::calc-control-points grob)))
     ;; add offsets to default coordinates
     (define (add-offsets coords offsets)
       (if (null? coords)
       '()
       (cons
         (cons (+ (caar coords) (car offsets))
               (+ (cdar coords) (cadr offsets)))
         (add-offsets (cdr coords) (cddr offsets)))))

     (if (null? offsets)
         coords
         (add-offsets coords offsets))))


#(define ((shape-tie 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:
                       ((alter-tie-curve (list-ref offsets n)) grob)
                       (if (< n total-found)
                           (loop (1+ n))
                           ;; end of list -- none found?!
                           ;; return defaults:
                           ((alter-tie-curve '()) grob))))
         ;;
         ;; shape UNBROKEN
         ((alter-tie-curve offsets) grob))))


shapePhrasingSlur =
#(define-music-function (parser location offsets)
                        (list?)
  #{
    \once \override PhrasingSlur #'control-points = #(shape-slur offsets)
  #})


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

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


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

Reply via email to