On 2018-11-16 4:24 pm, Kieren MacMillan wrote:
[ . . . ]

Kieren,

Would something like the following be of any help?

%%%%
\version "2.19.82"

#(define (contract-control-points coords amount)
  (let* ((x-coords (map (lambda (coord) (car coord)) coords))
         (orig-left (apply min x-coords))
         (orig-right (apply max x-coords))
         (new-left (+ (* orig-left (- 1 (car amount)))
                      (* orig-right (car amount))))
         (new-right (+ (* orig-left (cdr amount))
                       (* orig-right (- 1 (cdr amount))))))
    (map (lambda (coord)
      (let ((t (/ (- (car coord) orig-left) (- orig-right orig-left))))
        (cons (+ new-left (* t (- new-right new-left))) (cdr coord))))
      coords)))

contractSlur = #(define-music-function (amount evt) (pair? ly:music?)
  #{ \tweak control-points #(lambda (grob)
      (contract-control-points
        (ly:slur::calc-control-points grob)
        amount)) $evt #})
globalContractSlur = #(define-music-function (amount) (pair?)
  #{ \override Slur.control-points = #(lambda (grob)
      (contract-control-points
        (ly:slur::calc-control-points grob)
        amount))
     \override PhrasingSlur.control-points = #(lambda (grob)
      (contract-control-points
        (ly:slur::calc-control-points grob)
        amount)) #})

csr = -\contractSlur #'(0 . 0.05) \etc
csl = -\contractSlur #'(0.05 . 0) \etc

\relative f' {
  \override Score.RehearsalMark.self-alignment-X = #-1
  \mark \markup \small "Default behavior"
  f8 ( e g ) ( e f2 ) |
  f8 \( e g \) \( e f2 \) |

  \mark \markup \small "Overridden behavior"
  \globalContractSlur #'(0.1 . 0.1)
  f8 ( e g ) ( e f2 ) |
  f8 \( e g \) \( e f2 \) |

  \mark \markup \small "Tweaked behavior"
  f8 -\csr ( e g ) -\csl ( e f2 ) |
  f8 -\csr \( e g \) -\csl \( e f2 \) |
}
%%%%

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

Reply via email to