Hi list,

I am working on a large score with several ties. You might have read about Janek's thoughts on a tie-crusade and maybe this is related. I don't have a perfect solution on this topic, but I could reduce the needed shape-tweaks significantly. I want to share it - probably it helps one and the other has another idea.

The problem I am talking of, are the ties, which sometimes are very near to the next staff-line and are therefor difficult to read. I normally tweak them to make them more or less flat, so that the outer bow has a bigger distance to the next line. This control-point-function ('optie') modifies the tie just a little bit, to automate this procedure.
(If this doesn't fit, I can still use \shape.)

This function is more a proof of concept than a real proposal, but perhaps, this might inspire some development.

Cheers
Jan-Peter

P.S. @Janek: Is this something, you thought of with your tie-crusade?
\version "2.19.32"

% try to avoid collision of ties with staff-lines

% This assumes that there only two y-values per tie, as two tied notes are normally on the same y-level

% function to use for control-points property in Tie grob
optie =
#(lambda (grob)
   (let* ((cp (ly:tie::calc-control-points grob)) ; default control-points
           (cx (map (lambda (p) (car p)) cp)) ; x-values
           (cy (map (lambda (p) (cdr p)) cp)) ; y-values
           (dir (if (> (cadr cy)(car cy)) 1 -1)) ; calc direction (this is also a grob property ...)
           (ymin (apply min cy)) ; minimum y-value
           (ymax (apply max cy)) ; maximum y-value
           (ypad .2) ; pad from lines
           (xpad .2) ; pad from start/end
           )
     (if (and (> (car cy) -2.5)(< (car cy) 2.5)) ; if first cp is in StaffSymbol
         (let* ((xmin (apply min cx)) ; minimum x-value
                 (xmax (apply max cx)) ; maximum x-value
                 (yo (if (> dir 0) ymin ymax)) ; outer y-values
                 (yi (if (> dir 0) ; inner y-values
                         (- (/ (ceiling (* ymax 2)) 2) ypad)
                         (+ (/ (floor (* ymin 2)) 2) ypad)
                         ))
                 )
           ; create control-points
           `((,xmin . ,yo)
             (,(+ xmin xpad) . ,yi)
             (,(- xmax xpad) . ,yi)
             (,xmax . ,yo))
           )
         cp ; if not in StaffSymbol return default values
         )
     ))

\layout {
  \context {
    \Score
    % this would just shape the tie
    %\override Tie.control-points = #optie
    % show default shape in red and modified in green
    \override Tie.stencil =
    #(lambda (grob)
       (let ((def (apply ly:stencil-in-color (ly:tie::print grob) red))) ; get default stencil (in red)
         (ly:grob-set-property! grob 'control-points (optie grob)) ; set control-points function
         (ly:stencil-add def (apply ly:stencil-in-color (ly:tie::print grob) green)) ; combine default stencil (red) with modified (green)
         ))
  }
}

\relative c'' {
  c1~ c c~ \break c
  b~ b \break
  a~ a \break
  d~ d \break
  d,~ d \break
  e4~ e f~ f g~ g a~ a b~ b c~ c d~ d e~ e f~ f g~ g \break
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to