[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: tweaking beam length
From: |
Thomas Morley |
Subject: |
Re: tweaking beam length |
Date: |
Fri, 17 May 2013 00:40:49 +0200 |
2013/5/16 luis jure <address@hidden>:
>
> dear list,
>
> the output of the following code is shown in the first attached image:
>
> \version "2.17.17"
>
> \score {
> \new Voice \with {
> \remove "Forbid_line_break_engraver"
> \override Beam.breakable = ##t
> }
>
> \relative c'' {
> \repeat unfold 5 { c2. \repeat unfold 2 { c8[ c16] } c8 c2. } }
> \layout { }
> }
>
>
> i find the beams after the break (m. 6) too long, but i don't know how to
> modify them. i'd like to get something like in the second image. is there
> a property that i could somehow adjust? i tried a couple of searches in
> the manual but i couldn't find anything appropriate.
>
> best,
>
>
> lj
Hi Luis,
I suppose noone thought about this case before.
At least, every version since 2.12.3 (the oldest on my computer) shows
two beams of equal length at line-begin.
Worth a bug-report, I think.
Meanwhile you may want to use the function below.
Comments in code, if something isn't clear, shout.
\version "2.16.0"
shortenBrokenBeams =
#(define-music-function (parser location 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.
"
#{
%% Add \once ?
\override Score.Beam #'beam-segments =
#(lambda (grob)
(let* ((beam-segments (ly:beam::calc-beam-segments grob))
(grob-name
(lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
;; TODO: better coding, use set-car! or ...
(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)))
#})
\score {
\new Voice \with {
\remove "Forbid_line_break_engraver"
\override Beam #'breakable = ##t
}
\relative c'' {
\shortenBrokenBeams #'(-1.5 -3.6)
\repeat unfold 5 { c2. \repeat unfold 2 { c8[ c16] } c8 c2. } }
\layout { }
}
HTH,
Harm
affect-broken-beams-length.png
Description: PNG image