Hi Chen, 1. I was able to mostly solve this - you can now click on the time signatures (but it doesn't seem to work for all of them - I don't know why). 2. This should work now 3. This is done using callbacks (it's a hacky solution that brings back the time signature stencil for just that purpose since that is the only time we want it to occupy space throughout the score) 4. This might be doable in the engraver, but I'm not sure how (without making it hard to change), so I implemented it as a callback (that means combining callbacks if you both want to center over the barline and create extra space for the time signature at the end of a line - I have hopefully explained this in the comments so it's clear how to set it up the way you might want)
File is attached. Kevin On Mon, 20 Apr 2020 at 05:08, Leo Chen <leo04c...@outlook.com> wrote: > > Hi Kevin, > > Thank you so much for all the effort you've put into this! > I think this has already become useable but I still have a few suggestions: > > 1. Due to the nature of text scripts, they can't be clicked on and directed > to the code in Frescobaldi, this may make debugging the score a bit more > difficult, but it won't affect the outcome once the score is finished, so it > shouldn't be a big problem. > > 2. Compound time signatures are now automatically formatted into normal time > signatures (see attachment) I think this can be fixed relatively easily by > reformatting the markup. > > 3. It would be great if extra space can be arranged for the time signature > before the line break instead of aligning it to the left side of the last bar. > > 4. This is not a personal request, however, some people may prefer aligning > the time signature to the centre instead of the right side of the barline > like the example in the original snippet. > http://lsr.di.unimi.it/LSR/Snippet?id=272 I wonder how hard this can be > implemented into this custom engraver. > > Overall, I think this is a massive improvement from the last version and I > greatly appreciate your help. > > Best, > Leo
\version "2.19.0" #(define (Time_signature_markup_engraver context) (let ((time-sig '()) (time-sig-copy #f) (previous-was-grace #f)) ; to avoid printing twice at grace notes (make-engraver (acknowledgers ((time-signature-interface engraver grob source-engraver) (let* ((current-moment (ly:context-current-moment context)) (grace-nom (ly:moment-grace-numerator current-moment))) (if (not (eqv? 0 grace-nom)) (begin (set! previous-was-grace #t) (set! time-sig grob)) (if (and (eqv? 0 grace-nom) previous-was-grace) (begin (set! previous-was-grace #f) (set! time-sig '())) (set! time-sig grob)))))) ((process-acknowledged engraver) (and (not (null? time-sig)) (let* ((time-sig-copy (ly:engraver-make-grob engraver 'TextScript time-sig)) (copy-prop (lambda (prop) (ly:grob-set-property! time-sig-copy prop (ly:grob-property time-sig prop)))) (timing-context (ly:context-find context 'Timing)) (timing-time-sig (ly:context-grob-definition timing-context 'TimeSignature)) (timing-time-sig-stencil (ly:assoc-get 'stencil timing-time-sig '())) (prop-list '(fraction style font-size cause))) (map copy-prop prop-list) (ly:grob-set-property! time-sig-copy 'stencil timing-time-sig-stencil) (ly:grob-set-parent! time-sig-copy Y time-sig) (ly:grob-set-parent! time-sig-copy X time-sig) (set! time-sig '()) ))) ((stop-translation-timestep engraver) (set! time-sig-copy #f))))) #(define (remove-except-at-line-end grob) (if (not (equal? (ly:item-break-dir grob) LEFT)) (ly:grob-set-property! grob 'stencil #f))) #(define (remove-at-end grob) (if (equal? (ly:item-break-dir grob) LEFT) (ly:grob-set-property! grob 'stencil #f))) #(define (center-over-barline grob) (if (equal? (ly:item-break-dir grob) 0) (let* ((x-extent (ly:grob-property grob 'X-extent)) (width (interval-length x-extent))) (ly:grob-set-property! grob 'X-offset (* -1 (/ width 2)))))) #(define (center-over-barline-and-remove-at-end grob) (begin (remove-at-end grob) (center-over-barline grob))) #(define (left-align-at-end grob) (and (and (ly:item? grob) (equal? (ly:item-break-dir grob) LEFT)) (ly:grob-set-property! grob 'self-alignment-X 1))) timeSignatures = { \tempo 4 = 80 \time 4/4 s1 \time 3/8 s4. \time 3/4 s2. \time 4/4 s1 \time 2/4 s2 \compoundMeter #'((2 4) (1 16)) s1* 9/16 } \score { \layout { \context { \Score \override MetronomeMark.break-align-symbols = #'(clef time-signature) \remove "Bar_number_engraver" } \context { \Staff \override MultiMeasureRest.spacing-pair = #'(clef . staff-bar) \remove "Time_signature_engraver" } \context { \Score } } << \new Dynamics \with { \consists "Axis_group_engraver" \consists "Time_signature_engraver" % Remove time signatures everywhere except at the end of a line % because that's the only place we want them to create space \override TimeSignature.before-line-breaking = #remove-except-at-line-end \override TimeSignature.font-size = #8 \numericTimeSignature \consists \Time_signature_markup_engraver % Remove TextScript (our non-space-occupying time signatures) at % the end of lines and/or center them over bar lines. %\override TextScript.before-line-breaking = #remove-at-end %\override TextScript.before-line-breaking = #center-over-barline \override TextScript.before-line-breaking = #center-over-barline-and-remove-at-end \override TextScript.direction = #UP \override TextScript.Y-offset = #0 } { \timeSignatures } \new StaffGroup \with {} << \new Staff \with { \consists "Bar_number_engraver" } \relative c' { \textLengthOn \time 4/4 c4 ( _\markup \column { "← Objects failed to appear" "below the time signature" "when using \\textLengthOn" } \textLengthOff d4 e4 f4 ) \time 3/8 a'4 ( g8 ) \time 3/4 R2. \time 4/4 c1 \time 2/4 a8 ^\markup \column { "← Time signature appear twice" "when one staff has a grace note" "as the first note in a bar" } g8 f8 e8 \compoundMeter #'((2 4) (1 16)) a2 g16 } \new Staff \relative c' { \time 4/4 R1 \time 3/8 R4. \clef bass \time 3/4 a,2. \> \startTextSpan \break \time 4/4 c2 _\markup \column { " " "↑" "Harpin stops below the time signature" } ^\markup \column { "TextSpanner stops below the time signature" "↓" } e2 \! \stopTextSpan \clef treble \time 2/4 \acciaccatura f'8 a8 g8 f8 e8 \compoundMeter #'((2 4) (1 16)) a2 g16 } \new Staff \relative c' { \clef bass \time 4/4 R1 \time 3/8 R4. \time 3/4 R2. \time 4/4 c1 \time 2/4 a8 g8 f8 e8 \compoundMeter #'((2 4) (1 16)) a2 g16 } >> >> }