Re: Symmetrical hairpins

2023-09-25 Thread David Kastrup
Valentin Petzel  writes:

> 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:

Huh.  Maybe this would not be the worst strategy for implementing messa
di voce graphically in general.  It would take care of symmetry and
length issues.

-- 
David Kastrup



Re: Symmetrical hairpins

2023-09-25 Thread Valentin Petzel
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.


Re: Symmetrical hairpins

2023-09-24 Thread Knute Snortum
On Sun, Sep 24, 2023 at 9:12 AM Arjen  wrote:

> 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\> <>\! }
>  >>
>

What I use in this situation is to put the dynamics in their own context
(I'm not sure if context is the correct term):

\version "2.24.2"

notes = { c'2 2 }
dynamics = { s4..\< s16\! s2\> <>\! }

\score {
  <<
\new Staff \notes
\new Dynamics \dynamics % <-- here
  >>
}


--
Knute Snortum


Re: Symmetrical hairpins

2023-09-24 Thread Mats Bengtsson

  
  


On 2023-09-24 16:58, Arjen wrote:

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?
  
  

I prefer to enter the dynamics together with the music, instead
  of instead of using a parallel set of spacing notes, but that may
  be a matter of taste. A first step to get close to what you want
  is to set the minimum-length, either for en individual hairpin
  using \tweak:
\new Voice \relative { 
    c'2 \pp -\tweak minimum-length #7 \< c2 \> <>\! 
  }

or setting it for all upcoming hairpins:
\new Voice \relative { 
    \override Hairpin.minimum-length=#7 c'2 \< c2 \>
  <>\! 
  }
However, as you can see from these two examples, you probably
  need some manual tweaking of the minimum-length for each specific
  situation, in which case the \tweak syntax is somewhat more
  convenient. In particular, it seems that the absolut dynamic (the
  \pp in this example) is included in the length. 

For more aspects on the problem and some ideas of possible
  solutions, see
  https://lists.gnu.org/archive/html/lilypond-user/2023-09/msg00079.html,
  where I'm still hoping that some other people on the list can
  contribute with even better ideas than the ones I came up with. 

    /Mats

PS My examples can of course also be written more similar to your
  code:
\new Voice \relative <<
    { c'2 c2 }
    { s2 \pp -\tweak minimum-length #7 \< s2\> <>\! }
  >>
  
  \new Voice \relative <<
    { c'2 c2 }
    { \override Hairpin.minimum-length=#7 s2 \< s2\>
  <>\! }
  >>