lilypond-user
[Top][All Lists]
Advanced

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

Re: centering different time signatures


From: Thomas Morley
Subject: Re: centering different time signatures
Date: Sun, 12 Apr 2015 23:08:48 +0200

2015-04-12 21:28 GMT+02:00 Kieren MacMillan <address@hidden>:
> Hi all,
>
>>> But forcing the grob to appear presupposes that there is a TimeSignature
>>> grob, and these are created in response to \time.  What you are suggesting
>>> would mean that each measure needs its own time signature object, which is
>>> not the case.
>
> Fair enough.
>
>> Can the edition engraver just insert a "\time X/X" where the time sig should 
>> appear?
>
> I tried that, and failed. Was going to email Jan-Peter, but am under a time 
> crunch. What seems to SORT OF work is
>
>     \set Staff.timeSignatureFraction = 2/2
>
> but that appears to set off a chain of unfortunate events worthy of Lemony 
> Snicket.
>
> Cheers,
> Kieren.


Well, you could do:

\version "2.19.17"

#(define (define-translator-property symbol type? description)
  (if (not (and (symbol? symbol)
    (procedure? type?)
    (string? description)))
      (ly:error "error in call of define-translator-property"))
  (if (not (equal? (object-property symbol 'translation-doc) #f))
      (ly:error (_ "symbol ~S redefined") symbol))

  (set-object-property! symbol 'translation-type? type?)
  (set-object-property! symbol 'translation-doc description)
  symbol)

#(for-each
  (lambda (x)
    (apply define-translator-property x))
    `((timeSigVisibility
       ,boolean?
       "what-ever-description")))

repeat-time-sig-key-engraver =
#(lambda (context)
 (let ((timeSignatureFraction '())
       (ev '()))
  `((listeners
      (time-signature-event
        .
        ,(lambda (engraver event)
           (set! ev event))))
    (acknowledgers
      (rhythmic-grob-interface
        . ,(lambda (engraver grob source-engraver)
             (if (eq? #t (ly:context-property context 'timeSigVisibility))
                  (ly:grob-set-property!
                    (ly:engraver-make-grob engraver 'TimeSignature ev)
                    'fraction
                    timeSignatureFraction)))))
    (process-music
        . ,(lambda (engraver)
             (set! timeSignatureFraction
                   (ly:context-property context 'timeSignatureFraction)))))))

\layout {
  \context {
    \Staff
    \consists #repeat-time-sig-key-engraver
  }
}

<<
\new Staff {
  \time 4/4
  c1
  \once \set Score.timeSigVisibility = ##t
  d1
  \time 8/8
  \break
  e1
  \once \set Score.timeSigVisibility = ##t
  \break
  f
}
\new Staff {
  c1
  d1
  e1
  f
}
>>


Though why?
\once \set Score.timeSigVisibility = ##t is even more typing than
inserting \time <whatever>
(And it's ofcourse untested apart from the demo-example)


Cheers,
  Harm



reply via email to

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