lilypond-user
[Top][All Lists]
Advanced

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

Re: Line-breaking with non-aligned barlines


From: Thomas Morley
Subject: Re: Line-breaking with non-aligned barlines
Date: Sun, 28 Oct 2018 02:01:04 +0200

Am Fr., 26. Okt. 2018 um 23:52 Uhr schrieb David Sumbler <address@hidden>:


> But as things are the break here is still unsatisfactory
> because the semiquaver just after the break has 2 long beams stretching
> back to the start of the line, whereas one would ideally want 1 long
> beam and a short one.  I haven't managed to figure out how this can be
> changed: any ideas would be welcome.

A minimal would be:

\paper { indent = 0 ragged-right = ##t }

{
    \override Beam.breakable = ##t
    s2. s8
    c'8[
    \break
    c'16]
}

Not sure I'd call it a bug. But I'd love to have a method to change
this behaviour easily, currently there's none.
Though, you can dive into Beam deeply and reset 'beam-segments with
custom values. Leading to:

\version "2.19.81"

\paper { indent = 0 ragged-right = ##t }

shortenBrokenBeams =
#(define-music-function (amount)(number-list?)
"
 Shorten broken Beams after line-break.

 We get the 'beam-segments, rebuilding it modified.
 The 'beam-segments-property is an alist of type:
    '(((vertical-count . 0) (horizontal 3.865018 . 5.93))
      ((vertical-count . 1) (horizontal 3.865018 . 5.93)))

    `vertical-count' is the beam-count.
    `horizontal' is the X-extent relative to 'System's 'line-width.

 Applying it only if the left-bound of the 'Beam is 'NonMusicalPaperColumn,
 i.e after a line-break.
 Affecting a broken Beam at line-end is possible, too, but not yet coded.
"
#{
  \override Beam.beam-segments =
    #(lambda (grob)
       (let* ((beam-segments (ly:beam::calc-beam-segments grob))
              (rebuild-beam-segments-proc
                (lambda (vertical-count horizontal shorten)
                  (cons
                    (cons 'vertical-count vertical-count)
                    (list
                      (cons 'horizontal
                        (cons (- (car horizontal) shorten)
                              (cdr horizontal))))))))

       (if (eq? (grob::name (ly:spanner-bound grob LEFT))
                'NonMusicalPaperColumn)
           (begin
              (let* ((horizontals
                       (map
                         (lambda (x) (assoc-get 'horizontal x))
                         beam-segments))
                     (vertical-counts
                       (map
                         (lambda (x) (assoc-get 'vertical-count x))
                         beam-segments))
                     (new-beam-segments
                       (map
                         rebuild-beam-segments-proc
                         vertical-counts horizontals amount)))

       ;;;; If you want to compare the default and the changed
       ;;;; settings, uncomment the following lines.
       ;        (let* ((new-horizontals
       ;                 (map
       ;                   (lambda (x) (assoc-get 'horizontal x))
       ;                   new-beam-segments)))
       ;             (display "\n\thorizontals \t")(write horizontals)
       ;             (display "\n\tnew-horizontals ")(write new-horizontals))
              new-beam-segments))
           beam-segments)))
#})


{
    \override Beam.breakable = ##t
    s2. s8
    \shortenBrokenBeams #'(-2.239194 0)
    c'8[
    \break
    c'16]
}


HTH,
  Harm



reply via email to

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