I've been looking at the code to see how things are defined.
I've been able to get a major improvement by raising the penalty for
unattached beam ends.
It's simple to do by overriding Beam.details.secondary-beam-demerit
Try the following file, modified from the one that Kit posted on the issue:
\version "2.24"
\paper { indent = #0 ragged-right = ##t }
ba = { \bar "|" }
{
\cadenzaOn
%16
d'16[ ^\markup "secondary-beam-demerit = 10"
c' b a] b16[ b c' d'] \ba
\tuplet 3/2 { f''16[ e''! d''] } \ba
%8 and 16
c''8[ f''16 g''] b''8[ d''16 c''] c''8[ a'16 f'] c'8[ a16 b] \ba
<a' c''>8[ <f' a'>16 <d' f'>] q8[ <b d'>16 <g c'>] \ba
g''16[ f'' e''8] d'16[ e' f'8] \ba
d'8[ b16 d' f' a'] \ba
g''8[ \tuplet 3/2 { a''16 f'' d''] } \ba
%beamlets
f''16[ f''8 a''16] g'8.[ a'16 g'8] \ba
%32
f''32[ a'' g'' f'' e'' d''] f'''32[ e''' d''' c''' b'' c''' a'' f''] \ba
%8 and 32
b'32[ d'' c'' e'' d''8] \ba
%16 and 32
g32[ a b c' d'16 e'] \ba
e''16[ c''' c'''32 b'' a'' g''] g''16[ f''32 e'' d'' c''] \ba
%mixed
d''16[ c''32 b' c''8] \ba
\break
%beam subdivision actually makes some things worse,
%but idk if that's not unavoidable
\set beamMinimumSubdivision = #1/8
\set subdivideBeams = ##t
f''32[ a'' g'' f'' e'' d''] \ba
g32[ a b c' d'16 e'] \ba
g''16[ f''32 e'' d'' c''] \ba
\break
\set subdivideBeams = ##f
\override Score.Beam.details.secondary-beam-demerit = 100
%16
d'16[ ^\markup "secondary-beam-demerit = 100"
c' b a] b16[ b c' d'] \ba
\tuplet 3/2 { f''16[ e''! d''] } \ba
%8 and 16
c''8[ f''16 g''] b''8[ d''16 c''] c''8[ a'16 f'] c'8[ a16 b] \ba
<a' c''>8[ <f' a'>16 <d' f'>] q8[ <b d'>16 <g c'>] \ba
g''16[ f'' e''8] d'16[ e' f'8] \ba
d'8[ b16 d' f' a'] \ba
g''8[ \tuplet 3/2 { a''16 f'' d''] } \ba
%beamlets
f''16[ f''8 a''16] g'8.[ a'16 g'8] \ba
%32
f''32[ a'' g'' f'' e'' d''] f'''32[ e''' d''' c''' b'' c''' a'' f''] \ba
%8 and 32
b'32[ d'' c'' e'' d''8] \ba
%16 and 32
g32[ a b c' d'16 e'] \ba
e''16[ c''' c'''32 b'' a'' g''] g''16[ f''32 e'' d'' c''] \ba
%mixed
d''16[ c''32 b' c''8] \ba
\break
%beam subdivision actually makes some things worse,
%but idk if that's not unavoidable
\set beamMinimumSubdivision = #1/8
\set subdivideBeams = ##t
f''32[ a'' g'' f'' e'' d''] \ba
g32[ a b c' d'16 e'] \ba
g''16[ f''32 e'' d'' c''] \ba
}
On Sat, Dec 20, 2025 at 3:29 PM A Jakovljevic
<[email protected]> wrote:
>
> The exemple you've given over there seems all right for the general
> beam-in-space issue; for the beam damping affecting it here is my example
> again (with the default and three different values for damping; I realise
> that this might in some cases be an alternative way of fixing wrong beams
> without having to manually indicate staff positions - damping = #3 has it
> nearly as I set it manually - so attaching it as an example of that as well)
> to allow for easy comparison. I don't have any old versions of Lilypond on my
> computer but if someone can run it that would be useful to see if it also
> arose between 2.2/2.4.
>
> Cheers,
>
> Aleksa
>
> Am Sa., 20. Dez. 2025 um 12:23 Uhr schrieb Luise Flesch
> <[email protected]>:
>>
>> just realised I should probably link the issue I created so here:
>> https://gitlab.com/lilypond/lilypond/-/issues/6877
>> it's not very sophisticated but I hope it's comprehensible
>>
>>> I'll try to take some time to type up a proper regtest-like example.
>>
>> oh please do, I have a feeling you'll do much better at that than me lmao
>>
>> thanks all :)
>> luise