Hello Arjen, I’m wondering if in your case it ight be beneficial to not create two Hairpins, but rather a special case stencil like this:
%%%%% #(define (ly:expr-hairpin::print grob) (let* ((orig (ly:hairpin::print grob)) (sp (ly:grob-property grob 'shorten-pair '(0 . 0))) (spl (car sp)) (spr (cdr sp)) (t (ly:grob-property grob 'text #f)) (tst (if t (grob-interpret-markup grob t) empty-stencil)) (tst (ly:stencil-translate-axis (ly:stencil-aligned-to (ly:stencil-aligned-to tst Y CENTER) X CENTER) (interval-center (ly:stencil-extent orig X)) X)) (bp (ly:grob-property grob 'gap 0.3)) (bp2 (ly:grob-property grob 'bound-padding 0.3)) (len (interval-length (ly:stencil-extent orig X))) (pad (if t (* 2 bp2) bp)) (shorten (/ (+ len pad (interval-length (ly:stencil-extent tst X))) 2)) (st1 #f) (st2 #f)) (ly:grob-set-property! grob 'shorten-pair (cons spl (+ spr shorten))) (ly:grob-set-property! grob 'grow-direction RIGHT) (set! st1 (ly:hairpin::print grob)) (ly:grob-set-property! grob 'shorten-pair (cons (+ spl shorten) spr)) (ly:grob-set-property! grob 'grow-direction LEFT) (set! st2 (ly:hairpin::print grob)) (ly:grob-set-property! grob 'shorten-pair sp) (ly:grob-set-property! grob 'grow-direction RIGHT) (ly:stencil-add st1 st2 tst))) expr = -\tweak stencil #ly:expr-hairpin::print -\< { 2\expr 2\! 2\mp\expr 2\! 1\mp\tweak text \markup\dynamic f \expr 1 1 \! } %%%%% Cheers, Valentin Am Sonntag, 24. September 2023, 16:58:18 CEST schrieb Arjen: > Hi, > > I'm trying to place symmetrical hairpins under a bar, but it turns out > that the left (crescendo) hairpin is longer than the right > (descrescendo) hairpin. > MWE: > \version "2.24.1" > \new Voice \relative << > { c'2 c2 } > { s2\< s2\> <>\! } > > > Tweaking with the lengths of the spacers turns out very difficult and > results in hairpins at unequal vertical positions: > \version "2.24.1" > \new Voice \relative << > { c'2 c2 } > { s4...\< s32\! s2\> <>\! } > > > And sometimes I need an absolute dynamic in front of the hairpins, in > which case the left hairpin becomes very small: > \version "2.24.1" > \new Voice \relative << > { c'2 c2 } > { s4...\pp\< s32\! s2\> <>\! } > > > Is there an (hopefully easy) way to give both hairpins equal size and > vertical alignment, regardless of the presence of an absolute dynamic in > front? > > Regards, > Arjen
signature.asc
Description: This is a digitally signed message part.