[Top][All Lists]

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

Re: A slur enclosed by parentheses or brackets

From: Aaron Hill
Subject: Re: A slur enclosed by parentheses or brackets
Date: Fri, 11 Sep 2020 22:25:44 -0700
User-agent: Roundcube Webmail/1.4.2

On 2020-09-11 9:18 pm, Jun Tamura wrote:

Is there an easy way to have a slur enclosed by parentheses or
brackets? Some urtext editions use parenthesized slurs to indicate
editorial additions.

\parenthesize does not currently handle spanners, so you would need to do some manual work.


\version "2.20.0"

parenthesizeSlur =
  -\tweak stencil
  #(lambda (grob)
    (let* ((cp (ly:grob-property grob 'control-points))
           (lp (grob-interpret-markup grob (markup #:teeny "(")))
           (rp (grob-interpret-markup grob (markup #:teeny ")"))))
      (set! lp (ly:stencil-aligned-to lp Y CENTER))
      (set! lp (ly:stencil-aligned-to lp X 0.2))
      (set! lp (ly:stencil-translate lp (first cp)))
      (set! rp (ly:stencil-aligned-to rp Y CENTER))
      (set! rp (ly:stencil-aligned-to rp X -0.2))
      (set! rp (ly:stencil-translate rp (last cp)))
      (list-set! cp 0
        (cons (cdr (ly:stencil-extent lp X))
              (cdr (first cp))))
      (list-set! cp (1- (length cp))
        (cons (car (ly:stencil-extent rp X))
              (cdr (last cp))))
      (ly:grob-set-property! grob 'control-points cp)
      (apply ly:stencil-add (list lp rp
        (ly:slur::print grob)))))

{ g'4\parenthesizeSlur (
     \parenthesizeSlur \( b' c''2 ) |
  g'2\parenthesizeSlur ( f'4 e' ) \) }

-- Aaron Hill

Attachment: paren-slur.cropped.png
Description: PNG image

reply via email to

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