lilypond-user
[Top][All Lists]
Advanced

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

centering note columns [WAS: Directional NoteHead Stencil Support]


From: David Nalesnik
Subject: centering note columns [WAS: Directional NoteHead Stencil Support]
Date: Sun, 22 Mar 2015 15:13:49 -0500

Hi,

In a recent thread, the topic of centering items within their measures came up.  This post on "Scores of Beauty" ( http://lilypondblog.org/2013/06/horizontally-aligning-full-measure-rests/ )
shows an example where this nonstandard practice looks much better.  Normally, of course, a note filling a measure isn't centered, while a whole rest is.  When the two occur at the same time, it's more appealing when both are centered.

(See also the thread at http://www.mail-archive.com/lilypond-user%40gnu.org/msg98447.html for a usage case.)

The Scores of Beauty post comes with a code attachment which allows automation of the process.

It just occurred to me that this might be done through PaperColumns.  Moving a PaperColumn will carry everything associated with it--the NoteColumn, noteheads, dots, stem, articulations.  And _arpeggio_ (which presented a difficulty discussed in the thread this branched off from).

Here is a sketch of that approach.  It doesn't yet allow for the fine-grained control of the other code.

Note: measures aren't resized.  We simply use the available space.  However... one of the nice features of paper columns is that there is easy access to adjoining paper columns.  I wonder if it's possible to manipulate their X-extents to create a more flexible approach?

--David

%%%%%%

\version "2.19.17"

\paper {
  right-margin = 3\in
}

#(define center-column
   (lambda (grob)
     (if (grob::has-interface grob 'note-column-interface)
         (let* ((col (ly:item-get-column grob))
                (left-col (ly:grob-object col 'left-neighbor))
                (right-col (ly:grob-object col 'right-neighbor)))
           ;; we only shift a PaperColumn if it is alone in its
           ;; measure
           (if (and (ly:grob-property left-col 'non-musical)
                    (ly:grob-property right-col 'non-musical))
               (let* ((sys (ly:grob-system grob))
                      (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
         '()
         )))

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

\new PianoStaff <<
  \new Staff {
    <c' e' g' c''>1\accent\fermata\f\arpeggio
    c'4 d' e' f'
    R1
  }
  \new Staff {
    R1
    R1
    <c' e' g' c''>1\accent\fermata\f\arpeggio
  }
>>

\layout {
  ragged-right = ##f
  \context {
    \Voice
    \override NoteColumn.after-line-breaking = #center-column
  }
}

reply via email to

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