2

I found this code for slur-arrows in this question and adapted this answer to make it look nicer.

\version "2.22.0"

slurArrow =
\once \override Slur.stencil =
  #(lambda (grob)
    (let* ((slur-dir (ly:grob-property grob 'direction))
           (right-bound (ly:spanner-bound grob RIGHT))
           (right-bound-stem (ly:grob-object right-bound 'stem))
           (right-bound-stem-dir
             (if (ly:grob? right-bound-stem)
                 (ly:grob-property right-bound-stem 'direction)
                 #f))
           (c-ps (ly:grob-property grob 'control-points))
           (frst (car c-ps))
           (thrd (caddr c-ps))
           ;;; corr-values are my choice
           (corr (cond ((not right-bound-stem-dir)
                        '(0 . 0))
                       ((= slur-dir (* -1 right-bound-stem-dir))
                        (cons -0.4  (* 0.2 slur-dir)))
                       (else '(-0.4 . 0.2))))
           (frth (offset-add (cadddr c-ps) corr)))

      (ly:grob-set-property! grob 'control-points
        (append (list-head c-ps 3) (list frth)))

      (ly:grob-set-property! grob 'line-thickness 0.8)
      (ly:grob-set-property! grob 'thickness 1.2)

    (let* ((orig (ly:grob-original grob))
           (siblings (ly:spanner-broken-into orig)))
       (if (or (null? siblings)
               (equal? grob (car (last-pair siblings))))
           (let* ((default-stil (ly:slur::print grob))
                  (default-stil-lngth
                    (interval-length (ly:stencil-extent default-stil X)))
                  (delta-x-cps (- (car frth) (car frst)))
                  (diff (- default-stil-lngth delta-x-cps))
                  (delta-iv
                    (cons (- (car frth) (car thrd)) (- (cdr frth) (cdr thrd))))
                  (radians->degree (lambda (radians) (/ (* radians 180) PI)))
                  (ang (radians->degree (atan (cdr delta-iv) (car delta-iv))))
                  (arrowhead (ly:font-get-glyph (ly:grob-default-font grob)
                                            "arrowheads.close.01"))
                  (rotated-arrowhead (ly:stencil-rotate arrowhead ang 0 0))
                  (arrowhead-lngth
                    (interval-length (ly:stencil-extent rotated-arrowhead X))))

             (ly:stencil-add
               default-stil
               (ly:stencil-translate
                 rotated-arrowhead
                 ;; Ugh, 3.8 found by trial and error
                 (cons (+ diff (/ arrowhead-lngth 3.8) (car frth))
                       (+ (cdr frth) 0)))))

            (ly:slur::print grob)))))


\relative c'' {
    \slurArrow
    c'4( c \bar "" \break c c)
    \slurArrow
    \slurDown
    c4( c c c)
    \slurArrow
    \stemUp
    \slurUp
    c4( c d a)
    %% maybe add:
    % \shape #'((0 . 0)(0 . 0)(0 . -0.5)(0 . -0.5)) Slur
    \slurArrow
    \slurDown
    c4( a) \slurArrow f( d)
}

enter image description here

Is it possible to define the same arrow-heads for the left side of the slur, so I could use something like:

\slurArrowR for the arrow in the right side (like in the example)
\slurArrowL for the arrow on the left side (Asking how it works...)


Edit:

I found a quite more complex example here. There is arrow heads on both sides, enabling to switch the function on and off, but no possibility to change between --> and <--

enter image description here

3
  • The "complicated" code looks like you can just remove the arrow settings from the \layout section and place them as \once\override at the point of the slur you want to affect. I don't have a way to test (hence the comment rather than answer), but if that works for you, let me know, and I'll add it as an answer.
    – Aaron
    Commented Aug 7, 2021 at 4:45
  • Dear @Aaron · I'm not sure if you understood my question in the right way. I did not ask for ways of on and off switching of the scripts functionality. A was asking if anybody knows a way to create slurs with an arrow on the left side of the bow: <-- The scripts of the examples I posted, create and arrow on the right --> or on both sides <--> of the bow. I hope I understood your comment in the right way. Love, Nathanael
    – nath
    Commented Aug 9, 2021 at 15:08
  • 2
    My comment was unclear. What I mean is that the "complicated" code already appears to handle the arrows you want. I believe it can do left, right, and both. The issue with the existing code is that the slurs are defined in the layout section, so they affect every slur in the score. You can instead remove that code from \layout and place appropriate \overrides immediately before the slur you want to modify.
    – Aaron
    Commented Aug 9, 2021 at 15:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.