lilypond-user
[Top][All Lists]
Advanced

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

Re: Slur as TupletBracket


From: address@hidden
Subject: Re: Slur as TupletBracket
Date: Sat, 22 Oct 2011 11:29:14 +0200

On Oct 22, 2011, at 1:44 AM, Thomas Morley wrote:

Hi Mke

2011/10/21 address@hidden <address@hidden>
i <3 hacks

\version "2.15.12"
\relative c'' {
 \override TupletBracket #'stencil = #ly:slur::print
 \override TupletBracket #'direction = #UP
 \override TupletNumber #'whiteout = ##t
 \override TupletNumber #'layer = #2
 \override TupletBracket #'layer = #1
 \override TupletNumber #'Y-offset = #(lambda (grob) (+ 0.5 (ly:tuplet-number::calc-y-offset grob)))
 \override TupletBracket #'control-points =
#(lambda (grob)
  (let ((x-pos (ly:grob-property grob 'X-positions))
        (pos (ly:grob-property grob 'positions)))
    (list (cons (car x-pos) (car pos))
          (cons (+ (car x-pos) (/ (interval-length x-pos) 3)) (+ (car pos) 0.5))
          (cons (+ (car x-pos) (* (interval-length x-pos) 2/3)) (+ (cdr pos) 0.5))
          (cons (cdr x-pos) (cdr pos)))))
\repeat unfold 10 \times 2/3 { a4 b4 c }
}

To be messed with to your heart's content :)
This'll only work in one of the more recent development versions, as X-positions is a new addition to LilyPond.

Cheers,
MS

Hi Mike,

I tested your suggestion with "2.15.13" and  get this warning:

In procedure car in _expression_ (car x-pos):
atest.ly:13:17: Wrong type (expecting pair): ()

Searching 'X-positions gives no result, even in define-grob-properties.scm.

Am I missing something?

Harm

Hey Harm,
I compiled it against current master.  If your version of LilyPond doesn't have an X-positions property, you can assemble something that works like X-positions by getting the two spanner bonuds via ly:spanner-bound and then getting their relative coordinates.

\version "2.14.0"
\relative c'' {
 \override TupletBracket #'stencil = #ly:slur::print
 \override TupletBracket #'direction = #UP
 \override TupletNumber #'whiteout = ##t
 \override TupletNumber #'layer = #2
 \override TupletBracket #'layer = #1
 \override TupletBracket #'control-points =
#(lambda (grob)
  (let* ((b-l (ly:spanner-bound grob LEFT))
         (b-r (ly:spanner-bound grob RIGHT))
         (crf (ly:grob-common-refpoint b-l b-r X))
         (x-pos (cons (ly:grob-relative-coordinate b-l crf X) (ly:grob-relative-coordinate b-r crf X)))
         (pos (ly:grob-property grob 'positions)))
    (list (cons (car x-pos) (car pos))
          (cons (+ (car x-pos) (/ (interval-length x-pos) 3)) (+ (car pos) 0.5))
          (cons (+ (car x-pos) (* (interval-length x-pos) 2/3)) (+ (cdr pos) 0.5))
          (cons (cdr x-pos) (cdr pos)))))
\repeat unfold 10 \times 2/3 { a4 b4 c }
}

In 2.14.0 the TupletNumber Y-offset callback doesn't exist, so I've nixed it.  This messes with the tuplet number positioning, but you can write a positioning fixed based on the coordinates of the bracket.  To get the bracket, if the TupletNumber is `grob' in a function, use (ly:grob-object grob 'bracket).

Cheers,
MS

reply via email to

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