lilypond-user
[Top][All Lists]
Advanced

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

Re: centering different time signatures


From: David Nalesnik
Subject: Re: centering different time signatures
Date: Sat, 11 Apr 2015 18:56:55 -0500

Hi Kieren,

On Sat, Apr 11, 2015 at 4:03 PM, Kieren MacMillan <address@hidden> wrote:
Hi Pierre,

> I'm not sure you'll like it since it is no incantation but a workaround.

I appreciate the work… but I have multiple instances of this issue, with different combinations of time signatures, so this isn’t sufficient to save much manual work.
I’ll just use the \editionEngraver to throw an ‘extra-offset tweak on the smaller TimeSignature grob(s) — one day, maybe there’ll be an automated solution.



No promises, just something hacked together.  This only moves time signatures belonging to the same paper column as a criteron of vertical "relatedness."  Can't say if that's a valid assumption.

 \version "2.19.17"

#(define (callback grob)
   (let* ((my-col (ly:item-get-column grob))
          (elts (ly:grob-array->list (ly:grob-object my-col 'elements)))
          (ts (filter
               (lambda (x) (grob::has-interface x 'time-signature-interface))
               elts))
          (my-ext (ly:grob-property grob 'X-extent))
          (my-ext-len (interval-length my-ext))
          (total-ext 
           (map (lambda (t) (ly:grob-property t 'X-extent))
             ts))
          (total-ext (reduce interval-union '() total-ext))
          (available-space (interval-length total-ext))
          (offset (/ (- available-space my-ext-len) 2.0))
          (stil (ly:grob-property grob 'stencil)))
     
     (set! (ly:grob-property grob 'stencil)
           (ly:stencil-translate-axis stil offset X))))

\layout {
  \context {
    \Score
    \remove "Timing_translator"
    \remove "Default_bar_line_engraver"
  }
  \context {
    \Staff
    \consists "Timing_translator"
    \consists "Default_bar_line_engraver"
    \override TimeSignature.after-line-breaking = #callback
  }
}

shortTSmusic = {
  \time 4/4 g'4 g' g' g'
  \time 3/4 g'4 g' g' 
}

mediumTSmusic = {
  \time 12/8 g'4. g' g' g'
  \time 9/8 g'4. g' g'
}

longTSmusic = {
  \time 12345/4 g'4
}

\score {
  <<
    \new Staff \shortTSmusic
    \new Staff \mediumTSmusic
    \new Staff \longTSmusic
  >>
}


reply via email to

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