lilypond-user
[Top][All Lists]
Advanced

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

Re: Glissando in parentheses


From: Thomas Morley
Subject: Re: Glissando in parentheses
Date: Mon, 16 Oct 2017 22:43:26 +0200

2017-10-16 19:38 GMT+02:00 Rodney Duplessis <address@hidden>:
> I want to put a glissando in parentheses. I’ve tried to adapt some snippets
> (for example, http://lsr.di.unimi.it/LSR/Item?id=902 and
> http://lsr.di.unimi.it/LSR/Item?id=647) to my needs but I couldn’t get any
> results.
>
> Best,
> Rodney



It's not difficult to parenthesize a spanner-stencil, we have
'parenthesize-stencil' if you want to try, but you wouldn't want
that...

Parenthesizing not horizontal lines like Glissando has two difficulties:
(1)
You need to place reasonable sized parentheses left/right at the line
and align them properly.
(2)
But this would extend the Glissando to both sides, leaving too less
space or even causing collisions with other objects. So you need to
shorten the Glissando.

Here my attempt:

\version "2.19.65"

\paper { ragged-right = ##f }

%% c/p from stencil.scm
#(define (make-parenthesis-stencil
         y-extent thickness width angularity orientation)
  "Create a parenthesis stencil.
@var{y-extent} is the Y extent of the markup inside the parenthesis.
@var{half-thickness} is the half thickness of the parenthesis.
@var{width} is the width of a parenthesis.
@var{orientation} is the orientation of a parenthesis.
The higher the value of number @var{angularity},
the more angular the shape of the parenthesis."
  (let* ((start (cons 0 (car y-extent)))
         (stop (cons 0 (cdr y-extent)))
         (line-width 0.1)
         (bow-stil
           (make-bow-stencil
             start stop thickness angularity width orientation))
         (x-extent (ly:stencil-extent bow-stil X)))
    (ly:make-stencil
      (ly:stencil-expr bow-stil)
      (interval-widen x-extent (/ line-width 2))
      (interval-widen y-extent (/ line-width 2)))))

#(define parenthesized-gliss-stencil
  (lambda (grob)
    (let* ((stil (ly:line-spanner::print grob))
           (stil-x-ext (ly:stencil-extent stil X))
           (left-bound-info (ly:grob-property grob 'left-bound-info))
           (left-Y (assoc-get 'Y left-bound-info))
           (right-bound-info (ly:grob-property grob 'right-bound-info))
           (right-Y (assoc-get 'Y right-bound-info))
           (parentheses-proc
             (lambda (val dir)
               ;; TODO should 'make-parenthesis-stencil' be public?
               (make-parenthesis-stencil
                  ;; numeric values are my choice, Harm
                  (cons (- val 0.7) (+ val 0.7)) ;; y-extent
                  0.05 ;;thickness
                  0.3  ;;width
                  0  ;;angularity
                  dir  ;;orientation
                  )))
           (left-par (parentheses-proc left-Y 1))
           (right-par (parentheses-proc right-Y -1))
           (left-par-x-length (interval-length (ly:stencil-extent left-par X))))
    (ly:message "\tLimitation: does not work for broken Glissando")
    (ly:stencil-add
      (ly:stencil-translate-axis left-par (car stil-x-ext) X)
      stil
      (ly:stencil-translate-axis right-par (cdr stil-x-ext) X)))))

{
  \time 3/2

  %% maybe add more padding (default is on both sides 0.5):
  \once \override Glissando.bound-details.left.padding = 1
  \once \override Glissando.bound-details.left-broken.padding = 1
  \once \override Glissando.bound-details.right.padding = 1
  \once \override Glissando.bound-details.right-broken.padding = 1

  \once \override Glissando.stencil = #parenthesized-gliss-stencil

  cis''1.\glissando
  dis'
}



HTH,
  Harm



reply via email to

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