lilypond-devel
[Top][All Lists]
Advanced

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

Re: shape and chords


From: Jan-Peter Voigt
Subject: Re: shape and chords
Date: Mon, 25 Jun 2012 11:47:25 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120614 Thunderbird/13.0.1

Hi David,

this is a solution for unbroken TieColumns - great! This will be useful!

On 25.06.2012 00:42, David Nalesnik wrote:
Hi Jan-Peter,

On Wed, Jun 20, 2012 at 2:46 AM, Jan-Peter Voigt <address@hidden <mailto:address@hidden>> wrote:

    Hi David,

    ... moving this to devel ...
    I had a look into "tie-column.cc":
    In the scheme-callback "calc_positioning_done" all ties in a chord
    are assigned control-points in a loop. So it might be possible to
    define a scheme-callback "calc_control_point_column", that returns
    a list of a list of a list ... that returns all
    control-point-lists from the Tie_column. If it is not a column,
    say one tie, it might still return a list of this one tie.
    This is just a thought - it might have implications or whatever
    fiddling with those files ...
    My intention is: I would like to shape all ties in a chord.


At this point I unfortunately can't help with the C++ aspect of this. Some experimentation did show me that it is possible to manipulate 'control-points within a column of ties using Scheme, however.
This was the hint I was looking for in tie-column.cc. Interestingly the TieColumn, in contrast to the Tie, has to be overridden after the first note/chord.
The following function demonstrates roughly how this might be done. It doesn't make allowance for broken ties yet and requires an entry for each tie. You can use () to leave a tie as-is.

\version "2.15.40"

shapeTieColumn =
#(define-music-function (parser location offset-list) (list?)
  #{
    \once \override TieColumn #'after-line-breaking =
      #(lambda (grob)
        (let ((ties (ly:grob-array->list (ly:grob-object grob 'ties))))
          (for-each
            (lambda (tie off)
              (if (pair? off)
                  (set! (ly:grob-property tie 'control-points)
                        (map
                          (lambda (x y) (coord-translate x y))
                          (ly:tie::calc-control-points tie) off))))
             ties offset-list)))
  #})

{
  <d' e' g' a'> ~ q
  q ~
  \shapeTieColumn #'(
   ()
   ((0 . -0.25) (0.33 . -0.1) (0.67 . -0.1) (1 . -0.25))
   ((0 . 0.2) (0.33 . 0.4) (0.67 . 0.4) (1 . 0.2))
   ()
  )
  q
}

\layout {
  ragged-right = ##t
}

%%%%%%%%%%%%%%%%

Now I tried, like you probably also already did, to include the code from shape:
--snip--

\version "2.15.40"

shapeTieColumn =
#(define-music-function (parser location offset-list) (list?)
   ;; taken from the shape command
   (define (shape-curve grob offsets)
     (let* ((orig (ly:grob-original grob))
            (siblings (if (ly:spanner? grob)
                          (ly:spanner-broken-into orig) '()))
            (total-found (length siblings))
            (function (assoc-get 'control-points
                        (reverse (ly:grob-basic-properties grob))))
            (coords (function grob)))

       (define (offset-control-points offsets)
         (if (null? offsets)
             coords
             (map
              (lambda (x y) (coord-translate x y))
              coords offsets)))

       (define (helper sibs offs)
         (ly:input-message location "offsets = ~A" offs)
         (if (pair? offs)
             (if (eq? (car sibs) grob)
                 (offset-control-points (car offs))
                 (helper (cdr sibs) (cdr offs)))
             coords))

       ;; log
       (ly:input-message location "siblings = ~A" (length siblings))
       ;; we work with lists of lists
       (if (or (null? offsets)
               (not (list? (car offsets))))
           (set! offsets (list offsets)))

       (if (>= total-found 2)
           (helper siblings offsets)
           (offset-control-points (car offsets)))))

   #{
     \once \override TieColumn #'after-line-breaking =
     #(lambda (grob)
        (let ((ties (ly:grob-array->list (ly:grob-object grob 'ties))))
          (for-each
           (lambda (tie off)
             (if (pair? off)
                 (set! (ly:grob-property tie 'control-points)
                       (shape-curve tie off)
                       )))
           ties offset-list)))
   #})

{
  <d' e' g' a'>4 ~ q2
  q4 ~
  \shapeTieColumn #'(
                     ()
                     (((0 . -0.25) (0.33 . -0.1) (0.67 . 5) (1 . -0.25))
                      ((0 . -0.25) (0.33 . -0.1) (0.67 . 5) (1 . -0.25)))
                     ((0 . 0.2) (0.33 . 0.4) (0.67 . 0.4) (1 . 0.2))
                     ()
                     )
  \break
  q
}

\layout {
  ragged-right = ##t
}
--snip--


Now the broken siblings are found, but only the first one is shaped.
But it seems possible ... I will have another look after lunch ;-)

Cheers, Jan-Peter




reply via email to

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