Am Fr., 19. Dez. 2025 um 14:35 Uhr schrieb Tina Petzel <[email protected]>:
>
> > Nice, thanks!  In case this works in general, would it make sense to
> > add that to `\breakDynamicSpan`?
>
> Don’t think that’s a good idea. `\breakDynamicSpan` is intended to break the
> current dynamic line at this time step, not to break to dynamic events at the
> same time.

+1

>
> The intended purpose for this is a setting like this
>
> ```
> {
>   \dynamicUp
>   g''1\fermata\f\>\breakDynamicSpan
>
>   \section
>   c''4\p\< 4 4 4 |
>   2\sf
> }
> ```
>
> where a dynamic marking is not linked to the previous hairpin. Applying Harms
> code here does cause issues in this intended scenario:
>
> ```
> {
>   \dynamicUp
>   g''1\fermata\f
>     -\tweak before-line-breaking
>       #(lambda (grob)
>          (let ((dyn-txt (ly:spanner-bound grob LEFT)))
>            (ly:spanner-set-bound! grob LEFT (ly:grob-parent dyn-txt X))))
>       \>
>     \breakDynamicSpan
>   \section
>
>   c''4\p\< 4 4 4 |
>   2\sf
> }
> ```
>
> So what you are intending to do is not at all something `\breakDynamicSpan` is
> designed for. In fact your problem is not actually the `DynamicLineSpanner`,
> as dynamics with different direction will break the `DynamicLineSpanner` 
> anyway.
> As Harms has shown it is actually the fact that in dynamic-engraver.cc:175 the
> left bound of the hairpin is set to any dynamic script that might exists, even
> if it is not in the same direction as the hairpin. In theory this should be
> fixable by adding a check for direction of hairpin matching direction of the
> script event.
>
> Modifying Harms solution we can also do:
>
> ```
> \layout {
>   \context {
>     \Score
>     \override Hairpin.before-line-breaking =
>     #(lambda (grob)
>        (let* ((bound-left (ly:spanner-bound grob LEFT))
>               (bound-right (ly:spanner-bound grob RIGHT))
>               (line-span (ly:grob-parent grob Y))
>               (bound-left-line-span (ly:grob-parent bound-left Y))
>               (bound-right-line-span (ly:grob-parent bound-right Y)))
>          (if (not (eq? line-span bound-left-line-span))
>              (ly:spanner-set-bound! grob LEFT (ly:grob-parent bound-left X)))
>          (if (not (eq? line-span bound-right-line-span))
>              (ly:spanner-set-bound! grob RIGHT (ly:grob-parent bound-right
> X)))))
>   }
> }
>
> {
>   c''2_\ppppp^\> 2\!
>   2^\> 2_\ppppp
>   2^\< 2\>\breakDynamicSpan
>   2^\ppppp^\< 2\!
> }
> ```
>
> This will apply Harms logic for left and right bound only if it belongs to a
> different dynamic line span group.
>
> Cheers,
> Tina

Reply via email to