lilypond-user
[Top][All Lists]
Advanced

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

Re: TupletNumber direction


From: Thomas Morley
Subject: Re: TupletNumber direction
Date: Sun, 11 Nov 2012 23:31:36 +0100

2012/11/11 David Nalesnik <address@hidden>:
> On Sun, Nov 11, 2012 at 3:36 PM, Daniel Rosen <address@hidden> wrote:
>> Fantastic. I had a feeling that it would be a relatively simple function (it 
>> certainly appears to be), but I know absolutely nothing about Scheme. I'll 
>> have to read the Extending manual one of these days.
>>
>
> Yes--Scheme certainly opens up a lot of possibilities, and it's great
> fun if you like solving puzzles.

Hi David,

Big surprise: I _do_ like solving puzzles. :D

On topic:
Your function doesn't cover the case, where a rest is first in a tuplet.

Try it with:

\relative c'' {
  \times 2/3 { r8 c, c }
}

Here my approach, covering the rest-case and emitting a warning if
kneed beam is occurring:

\version "2.16.0"

\relative c' {
        \override TupletBracket #'after-line-breaking =
          #(lambda (grob)
            (let* ((tuplet-dir (ly:grob-property grob 'direction))
                   (note-columns (ly:grob-array->list (ly:grob-object
grob 'note-columns)))
                   (note-heads-array-list
                                (flatten-list
                                  (map
                                    (lambda (x)
                                      (ly:grob-object x 'note-heads))
                                        note-columns)))
                   (note-heads
                        (flatten-list
                          (map
                            (lambda (x)
                              (ly:grob-array->list x))
                                note-heads-array-list)))
                  (stems (map (lambda (x) (ly:grob-object x 'stem)) note-heads))
                  (stem-dirs (map (lambda (x) (ly:grob-property x
'direction)) stems))
                  (sorted-stems-dirs-list (sort-list stem-dirs (lambda
(a b) (< a b))))
                  (equal-stems-dir? (= (car sorted-stems-dirs-list)
(car (reverse sorted-stems-dirs-list)))))
        (if (and equal-stems-dir? (= (car sorted-stems-dirs-list) tuplet-dir))
          (ly:grob-set-property! grob 'direction (* -1 (car
sorted-stems-dirs-list)))
          (ly:warning "Kneed beam detected - if desired, adjust
TupletBracket manually."))))

        \times 2/3 { c'8 c c }
        \times 2/3 { r8 c c }
        \times 2/3 { r8 r c }
        \times 2/3 { c c'' r }
        \break
        \times 2/3 { c,,,8 c c }
        \times 2/3 { r8 c c }
        \times 2/3 { r8 r c }
        \times 2/3 { c c'' r }
}

Best,
  Harm



reply via email to

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