lilypond-user
[Top][All Lists]
Advanced

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

Re: "natural width" of a measure


From: David Nalesnik
Subject: Re: "natural width" of a measure
Date: Tue, 11 Apr 2017 15:42:48 -0500

On Tue, Apr 11, 2017 at 3:34 PM, David Nalesnik
<address@hidden> wrote:
> On Tue, Apr 11, 2017 at 1:52 PM, Urs Liska <address@hidden> wrote:
>>
>>
>> Am 11.04.2017 um 20:46 schrieb Malte Meyn:
>>>
>>> Am 11.04.2017 um 20:36 schrieb Urs Liska:
>>>> So, is there any moment in the compilation process where the natural,
>>>> unstretched length of a measure can be calculated? It doesn't have to be
>>>> an easily-read property and can involve calculation, but actually the x
>>>> position of the barlines would be an easy target - *if* there's this
>>>> magic moment in the compilation pipeline ;-)
>>> Maybe you could experiment with the ly:one-line-breaking?
>>
>> I don't think so (only, of course, to investigate how much can be done
>> on the internal level).
>> Basically what I'm after is a ly:cheap-line-breaking mode that doesn't
>> care at all about overall appearance or good page turns but instead
>> simply places as many measures in a line as fit naturally. If then a
>> line break changes and I know the natural width of the measures I can
>> determine before compilation how many measures will fit on the *next*
>> system.
>>
>
> But spacing depends on the sorts of durations present -- the most
> common duration, the shortest duration.
>
> Do you mean to typeset each measure as if it's in isolation, without
> stretching based on surrounding measures?
>
> For example,
>
> \version "2.19.59"
>
> \layout { ragged-right = ##t }
>
> {
>   \repeat unfold 16 { c''16 }
>   \repeat unfold 4 { c''4 }
>   c''1
>   c''2 c''2
>   \repeat unfold 64 { c''64 }
> }
>
> \layout {
>   \context {
>     \Score
>     \override SpacingSpanner.common-shortest-duration = #'()
>   }
> }
>
> %%
>
> Alternately, you could create a \newSpacingSection every measure,
> though this gives different values.  Don't know why.
>
> %%%%%%%%%%%%%%%%%%%%%%%%
>
> Here's how you can determine the widths of measures.  Note that I've
> put everything on one line, so that the \once \override of the
> NoteHead gives access to every column in the score.  You can adjust
> what alignment objects are used to gauge width by changing the symbol
> in ly:paper-column::break-align-width (available as of 2.19.59).
> Right now, it's BreakAlignment objects to give you an extent
> considering all prefatory materials.  staff-bar would give extents of
> the bar lines.
>
> \version "2.19.59"
>
> \paper {
>   page-breaking = #ly:one-line-breaking
> }
>
> #(define (display-measure-widths grob)
>    (let* ((sys (ly:grob-system grob))
>           (cols (ly:grob-array->list (ly:grob-object sys 'columns)))
>           (nmpcs
>            (filter
>             (lambda (elt)
>               (and (grob::has-interface elt 'paper-column-interface)
>                    (eq? #t (ly:grob-property elt 'non-musical))))
>             cols))
>           (widths
>            (map
>             (lambda (c) (ly:paper-column::break-align-width c
> '(break-alignment)))
>             nmpcs))
>           (widths (sort widths (lambda (x y) (< (car x) (car y)))))
>           )
>      (pretty-print widths)))
> {
>
>   \once \override NoteHead.after-line-breaking = #display-measure-widths
>   \repeat unfold 4 { c''8. c''16}
>   \repeat unfold 4 { c''4 }
>   c''1
>   c''2 c''2
>   \repeat unfold 64 { c''64 }
> }
>
> \layout {
>   \context {
>     \Score
>     \override SpacingSpanner.common-shortest-duration = #'()
>   }
> }
>
> Hope this helps with something!
>

Oh, I should have mentioned that the function is showing the extents
of objects held by the columns organizing barlines, clefs, key
signatures, etc --  not measure lengths.  Finding the measures will
involve an extra fun step.

David



reply via email to

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