lilypond-user
[Top][All Lists]
Advanced

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

Re: incomplete tuplets in non-standard time signatures


From: Thomas Morley
Subject: Re: incomplete tuplets in non-standard time signatures
Date: Mon, 6 Apr 2020 13:29:58 +0200

Am So., 5. Apr. 2020 um 19:59 Uhr schrieb 98123981293 1293812397123
<address@hidden>:
>
> Dear list,
>
> In the following example, I would like to:
> 1) In the first voice: make the tuplet line to the right of the number into a 
> dashed straight line.
> 2) In the second voice: fix the appearance of the last tuplet in the measure 
> so that the number does not clash with the bracket, and the bracket is not 
> horizontally flipped. Once this is accomplished, I would like to apply the 
> same appearance with dotted right lines from step one. I've attached a .png 
> drawing of roughly how I want it to look.
>
> This thread (https://www.mail-archive.com/address@hidden/msg89110.html) 
> addresses these types of alterations, but affects the whole bracket; is there 
> any way to adjust the left and right sides of the bracket independently?  If 
> this has already been addressed elsewhere please let me know so that I may 
> consult the relevant documentation/snippet/archive.
>
> Thank you for your time,
> -Kyle

Hi,

ad 2) A TupletBracket needs bounds to the left and the right, which
must be _not_ the same.
You need a workaround, see example-code below.

ad 1) For your request one needs to recreate the stencil.
Below my own take on it. It relies heavily on how the stencil is
created currently, this may vary in future version. Then the code will
break.
Furthermore, in 2.20.0 the bracket edges are always solid, In the
hopefully upcoming soon 2.21.0 there will be the dashed-edge-property
for customizing them.

Below relies on a dashed TupletBracket, making parts of it solid.
'edge-height may be set separately.

Cheers,
  Harm

\version "2.20.0"

#(define (translated-dashed-line->draw-line bool lst)
;; lst is supposed to be a list retrieved from a stencil-expression, p.e.
;;     (translate-stencil
;;       (17.1123059321317 . 0.0)
;;       (dashed-line
;;         0.16 <- thick
;;         0.409629549559636 <- on
;;         0.614444324339455 <- off
;;         -7.57814666685327 <- x-destination
;;         0.0 <- y-destination
;;         0.0 <- phase
;;         ))
;; This procedure will transform it into:
;;     (drawline
;;       thick
;;       x-start
;;       y-start
;;       x-end
;;       y-end)

  (if (and bool
           (>= (length lst) 3)
           (not (eq? (car lst) 'draw-line)))
      (let* ((translate (list-ref lst 1))
             (dashed-line (last lst))
             (thick (list-ref dashed-line 1))
             (x-dest (list-ref dashed-line 4))
             (y-dest (list-ref dashed-line 5)))
        (list
          'draw-line
          thick
          (car translate)
          (cdr translate)
          (+ x-dest (car translate))
          (+ y-dest (cdr translate))))
      lst))

#(define (half-solid-tuplet-bracket bool-pair)
(lambda (grob)
  (if (and ;; continue if the TupletBracket is dashed
           (eq? (ly:grob-property grob 'style) 'dashed-line)
           ;; continue if left or right part should become solid
           (or (car bool-pair) (cdr bool-pair))
           ;; don't continue, if TupletBracket is omitted
           (not (ly:stencil-empty? (ly:grob-property grob 'stencil)))
           ;; don't continue, if the whole TupletBracket should be dashed
           (not (and (car bool-pair) (cdr bool-pair))))
      ;; make left or right part solid
      (let* ((stil (ly:grob-property grob 'stencil))
             (x-ext (ly:stencil-extent stil X))
             (y-ext (ly:stencil-extent stil Y))
             (stil-expr (ly:stencil-expr stil))
             (translate (list-ref stil-expr 1))
             (combined-stil (last stil-expr))
             (new-stencil-expr
               (list
                 'translate-stencil
                 translate
                 (cons 'combine-stencil
                    (map
                      (lambda (i)
                        (translated-dashed-line->draw-line
                          (if (odd? i)
                              (cdr bool-pair)
                              (car bool-pair))
                          (list-ref combined-stil i)))
                      (iota 4 1 1))))))
      (ly:grob-set-property! grob 'stencil
        (ly:make-stencil
          new-stencil-expr
          x-ext
          y-ext))))))

halfSolidTupletBracket =
#(define-music-function (pair)(pair?)
#{
  \override TupletBracket.after-line-breaking =
    #(half-solid-tuplet-bracket pair)
#})

%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Examples
%%%%%%%%%%%%%%%%%%%%%%%%%%
\paper { ragged-right = ##f }
{
  \once \halfSolidTupletBracket #'(#t . #f)
  \once \override TupletBracket.style = #'dashed-line
  %% set edges
  \once \override TupletBracket.edge-height = #'(0.7 . 0)
  \times 2/3 { b4 4 4 }

  %% default
  \times 2/3 { b4 4 4 }

  \once \override TupletBracket.dash-period = #0.5
  \once \override TupletBracket.dash-fraction = #1/6
  \once \override TupletBracket.style = #'dashed-line
  \halfSolidTupletBracket #'(#t . #f)
  %% available with hopefully upcoming soon 2.21.0:
  %% with 2.20.0 edges are always solid
  %\once \override TupletBracket.dashed-edge = ##t
  \times 2/3 {
    \omit Tie g8.*1/2~ \noBeam \hideNotes g8.*1/2
  }
  r8 r4 r2
}



reply via email to

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