lilypond-user
[Top][All Lists]
Advanced

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

Tie/slur variable thickness vs shape


From: Pierre Perol-Schneider
Subject: Tie/slur variable thickness vs shape
Date: Fri, 22 May 2020 07:16:50 +0200

Hi,
I'm using Abraham's function: http://lsr.di.unimi.it/LSR/Item?id=1028
However, the overrides are killed by the shape adjustment:

%%
\version "2.20.0"

#(define (variable-bow-thickness min-l max-l min-t max-t)
  (lambda (grob)
    (let (;; get the procedure to calculate the control-points
          (cpf (assoc-get 'control-points (ly:grob-basic-properties grob))))
      (if (procedure? cpf)
          (let* (;; get first and last control-point to calculate the length
                 ;; of the bow
                 (cpt (cpf grob))
                 (cp0 (car cpt))
                 (cp3 (cadddr cpt))
                 (dx (- (car cp3) (car cp0)))
                 (dy (- (cdr cp3) (cdr cp0)))
                 (len (magnitude (make-rectangular dx dy)))
                 ;; return a value for thickness
                 ;;   below min-l             -> min-l
                 ;;   greater than max-l      -> max-l
                 ;;   between min-l and max-l -> calculate a nice value
                 (thickness
                   (cond ((< len min-l) min-t)
                         ((> len max-l) max-t)
                         (else
                           (+ min-t
                             (* (- len min-l)
                                (/ (- max-t min-t)
                                   (- max-l min-l))))))))
            ;; print info in terminal
            ;(format #t "\n~a has \n\tlength ~a \n\tand \n\tthickness ~a"
            ;  grob
            ;  len
            ;  thickness)
            thickness)
          ;; if no control-points can be calculated use default value
          1.2))))

\layout {
  ragged-last = ##f
  \override PhrasingSlur.thickness = #(variable-bow-thickness 6 25 1 3)
  \override Slur.thickness = #(variable-bow-thickness 6 25 1 3)
  \override Tie.thickness = #(variable-bow-thickness 6 18 1 2)
}

%% Test:
{
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Tie
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) Slur
  %\shape #'((0 . 0) (0 . 0) (0 . 0) (0 . 0)) PhrasingSlur
  c''1~\(( 1 1 1) 1 1\)
}
%%

Any idea how to avoid that?
TIA, cheers,
Pierre

reply via email to

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