On 2021-11-03 4:45 pm, Paolo Prete wrote:
Hello Aaron,
what if I enlarge the beam angle? (see below)
Okay, my guesswork was wrong. Here is code that was adapted from the
underlying C++ logic:
%%%%
\version "2.22.0"
#(define (ly:stem::beam-multiplicity grob)
;; Adapted from non-exported C++ method
(define (slice lst)
(let ((ints (filter integer? (or lst '()))))
(if (null? ints) (cons 1 -1)
(cons (apply min ints) (apply max ints)))))
(let ((beaming (ly:grob-property grob 'beaming)))
(interval-union (slice (car beaming)) (slice (cdr beaming)))))
#(define (ly:beam::get-beam-count grob)
;; Adapted from non-exported C++ method
(apply max
(map
(lambda (stem)
(1+ (interval-length (ly:stem::beam-multiplicity stem))))
(ly:grob-array->list (ly:grob-object grob 'stems)))))
#(define (ly:beam::get-beam-translation grob)
;; Adapted from non-exported C++ method
(let* ((beam-count (ly:beam::get-beam-count grob))
(staff-space (ly:staff-symbol-staff-space grob))
(line-thickness (ly:staff-symbol-line-thickness grob))
(beam-thickness (* (ly:grob-property grob 'beam-thickness)
staff-space))
(length-fraction (ly:grob-property grob 'length-fraction 1))
(scalar (if (< beam-count 4) 2 3)))
(- (* length-fraction (+ staff-space (/ line-thickness scalar)))
(/ beam-thickness scalar))))
alignGrowingBeams =
\override Beam.positions =
#(grob-transformer 'positions (lambda (grob orig)
(let* ((beam-translation (ly:beam::get-beam-translation grob))
(beam-count (ly:beam::get-beam-count grob))
(staff-space (ly:staff-symbol-staff-space grob))
(height (/ (* (1- beam-count) beam-translation) staff-space))
(direction (ly:grob-property grob 'direction))
(grow-right? (< 0 (ly:grob-property grob 'grow-direction)))
(interval (if (interval-sane? orig) orig
(reverse-interval orig)))
(far (interval-index interval direction))
(near (- far (* 0.5 direction height))))
(if grow-right? (cons near far) (cons far near)))))
beamTest = {
\override Beam.grow-direction = #RIGHT
e'32[ f' g' a']
c''64[ d'' e'' f'']
\override Beam.grow-direction = #LEFT
b'128[ a' g' f']
}
beamTests = {
\beamTest
\override Beam.length-fraction = #1.6
\beamTest
\override Beam.beam-thickness = #0.8
\beamTest
}
{ \alignGrowingBeams \beamTests }
{ \magnifyStaff #0.6 \alignGrowingBeams \beamTests }
%%%%
-- Aaron Hill