Hi Leo,

Since bar lines, like time signatures, are synchronised across all staves,
space is allocated in all staves for them. The space they take up will push
other things (hairpins and such) around. My previous attempt (before the
last one) avoided this by printing markup above the spacer rests instead of
hooking onto the bar line. I don't know how to solve your problem: have
something synchronised across all staves that won't occupy any space. I
suspect one could write a custom engraver to do it, but that is beyond my
capabilities.
Kevin

On Sun, 12 Apr 2020 at 15:48, Leo Chen <leo04c...@outlook.com> wrote:

> Hi Kevin,
>
>
> Thank you again for your help, however, your code is still not solving the
> alignment problems with the hairpin and markup text. It has a similar
> result with the version that uses
> \override TimeSignature.break-align-symbol = #'staff-bar
> and
> \override MultiMeasureRest.spacing-pair = #'(clef . staff-bar)
>
>
> And this is what I meant by compound meter:
>
> \relative {
>   \compoundMeter #'((2 4) (1 16))
>   a2 g16
> }
>
> Best,
> Leo
>
>
>
> ------------------------------
>
> Hi Chen,
>
> I was able to solve the first two problems by adding bar lines to the
> dynamics context and replacing their stencils with a printed time
> signature. Without an example of what you mean by compound meters I'm not
> sure what is wrong, but if you were referring to the ability to supply a
> beat structure when you use \time, then I added that back in. The code is
> below.
>
> \version "2.19.0"
>
> ttime =
> #(define-music-function (beat-structure fraction)
>    ((number-list? '()) fraction?)
>    (define-markup-command (time-sig layout props numer denom)
>      (markup? markup?)
>      (interpret-markup layout props
>        #{
>          \markup
>          \override #'(baseline-skip . 1.5) \center-column {
>            \number #numer \number #denom
>          }#}))
>    (let* ((numer (number->string (car fraction)))
>           (denom (number->string (cdr fraction))))
>      #{
>        \time #fraction
>        \once \override BarLine.stencil =
>        #(lambda (grob) (grob-interpret-markup grob
>                          #{ \markup { \time-sig #numer #denom } #}))
>      #}))
>
> timeSignatures = {
>   \tempo 4 = 80
>   \bar ""
>   \ttime 4/4 s1
>
>   \ttime 3/8 s4.
>   \ttime 3/4 s2.
>   \ttime 4/4 s1
>   \ttime 2/4 \grace s8 s4.
> }
>
> \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 "Bar_engraver"
>       \override BarLine.break-visibility = #'#(#t #t #t)
>       \override BarLine.font-size = #8
>     }
>     {
>       \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
>       }
>
>       \new Staff \relative c' {
>         \time 4/4
>         R1
>         \time 3/8
>         R4.
>         \clef bass
>         \time 3/4
>         a,2. \> \break
>         \time 4/4
>         c2 _\markup \column {
>           "  "
>           "↑"
>           "Hairpin stops below the time signature"
>         }
>         e2 \!
>         \clef treble
>         \time 2/4
>         \acciaccatura f'8 a8
>         g8 f8 e8
>       }
>
>       \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
>       }
>     >>
>   >>
> }
>
> Hope that helps,
> Kevin
>
> On Sun, 12 Apr 2020 at 12:12, Leo Chen <leo04c...@outlook.com> wrote:
>
> Hi Kevin,
>
> I really appreciate your help.
>
> I may be asking a bit too much here, however, I still have a few problems
> with this helper function.
> Firstly, the time signatures are aligned to the first note in a bar. Are
> there any ways it can be aligned to the bar line?
> Secondly, the time signature doesn't show up at the end of the line
> whenever a new time signature is drawn after the line break.
> Thirdly, this helper function isn't supporting compound meters which I
> happened to be using a lot in my composition.
>
> Leo
> ------------------------------
> *发件人:* Kevin Barry <barr...@gmail.com>
> *发送时间:* 2020年4月12日 18:13
> *收件人:* Chen Leo <leo04c...@outlook.com>
> *抄送:* lilypond-user@gnu.org <lilypond-user@gnu.org>
> *主题:* Re: Alignment issues of Time signature above the staff
>
> Hi Chen,
>
> Space alloted for time signatures in one staff cause space to be allotted
> in all other staves as well (even if they aren't printing it), which is
> causing lots of problems that have to be worked around.
>
> Perhaps a different approach would be easier. In the code below there is a
> helper function (\ttime) to print the time signature as a markup (with the
> time signature engraver removed everywhere). It seems to make things easier.
>
> \version "2.19.0"
>
> ttime =
> #(define-music-function (fraction music)
>    (fraction? ly:music?)
>    (let* ((numer (number->string (car fraction)))
>           (denom (number->string (cdr fraction))))
>      #{ \time #fraction
>         #music ^\markup
>         \override #'(baseline-skip . 1.5)
>         \center-column { \number #numer \number #denom } #}))
>
> timeSignatures = { \tempo 4 = 80 \ttime 4/4 s1 \ttime 3/8 s4.
>                    \ttime 3/4 s2. \ttime 4/4 s1 \once \override
> TextScript.X-offset = #-6
>                    \ttime 2/4 s4.}
>
> \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 {
>       \override TextScript.font-size = #8
>       \override TextScript.X-offset = #-2
>     }
>     {
>       \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
>       }
>
>       \new Staff \relative c' {
>         \time 4/4
>         R1
>         \time 3/8
>         R4.
>         \clef bass
>         \time 3/4
>         a,2. \> \break
>         \time 4/4
>         c2 _\markup \column {
>           "  "
>           "↑"
>           "Hairpin stops below the time signature"
>         }
>         e2 \!
>         \clef treble
>         \time 2/4
>         \acciaccatura f'8 a8
>         g8 f8 e8
>       }
>
>       \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
>       }
>     >>
>   >>
> }
>
> Hope that helps!
> Kevin
>
>
> On Sat, 11 Apr 2020 at 16:04, Chen Leo <leo04c...@outlook.com> wrote:
>
> Hi,
>
> I was able to align the metronome mark above the time signature by using a
> small hack
>
> That is to use
> \override TimeSignature.stencil = #(lambda (grob) (grob-interpret-markup
> grob (markup "")))
> instead of removing the “time_signature_engraver” from the staff context.
>
> I also discovered another problem that is the time signature will display
> twice when one staff has a grace note as the first note in a bar. I was
> only able to solve this by commenting out the \time commands from the rest
> of the staffs, which is not an ideal solution. After looking into some of
> the internal commands I still don’t have a clue on how to solve the rest of
> the alignment problems, I guess some deeper scheme knowledge is required to
> make this work.
>
> See the attached files.
>
> ------------------------------
> Hi,
> Thank you for your responses.
> I managed to solve the bar number problem by removing the
> "Bar_number_engraver" from the staff context and \consists
> "Bar_number_engraver" in the staff under the time signature.
> For the time signature’s alignment, I found a simpler solution by using
> \override TimeSignature.break-align-symbol = #'staff-bar with \override
> MultiMeasureRest.spacing-pair = #'(clef . staff-bar). However, It still
> causes break-alignment issues from here to there.
>
> Example:
>
> \version "2.19.0"
>
> timeSignatures = { \numericTimeSignature \tempo 4 = 80 \time 4/4 s1 \time
> 3/8 s4.
> \time 3/4 s2. \time 4/4 s1 }
>
> \score {
>   \layout {
>   \context {
>     \type "Engraver_group"
>     \consists "Time_signature_engraver"
>     \consists "Axis_group_engraver"
>     \name "TimeSig"
>     \alias "Staff"
>       \override TimeSignature.font-size = #8
>       \override TimeSignature.break-align-symbol = #'staff-bar
>       \override TimeSignature.X-offset =
>       #ly:self-alignment-interface::x-aligned-on-self
>       \override TimeSignature.self-alignment-X = #LEFT
>       %\override TimeSignature.X-extent = #'(0 . 0)
>   }
>   \context {
>     \Score
>     \accepts TimeSig
>     \remove "Bar_number_engraver"
>   }
>   \context {
>     \Staff
>     \override MultiMeasureRest.spacing-pair = #'(clef . staff-bar)
>     \remove "Time_signature_engraver"
>   }
>   \context {
>     \Score
>   }
> }
>   <<
>     \new TimeSig \with {
>     }
>     {
>       \timeSignatures
>     }
>
>     \new StaffGroup \with {} <<
>     \new Staff \with {
>     \consists "Bar_number_engraver"
>     }
>     \relative c' {
>     \textLengthOn
>     c4 ( _\markup \column {
>     "← Objects failed to appear"
>     "below the time signature"
>     "when using \\textLengthOn"
>     }
>     \textLengthOff
>     d4 e4 f4 )
>     a''4 ( g8 ) R2. c1 }
>     \new Staff \relative c' {
>     R1
>     R4.
>     \clef bass
>     a2. \> \break
>     c2 _\markup \column {
>     "  "
>     "↑"
>     "Hairpin stops below the time signature"
>     }  c2\! }
>     \new Staff \relative c' { R1 R4. R2. c1 }
>     >>
>   >>
> }
>
> ------------------------------
>
> On 3/29/2020 2:10 AM, Chen Leo wrote:
>
> Hi Kevin,
>
>
> Thank you for your reply.
>
>
> For the first problem, you will have to set break-align-symbol to ##f to
> reproduce the problem. That is because by default break-align-symbol is
> set to #'time-signature. so commenting out the override shouldn't help.
>
>
> Secondly, using \override TimeSignature.X-extent = #'(0 . 0) causes
> collisions when texts and notes are displayed above the staff because
> lilypond is not adding vertical spacing above the staff. And it seems like
> now all the time signatures are shifted a bit to the right instead of
> aligning right after the bar line.
>
>
> Thirdly, the bar numbers are raised to align vertically with the
> time-signatures, which is not something I would like to have. It will be
> nice if you can share any ideas on how that can be solved.
>
>
> Leo
>
> Here's an example:
>
> \version "2.20.0"
>
> \layout {
>   \context {
>     \type "Engraver_group"
>     \consists "Time_signature_engraver"
>     \consists "Axis_group_engraver"
>     \name "TimeSig"
>     \alias "Staff"
>     % original settings from "http://lsr.di.unimi.it/LSR/Snippet?id=272";
> <http://lsr.di.unimi.it/LSR/Snippet?id=272>
>     %{
>       \override TimeSignature.font-size = #3
>       \override TimeSignature.break-align-symbol = ##f
>       \override TimeSignature.X-offset =
>         #ly:self-alignment-interface::x-aligned-on-self
>       \override TimeSignature.self-alignment-X = #CENTER
>       \override TimeSignature.after-line-breaking =
>       #shift-right-at-line-begin
>     %}
>     % settings after adjustments
>     {
>     \override TimeSignature.font-size = #4
>     \override TimeSignature.X-offset =
>       #ly:self-alignment-interface::x-aligned-on-self
>     \override TimeSignature.self-alignment-X = #LEFT
>     \override TimeSignature.X-extent = #'(0 . 0)
>     }
>   }
>   \context {
>     \Score
>     \accepts TimeSig
>   }
>   \context {
>     \Staff
>     \remove "Time_signature_engraver"
>   }
> }
>
> timeSignatures = { \numericTimeSignature \time 4/4 s1 \time 3/8 s4. \time
> 3/4 s2. \break \time 4/4 s1 }
>
> \score {
>   <<
>     \new TimeSig \timeSignatures
>     \new Staff \relative c' { c4 ^\markup \column {"a" "b" "c"} ( d4 e4 f4
> ) a''4
>                               ^\markup \column {"a" "b" "c"} ( g8 ) R2. c1
> }
>     \new Staff \relative c' { R1 R4. \clef bass a2. c1 }
>     \new Staff \relative c' { R1 R4. R2. c1 }
>   >>
> }
>
>
> ------------------------------
>
> Hi Chen,
>
> I was able to solve the second of your problems (the whole bar rests
> being shifted by the time signatures in the TimeSig context) by
> adding:
> \override TimeSignature.X-extent = ##f
> (You could also use the value #'(0 . 0) if the warnings are off
> putting, but I noticed that that doesn't *quite* fix it fully.)
>
> I tried to reproduce your description of the first problem (time
> signatures aligning over cue clefs), but even commenting out the
> break-align-symbol override didn't make it appear. I was able to
> correct the alignment of the first time signature by removing the
> line:
> \override TimeSignature.after-line-breaking = #shift-right-at-line-begin
>
> After both of the above modifications everything looks OK to me, but
> perhaps we need a fuller example.
>
> Kevin
>
> On Sat, 28 Mar 2020 at 10:30, Chen Leo <leo04c...@outlook.com>
> <leo04c...@outlook.com> wrote:
> >
> > Hi, I am trying to put time signatures above the staffs according to "
> http://lsr.dsi.unimi.it/LSR/Item?id=272";.
> >
> >
> >
> > I discovered an issue, that is whenever a clef change is made, the time
> signature on the next bar fails to align to the bar line, it aligns to the
> cue clef in the previous bar instead. After some research, I found out that
> this is because the TimeSignature property "break-align-symbol" is set to
> "##f". I set "break-align-symbol" back to "#'time-signature", and this
> problem is solved, however, the horizontal alignments of the other time
> signatures are messed up. (Using the code presented below, the 4/4 in the
> first bar moves to the right & the bar rest on the third bar stretches to
> the right. ) Are there any ways to align all the time signatures to their
> corresponding bar lines without changing the alignments of other objects?
> Thank you.
> >
> >
> >
> > \version "2.20.0"
> >
> >
> >
> > \layout {
> >
> >   \context {
> >
> >     \type "Engraver_group"
> >
> >     \consists "Time_signature_engraver"
> >
> >     \consists "Axis_group_engraver"
> >
> >     \name "TimeSig"
> >
> >     \alias "Staff"
> >
> >     \override TimeSignature.font-size = #4
> >
> >     \override TimeSignature.break-align-symbol = #'time-signature
> >
> >     \override TimeSignature.X-offset =
> >
> >       #ly:self-alignment-interface::x-aligned-on-self
> >
> >     \override TimeSignature.self-alignment-X = #LEFT
> >
> >     \override TimeSignature.after-line-breaking =
> >
> >       #shift-right-at-line-begin
> >
> >   }
> >
> >   \context {
> >
> >     \Score
> >
> >     \accepts TimeSig
> >
> >   }
> >
> >   \context {
> >
> >     \Staff
> >
> >     \remove "Time_signature_engraver"
> >
> >   }
> >
> > }
> >
> >
> >
> > timeSignatures = { \numericTimeSignature \time 4/4 s1 \time 3/8 s4.
> \time 3/4 s2. }
> >
> >
> >
> > \score {
> >
> >   <<
> >
> >     \new TimeSig \timeSignatures
> >
> >     \new Staff \relative c' { c4 ( d4 e4 f4 ) a4 ( g8 ) R2. }
> >
> >     \new Staff \relative c' { R1 R4. \clef bass a2. }
> >
> >     \new Staff \relative c' { R1 R4. R2. }
> >
> >   >>
> >
> > }
> >
> >
>
> Hi Chen,
>
>
> The measure numbers should be aligned correctly throughout your score,
> except in the certain cases where there happens to be a time signature
> change at the end of the system and/or at the start of a new line.
>
>
> In which case you could simply use an override like this: \once \override
> Score.BarNumber.Y-offset = #-6.
>
>
> Would this help?
>
>
> (see attached)
>
>
> %%%%%%%%%%%
>
>
> \version "2.19.0"
>
> \layout {
>   \context {
>     \type "Engraver_group"
>     \consists "Time_signature_engraver"
>     \consists "Axis_group_engraver"
>     \consists "Staff_symbol_engraver"
>     \name "TimeSig"
>     \alias "Staff"
>     % original settings from "http://lsr.di.unimi.it/LSR/Snippet?id=272";
> <http://lsr.di.unimi.it/LSR/Snippet?id=272>
>     %{
>       \override TimeSignature.font-size = #3
>       \override TimeSignature.break-align-symbol = ##f
>       \override TimeSignature.X-offset =
>         #ly:self-alignment-interface::x-aligned-on-self
>       \override TimeSignature.self-alignment-X = #CENTER
>       \override TimeSignature.after-line-breaking =
>       #shift-right-at-line-begin
>     %}
>     % settings after adjustments
>     {
>       \override TimeSignature.font-size = #4
>       \override TimeSignature.X-offset =
>       #ly:self-alignment-interface::x-aligned-on-self
>       \override TimeSignature.self-alignment-X = #LEFT
>       \override TimeSignature.X-extent = #'(0 . 0)
>     }
>   }
>   \context {
>     \Score
>     \accepts TimeSig
>   }
>   \context {
>     \Staff
>     \remove "Time_signature_engraver"
>   }
>   \context {
>     \Score
>     \remove "System_start_delimiter_engraver"
>   }
> }
>
> timeSignatures = {
>   \numericTimeSignature \time 4/4 s1 \time 3/8 s4.
>   \time 3/4 s2. \break \time 4/4 s1
> }
>
> \score {
>   <<
>     \new TimeSig \with {
>       \override VerticalAxisGroup.default-staff-staff-spacing.padding = #2
>       \override StaffSymbol.transparent = ##t
>     } {
>       \timeSignatures
>     }
>     \new StaffGroup \with {
>       \consists "System_start_delimiter_engraver"
>       systemStartDelimiter = #'SystemStartBar
>     } <<
>       \new Staff \relative c' {
>         c4 ^\markup \column {"a" "b" "c"} ( d4
>         e4 f4 ) a''4
>         ^\markup \column {"a" "b" "c"} ( g8 ) R2.
>         \once \override Score.BarNumber.Y-offset = #-6
>         c,1 c c c c c \break c c
>       }
>       \new Staff \relative c' {
>         R1
>         R4.
>         \clef bass
>         a2.
>         c1
>       }
>       \new Staff \relative c' { R1 R4. R2. c1 }
>     >>
>   >>
> }
>
>

Reply via email to