Hi Victor,

On Fri, May 29, 2015 at 5:34 PM, Víctor <piratabonifa...@gmail.com> wrote:

> I've been using "center note column" function written by Thomas Morley,
> for some time now, and today I've spotted a bug. Notice the position of the
> dots in the last measure.
>
> I hope this can be fixed.
> Regards. Víctor.
>
>
I don't have a fix for the function you're using, but trying the alternate
routine here <
http://www.mail-archive.com/lilypond-user%40gnu.org/msg99927.html>
gets good results.  (See attached.)

Best,
David
\version "2.19.15"

#(define center-column
   (lambda (grob)
     (if (grob::has-interface grob 'note-column-interface)
         (let* ((col (ly:item-get-column grob))
                (sys (ly:grob-system col))
                (all-cols
                 (ly:grob-array->list
                  (ly:grob-object sys 'columns)))
                (measure-no
                 (car (ly:grob-property col 'rhythmic-location)))
                ; we need to find out if there is another
                ; PaperColumn in the measure.  If there is,
                ; we make no adjustments.
                (in-company?
                 ; is there a column...
                 (any
                  (lambda (c)
                    (and
                     ; which is NOT our column...
                     (not (eq? col c))
                     ; which is a PaperColumn...
                     (not (eq? #t (ly:grob-property c 'non-musical)))
                     ; which is in the same measure
                     (eq?
                      (car (ly:grob-property c 'rhythmic-location))
                      measure-no)))
                  all-cols))
                (alone? (not in-company?))) ; :)
           (if alone?
               (let* ((left-col (ly:grob-object col 'left-neighbor))
                      (right-col (ly:grob-object col 'right-neighbor))
                      ;(measure-len (ly:grob-property left-col 'measure-length))
                      (elts-list
                       (ly:grob-array->list (ly:grob-object col 'elements)))
                      (note-cols
                       (filter
                        (lambda (elt)
                          (grob::has-interface elt 'note-column-interface))
                        elts-list))
                      (all-rests
                       (map (lambda (c)
                              (ly:grob-object c 'rest))
                         note-cols))
                      (all-rests (filter ly:grob? all-rests))
                      (all-notes
                       (map
                        (lambda (c)
                          (ly:grob-object c 'note-heads))
                        note-cols))
                      (all 
                       (map (lambda (ga) 
                              (if (ly:grob-array? ga)
                                  (ly:grob-array->list ga)
                                  '()))
                         all-notes))
                      (all (flatten-list all))
                      (all (append all all-rests))
                      (same-dur?
                       (every (lambda (o) 
                                (equal?
                                 (ly:grob-property o 'duration-log)
                                 (ly:grob-property (car all)
                                   'duration-log)))
                         all)))
                 (if same-dur?
                     (let* ((col-center (interval-center
                                         (ly:grob-extent col sys X)))
                            (left-right-X
                             (cdr (ly:grob-extent left-col sys X)))
                            (right-left-X
                             (car (ly:grob-extent right-col sys X)))
                            (middle-X
                             (- (average left-right-X right-left-X)
                               col-center)))
                       (ly:grob-translate-axis! col middle-X X))))))
         ;; do nothing if override applied to something other
         ;; than NoteColumn
         '()
         )))


global = {
  \key a \major
  \time 4/4
  \partial 4
}

pianoDerI = \relative c'' {
  \global
  \voiceOne
  a4						|
  a e' e( d8[ cis]				|
  b4) cis d8[ cis] b4				|
  a2\fermata r4 a				|
  b cis d b					|
  
  e fis e\fermata cis				|
  cis8[ d] e4 d cis8[( b])			|
  a[( b] cis4) b\fermata cis			|
  a b8[ cis] d4\fermata cis			|
  
  b cis d\fermata cis				|
  b a e'4.( d8					|
  cis4) d8[ cis] b2				|
  %\centerNoteColumnOn 
  a2.\fermata \bar "|."
}

pianoDerII = \relative c' {
  \global
  \voiceTwo
  fis4						|
  e8( fis gis a b4) e,				|
  dis e d8 a' gis4				|
  e2 r4 fis					|
  fis e8( cis) gis'( fis) e( dis)		|
  
  e[ fis16 gis a8] fis gis4 a			|
  a ais b8 a gis fis				|
  e[( fis16 gis a8 fis]) gis4 a8[ gis]		|
  fis4. gis16 ais b4 ais!			|
  
  b8 a g4 fis e8 a~(				|
  a gis4) fis8 gis a b4~			|
  b8 e, a4 a( gis)				|
  e2.
}

pianoIzqI = \relative c' {
  \global
  \voiceOne
  cis8 d					|
  e4 d8 cis b4( a				|
  b) a8 g a4 e'8 d				|
  cis2 r4 a					|
  a gis b8( a) b4				|
  
  b8( e4) dis8 e4 e				|
  fis fis fis e					|
  e8( d cis dis) e4 e				|
  d8( cis) d( e) fis4 fis8 e			|
  
  d4 e a, a					|
  b cis8 dis e2~				|
  e8 cis a cis fis d b e			|
  %\centerNoteColumnOn 
  cis2.
}

pianoIzqII = \relative c {
  \global
  \voiceTwo
  fis4						|
  cis' b8 a gis4 a~				|
  a8 g fis e fis d e4				|
  a,2\fermata r4 d				|
  dis8 e4 eis fis8 gis a			|
  
  gis e b'4 e,\fermata a8 gis			|
  fis e d cis b4 e8 d				|
  cis( b a4) e'\fermata a,			|
  d8 e d cis b4\fermata fis'			|
  
  g8 fis e4 d\fermata a			|
  e'2~ e8 fis gis e				|
  a gis fis e d( b e4)				|
  a,2.\fermata
}

\score {
  <<
    \new PianoStaff \with { instrumentName = "Piano" } <<
      \new Staff = "right" <<
        \new Voice \pianoDerI
        \new Voice \pianoDerII
      >>
      \new Staff = "left" <<
        \clef bass 
        \new Voice \pianoIzqI
        \new Voice \pianoIzqII
      >>
    >>
  >>
  \layout {
    \context {
      \Voice
      \override NoteColumn.after-line-breaking = #center-column
    }
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to