lilypond-user
[Top][All Lists]
Advanced

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

Re: Tweaking end-of-line time signature?


From: Trevor Bača
Subject: Re: Tweaking end-of-line time signature?
Date: Tue, 26 May 2009 17:03:50 -0500

Hi David, hi all,

OK, the results included here make a nice supplement to using proportional notation. To better provide the context that brings these results about, I think it might be best to take a step back and present three successive ways of using proportional notation, culminating in the new, third way that makes use of a substitution function built around the after-line-breaking callback.

#1. The usual way of using proportional notation includes passing a rational-valued number to proportionalNotationDuration in the Score context, and turning on uniform-stretching, strict-note-spacing and strict-grace-spacing on the SpacingSpanner. This works great but -- crucially -- assumes the absence of middle-of-line and end-of-line time signatures. In cramped quarters, this will start to look hectic immediately before each time signature because each time signature is effectively sitting on the rhythmic space of the last few notes in each measure:

%%% BEGIN #1 PROPORTIONAL WITH STRICT-NOTE-SPACING %%%%

\layout { ragged-right = ##t }

\new Staff {
   \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
   \override Score.SpacingSpanner #'uniform-stretching = ##t
   \override Score.SpacingSpanner #'strict-note-spacing = ##t
   \override Score.SpacingSpanner #'strict-grace-spacing = ##t

   \time 1/4
   c'16 c'16 c'16 c'16

   \time 1/4
   c'16 c'16 c'16 c'16

   \break

   \time 1/4
   c'16 c'16 c'16 c'16
}

%%% END #1 %%%

See 1-proportional-notation-with-strict-note-spacing.png for the visual results. And note that time signatures and barlines are stepping on the rhythmic space of the last notes in each measure.


The solution to this is to turn off strict-note-spacing while keeping the other settings in tact, as shown below in #2.

%%% BEGIN #2 PROPORTIONAL NOTATION *WITHOUT* STRICT NOTE SPACING %%%

\layout { ragged-right = ##t }

\new Staff {
   \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
   \override Score.SpacingSpanner #'uniform-stretching = ##t
   %% \override Score.SpacingSpanner #'strict-note-spacing = ##t %% OFF!
   \override Score.SpacingSpanner #'strict-grace-spacing = ##t

   \time 1/4
   c'16 c'16 c'16 c'16

   \time 1/4
   c'16 c'16 c'16 c'16

   \break

   \time 1/4
   c'16 c'16 c'16 c'16
}

%%% END #2 %%

The visual results attach as 2-proportional-notation-WITHOUT-strict-note-spacing.png. This has the effect of fixing the time signature and barline in the *middle* of the first system. But the time signature and barline at the *end* of the first system are somehow no affected by turning off strict-note-spacing.

This had always bothered me and was the source of my original question that started this thread about moving around the time signatures (and barlines) that come at the end of a system.

Well, enter the idea of a substitution function built around after-line-breaking. With such as we've developed here, it's possible to get a completely consistent look, as in example 3, below.

%%% BEGIN #3 PROPORTIONAL SPACING WITHOUT STRICT NOTE SPACING AND WITH  EOL ADJUSTMENT %%%

adjustEOLMeterBarlineExtraOffset = #(define-music-function (parser location) ()
   #{
      #(define (foo grob)
         (if (<= (ly:item-break-dir grob) 0)
            (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
      #(define (bar grob)
         (if (<= (ly:item-break-dir grob) 0)
            (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
      \once \override Score.TimeSignature #'after-line-breaking = #foo
      \once \override Staff.BarLine #'after-line-breaking = #bar
   #})

\layout { ragged-right = ##t }

\new Staff {
   \set Score.proportionalNotationDuration = #(ly:make-moment 1 32)
   \override Score.SpacingSpanner #'uniform-stretching = ##t
   %% \override Score.SpacingSpanner #'strict-note-spacing = ##t %% OFF!
   \override Score.SpacingSpanner #'strict-grace-spacing = ##t

   \time 1/4
   c'16 c'16 c'16 c'16

   \time 1/4
   c'16 c'16 c'16 c'16
  
   \adjustEOLMeterBarlineExtraOffset
   \break

   \time 1/4
   c'16 c'16 c'16 c'16
}

%%% END %%%

The visual results attach as 3-proportional-notation-without-strict-note-spacing-and-with-adjustment.png.

Perfect!

Of course, the adjustment function implemented here has two inelegancies:

A. it uses extra-offset
B. it hardcodes a horizontal offset of 2.8 magic units, rather than using something semantic to say "align the barline at the dead end of the compass of the staff".

But it does visually work. Which is amazing.

So ...

A. Does anyone have a way of implementing adjustEOLMeterBarlineExtraOffset without recourse to extra-offset?

and

B. Does anyone have a semantic way of saying "align the last barline at the dead end of the compass of the staff ... with the time signature trailing afterwards in the whitespace beyond the staff"?


Trevor.





On Tue, May 26, 2009 at 4:34 PM, Trevor Bača <address@hidden> wrote:
Hi David,

Fake at Scheme? Well, you certainly pointed me the right direction!

:)

Of course Joe's response to the thread was exactly what we were looking for:

%%% BEGIN %%%


meterNudgeAndColor = #(define-music-function (parser location) ()
   #{
      #(define (meterBrk grob)
         (if
            (<= (ly:item-break-dir grob) 0)
            (begin

               (ly:grob-set-property! grob 'color red)
               (ly:grob-set-property! grob 'extra-offset (cons 3 0))
            )
            '()
         )

      )
            \once \override Score.TimeSignature #'after-line-breaking = #meterBrk
   #})

%%% END %%%


Which runs against this input ...


\new Staff {
   \time 4/4
   c'1
   \meterNudgeAndColor

   \break
   \time 7/8
   c'2..
}

... to produce the output attached here as nudge-and-color-meter.png. Excellent.


And, in fact, we now have a template for a function that:

  * takes no input arguments
  * modifies multiple grobs ...
  * ... each with multiple properties.

Viz:

%%% BEGIN MODIFY MULTIPLE ATTRS ON MULTIPLE GROBS %%%

meterAndBarlineNudgeAndColor = #(define-music-function (parser location) ()
   #{
      #(define (meterBrk grob)

         (if (<= (ly:item-break-dir grob) 0)
            (begin

               (ly:grob-set-property! grob 'extra-offset (cons 3 0))
               (ly:grob-set-property! grob 'color red))
             '() ))
      #(define (barlineBrk grob)        
          (if (<= (ly:item-break-dir grob) 0)
            (begin

               (ly:grob-set-property! grob 'extra-offset (cons 3 0))
               (ly:grob-set-property! grob 'color red))

             '() ))
            \once \override Score.TimeSignature #'after-line-breaking = #meterBrk
            \once \override Staff.BarLine #'after-line-breaking = #barlineBrk
   #})

%%% END %%%


When substituted on the input chunk given above, output is produced as shown in meter-and-barline-nudge-and-color.png, attached.


And you were also reading my mind in your comment here:

David> And now for the disturbing question: since the function uses "extra-offset"

which happens after everything else is placed, do you really regain that
real estate (do the other elements spread out to fill the line), or is it
just empty space? Perhaps you need "X-offset" in this instance. Sorry I
didn't think of that earlier.

In fact this had already become a concern this morning when I was mucking around looking for how to evaluate multiple statements in sequence (ie, looking for Scheme begin'). And what's particularly disturbing is that a substitution function of precisely the same structure that we've been messing with seems to do absolutely nothing when built around X-offset.

That is, the following function ...

%%% BEGIN %%%

adjustEOLMeterXOffset = #(define-music-function (parser location) ()
   #{
      #(define (meterBrk grob)

         (if (<= (ly:item-break-dir grob) 0)
            (ly:grob-set-property! grob 'X-offset 8) '() ))

            \once \override Score.TimeSignature #'after-line-breaking = #meterBrk
   #})

%%% END %%%

... seems to do absolutely nothing when run, for example, on this piece of input ...


\new Staff {
   \time 4/4
   c'1
   \adjustEOLMeterXOffset

   \break
   \time 7/8
   c'2..
}

... which is too bad.

So why is this?

I'm gonna go way out on a limb here and guess that the X-offset value of TimeSignature *is*, in fact, actually adjusted at the point in the formatting process at which after-line-breaking is called. . But I would guess the point in the formatting process at which after-line-breaking is called occurs BEFORE some other series of steps in the formatting process which basically have the effect of undoing the X-offset adjustment effected during the after-line-breaking callback.

(Note that I'm making this stuff up whole cloth. I haven't looked at a line of code; I'm just guessing. But the fact that the function both defines and applies without complaint from Lily makes me think the guess may not be too far off.)

OK, so I'm going to go whittle down a minimal example of this sort of EOL time signature shifting with proportional notation turned on to find out with certainty whether the terminal parts of the measure are in fact be freed up with extra-offset or not. (My guess, like yours, is that the space is not, in fact, being freed up.)

Will post the results presently.

Trevor.


















On Tue, May 26, 2009 at 11:42 AM, madMuze <address@hidden> wrote:

glad that helped, Trevor!

I totally agree with your concept of enclosing two commands in (...) as a
combined TRUE, but it doesn't work for me, either. Being an entire fake at
scheme and having no pride, I've resorted to repeating the entire IF
construct:
                       (if (<= (ly:item-break-dir grob) 0)
                               (ly:grob-set-property! grob 'extra-offset
(cons 3 0)) '() )
                       (if (<= (ly:item-break-dir grob) 0)
                               (ly:grob-set-property! grob 'color red) '()
)

Of course, since you're controlling two grobs, that means a total of four
IFs, and surely someone knows a better solution. If not, we remain grateful
for copy and paste.

And now for the disturbing question: since the function uses "extra-offset"
which happens after everything else is placed, do you really regain that
real estate (do the other elements spread out to fill the line), or is it
just empty space? Perhaps you need "X-offset" in this instance. Sorry I
didn't think of that earlier.

David



But now I've run into a challenge that I haven't been able to solve. How can
I set *two* properties on one grob in a single function?
--
View this message in context: http://www.nabble.com/Tweaking-end-of-line-time-signature--tp23712497p23726892.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.



_______________________________________________
lilypond-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/lilypond-user



--
Trevor Bača
address@hidden



--
Trevor Bača
address@hidden

Attachment: 1-proportional-with-strict-note-spacing.png
Description: PNG image

Attachment: 2-proportional-WITHOUT-strict-note-spacing.png
Description: PNG image

Attachment: 3-proportional-without-strict-note-spacing-and-WITH-eol-adjustment.png
Description: PNG image


reply via email to

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