Big time signatures: Difference between revisions

Lazy (talk | contribs)
Break long lines, add support for height limits and different width.
m Lemzwerg moved page Big Time Signatures to Big time signatures without leaving a redirect: Only the first letter of a title should be uppercase
 
(2 intermediate revisions by one other user not shown)
Line 3: Line 3:
# creating a new <code>BigTimeSignature</code> spanner grob that spans multiple time signatures and prints an enlarged signature over their extent, and
# creating a new <code>BigTimeSignature</code> spanner grob that spans multiple time signatures and prints an enlarged signature over their extent, and
# creating an engraver that collects all time signatures, replacing them with a <code>BigTimeSignature</code> spanner on them.
# creating an engraver that collects all time signatures, replacing them with a <code>BigTimeSignature</code> spanner on them.
It is possible to limit height of the <code>BigTimeSignature</code> by overriding <code>BigTimeSignature.height-limit</code>. Since this implementation reuses the individual time signature stencils it is possible to modify the width thus. Scaling the width of the spanner will not affect spacing — but the calculate the actual scaling factor requires knowing the system-spacing. Thus this include a method which estimates the scaling factor for setting the width of the time signatures to a suitable value.
It is possible to limit height of the <code>BigTimeSignature</code> by overriding <code>BigTimeSignature.height-limit</code>. Similarly use <code>BigTimeSignature.details.min-height</code> to limit how small this can get. Since this implementation reuses the individual time signature stencils it is possible to modify the width thus. Scaling the width of the spanner will not affect spacing — but the calculate the actual scaling factor requires knowing the system-spacing. Thus this include a method which estimates the scaling factor for setting the width of the time signatures to a suitable value.


Scaling time signatures isotropic will lead to very strong time signatures. To get a narrower look this proposes the following mechanic: <code>BigTimeSignature.details.width-adjustment</code> may be set to a factor. If the height is increased by some percentage width will be increased by only this part of that percentage. E.g. if that value is set to 0.5 then if height is increased by 100% width will be increased by only 50%.
Scaling time signatures isotropic will lead to very strong time signatures. To get a narrower look this proposes the following mechanic: <code>BigTimeSignature.details.width-adjustment</code> may be set to a factor. If the height is increased by some percentage width will be increased by only this part of that percentage. E.g. if that value is set to 0.5 then if height is increased by 100% width will be increased by only 50%.
Line 9: Line 9:
<lilypond version="2.24">
<lilypond version="2.24">
%%%%%%%%%%%%%%%% Big Time Signatures %%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%% Big Time Signatures %%%%%%%%%%%%%%%%
% Version: 2                                       %
% Version: 3                                       %
% Author: Tina Petzel (lilypond@petzel.at)          %
% Author: Tina Petzel (lilypond@petzel.at)          %
% Description: Implements large time signatures as  %
% Description: Implements large time signatures as  %
Line 25: Line 25:
%  the original stencil changes to this will be    %
%  the original stencil changes to this will be    %
%  reflected. This way e.g. the width can be      %
%  reflected. This way e.g. the width can be      %
%  adjusted.                                       %
%  adjusted. Similarly the minimum height of the  %
%  big time signature can be set in                %
%  `details.min-height`.
%                                                  %
%                                                  %
%  This file also defines a                        %
%  This file also defines a                        %
Line 56: Line 58:
%                                                  %
%                                                  %
% Functions:                                        %
% Functions:                                        %
% * (big-time-signature::print grob): Calculate     %
% * (big-time-signature::y-extent-from-elements    %
%   extent of big time signature and create        %
grob): Calculate Y-extent of big time signature %
scaled stencil.                                 %
% * (big-time-signature::print grob): Create scaled %
%  stencil from extent.                           %
% * (big-time-signature::estimate-factors grob):    %
% * (big-time-signature::estimate-factors grob):    %
%  Estimate scaling factors of big time            %
%  Estimate scaling factors of big time            %
Line 84: Line 87:
%%% Define a new `BigTimeSignature` spanner
%%% Define a new `BigTimeSignature` spanner


% Print big time sig. Scaling of width is done by scaling original stencil
% Determine full extent of individual time signatures
#(define (big-time-signature::print grob)
#(define (big-time-signature::y-extent-from-elements grob)
   (let*
   (let*
     ((height-limit (ly:grob-property grob 'height-limit +inf.0))
     ((height-limit (ly:grob-property grob 'height-limit +inf.0))
    (minimum-height
      (assoc-get 'min-height (ly:grob-property grob 'details) 0))
     (elts (ly:grob-object grob 'elements)) ; time-sig grobs
     (elts (ly:grob-object grob 'elements)) ; time-sig grobs
     (elts-list (ly:grob-array->list elts))
     (elts-list (ly:grob-array->list elts))
Line 102: Line 107:
     (full-ext-height (interval-length full-ext))
     (full-ext-height (interval-length full-ext))
     (full-ext-center (interval-center full-ext))
     (full-ext-center (interval-center full-ext))
     (limited-height (min full-ext-height height-limit))
     (limited-height
      (max minimum-height (min full-ext-height height-limit)))
     (limited-ext
     (limited-ext
       (cons (- full-ext-center (/ limited-height 2))
       (cons (- full-ext-center (/ limited-height 2))
             (+ full-ext-center (/ limited-height 2))))
             (+ full-ext-center (/ limited-height 2)))))
    ; Y-parent should be System = ref already,
    ; but just in case make sure
    (ly:grob-set-parent! grob Y ref)
    limited-ext))
 
% Print big time sig. Scaling of width is done by scaling original stencil
#(define (big-time-signature::print grob)
  (let*
    ((elts (ly:grob-object grob 'elements)) ; time-sig grobs
    (limited-ext (ly:grob-property grob 'Y-extent))
    (limited-height (interval-length limited-ext))
     ; the stencil of one time signature
     ; the stencil of one time signature
     (stc (ly:grob-property (ly:grob-array-ref elts 0) 'stencil))
     (stc (ly:grob-property (ly:grob-array-ref elts 0) 'stencil))
     (stc-ext-y (car exts)) ; the Y-extent of the time sig stencil
     ; the Y-extent of the time sig stencil
     (stc-ext-x (ly:stencil-extent stc X))
     (stc-ext-y (ly:stencil-extent stc Y))
       ; scaling factor for the stencil
       ; scaling factor for the stencil
     (f (/ limited-height (interval-length stc-ext-y))))
     (f (/ limited-height (interval-length stc-ext-y))))
    ; Y-parent should be System = ref already,
    ; but just in case make sure
    (ly:grob-set-parent! grob Y ref)
     ; shift resulting stencil to begin of time sig column
     ; shift resulting stencil to begin of time sig column
     (ly:stencil-translate-axis
     (ly:stencil-translate-axis
Line 125: Line 139:
   (let*
   (let*
     ((height-limit (ly:grob-property grob 'height-limit +inf.0))
     ((height-limit (ly:grob-property grob 'height-limit +inf.0))
    (minimum-height
      (assoc-get 'min-height (ly:grob-property grob 'details) 0))
     (width-adjustment
     (width-adjustment
       (assoc-get 'width-adjustment (ly:grob-property grob 'details) 0))
       (assoc-get 'width-adjustment (ly:grob-property grob 'details) 0))
Line 130: Line 146:
     (elts-list (ly:grob-array->list elts))
     (elts-list (ly:grob-array->list elts))
     (full-ext-height (+ (* 5 (length elts-list)) (* 4 (1- (length elts-list)))))
     (full-ext-height (+ (* 5 (length elts-list)) (* 4 (1- (length elts-list)))))
     (limited-height (min full-ext-height height-limit))
     (limited-height
      (max minimum-height (min full-ext-height height-limit)))
       ; scaling factor for the stencil
       ; scaling factor for the stencil
     (f (/ limited-height 5))
     (f (/ limited-height 5))
Line 157: Line 174:
     `(BigTimeSignature
     `(BigTimeSignature
       . ((stencil . ,big-time-signature::print)
       . ((stencil . ,big-time-signature::print)
          (Y-extent . ,big-time-signature::y-extent-from-elements)
           (meta
           (meta
           . ((class . Spanner)
           . ((class . Spanner)
Line 296: Line 314:
       \consists #big-time-signature-engraver
       \consists #big-time-signature-engraver
       \override TimeSignature.transparent = ##t
       \override TimeSignature.transparent = ##t
       \override BigTimeSignature.height-limit = 15
       \override BigTimeSignature.height-limit = 16
       \override BigTimeSignature.details.width-adjustment = 0.2
       \override BigTimeSignature.details.width-adjustment = 0.2
     }
     }
Line 332: Line 350:
}
}


%%% Example (staff group level, fixed height)
\score {
  \header {
    title =
    "Example 4: Per Group, fixed height, 20% width adjustment"
  }
  \layout {
    \context {
      \StaffGroup
      \consists #big-time-signature-engraver
      \override TimeSignature.transparent = ##t
      \override BigTimeSignature.height-limit = 16
      \override BigTimeSignature.details.width-adjustment = 0.2
      \override BigTimeSignature.details.min-height = 16
    }
  }
  <<
    \new Staff {
      \numericTimeSignature
      c''1 \time 3/4 d''2.
    }
    <<
      \new StaffGroup <<
        \new Staff {
          c''1 \time 3/4 d''2.
        }
        \new Staff {
          c''1 \time 3/4 d''2.
        }
      >>
    >>
    <<
      \new StaffGroup <<
        \new Staff {
          c''1 \time 3/4 d''2.
        }
        \new Staff {
          c''1 \time 3/4 d''2.
        }
        \new Staff {
          c''1 \time 3/4 d''2.
        }
      >>
    >>
  >>
}


\score {
\score {
   \header {
   \header {
     title = \markup {
     title = \markup {
       "Example 3: Whole system, comparison of"
       "Example 5: Whole system, comparison of"
       \typewriter "details.width-adjustment"
       \typewriter "details.width-adjustment"
     }
     }