lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dynamic next to espressivoII


From: Thomas Morley
Subject: Re: dynamic next to espressivoII
Date: Sun, 3 Feb 2019 15:20:21 +0100

Am So., 3. Feb. 2019 um 08:17 Uhr schrieb Andrew Bernard
<address@hidden>:
>
> I posted abot this recently, but only one response. Does anybody have any 
> idea how to align a dynamic and the new \espressivo mark horizontally, next 
> to each other? I know one is a dynamic and one is an accent, so I am stumped.
>
> Refer to the image extracted from the MS I am setting. I'd like it to be 
> close to this effect.
>
> Thanks all!
>
> Andrew

Hi Andrew,

in my understanding the espressivo-sign is a hint for the musician to
apply crescendo followed by a decrescendo on a long note.
In your image I fail to see any espressivo-sign, but encounter always
the more verbose (de)crescendo-Hairpins.

Furthermore in LilyPond they are different grobs, one a spanner the
other an item.
Placing them at the same height is possible only if both graphic signs
are transformed to belong to Dynamics or to Scripts. imho.

If the espressivo is not a spanner, than you have always to adjust the
extension-values as soon as layout changes even if the espressivo is
part of Dynamics. (See below)

So I'd vote for a new espressivo being a spanner, or more precisely it
should use real Hairpins.

Here some thoughts:

One could do all manual (the first two codings) or one could try to
automate it (the next two codings, the first reuses Aaron's coding, so
the pseudo-Hairpins are no spanners)

\version "2.19.82"

\paper {
  indent = 0
  %% uncomment:
  %ragged-right = ##f
}

\markup "Manually: using Hairpins and simultaneous-music, i.e << ... >>"

\new Staff {
  <<
    c''2
    { s4\mf-\tweak minimum-length #10 \< s4-\tweak minimum-length #6 \> <>\! }
  >>
  %% A \bar-command is necessary, otherwise one can't end with <>\!
  \bar "|."
}

\markup "Manually: using Hairpins and \\at by David Kastrup"

at =
#(define-music-function (time event music)
  (ly:duration? ly:music? ly:music?)
  "Place @var{event} at a relative duration @var{time} in relation to
  @var{music}."
  #{ \context Bottom << { \skip $time <>$event } $music >> #})

\new Staff {
  \at 4 -\tweak minimum-length #6 \> c''2\mf-\tweak minimum-length #10 \<
  <>\!
  %% A \bar-command is necessary, otherwise one can't end with <>\!
  \bar "|."
}

\markup \wordwrap-string
  #"Autogenerate: using DynamicText with 'make-dynamic-script', and
  'make-espressivo-stencil' by Aaron Hill"

dynamicTextLengthOn = {
  % 0.4 staff-space between adjacent texts
  \override DynamicText.extra-spacing-width = #'(-0.0 . 0.4)
  \override DynamicText.extra-spacing-height = #'(-inf.0 . +inf.0)
}

dynamicTextLengthOff = {
  \override DynamicText.extra-spacing-width = #'(+inf.0 . -inf.0)
  \override DynamicText.extra-spacing-height = #'(0 . 0)
}

#(define (make-espressivo-stencil thick width height gap)
   (let* ((inner (/ gap 2))
          (outer (+ width inner))
          (middle (/ height 2)))
     (ly:stencil-add
       (make-line-stencil thick (- inner) 0 (- outer) middle)
       (make-line-stencil thick (- outer) middle (- inner) height)
       (make-line-stencil thick inner 0 outer middle)
       (make-line-stencil thick outer middle inner height))))

buzz =
#(define-event-function (args dyn-strg)
  ((number-list? '(0.1 4 0.9 0.35)) string?)
  ;; args-list contains settings for: thick width height gap
  (make-dynamic-script
    #{
      \markup {
        $dyn-strg
        \stencil $(apply make-espressivo-stencil args)
      }
    #}))

{
  \dynamicTextLengthOn
  %% need to adjust X-offset (or self-alignment-X)
  c''-\tweak X-offset #-0.5 \buzz "p"
  c''-\tweak X-offset #-1.3 \buzz "pf"
  c''-\tweak X-offset #-2.5 \buzz #'(0.1 8 0.9 0.5) "pppp"
}

\markup \wordwrap-string
  #"Autogenerate: simultaneous-music with Hairpins."

%% Helper, c/p from define-music-display-methods.scm
#(define (make-music-type-predicate . music-types)
  (define make-music-type-predicate-aux
    (lambda (mtypes)
      (lambda (expr)
        (if (null? mtypes)
            #f
            (or (eqv? (car mtypes) (ly:music-property expr 'name))
                ((make-music-type-predicate-aux (cdr mtypes)) expr))))))
  (make-music-type-predicate-aux music-types))

foo =
#(define-music-function (shorten mus)
  ((number-pair-list? '((0 . 0) (0 . 0))) ly:music?)
  ;; the optional argument 'shorten' may be used fine-tune first/second Hairpin
  ;; going for 'minimum-length would have been possible as well, though
  ;; 'shorten-pair gives more control
  (let* ((note-or-chord?
           (make-music-type-predicate
             ;; more?
             'EventChord
             'NoteEvent)))
    (if (note-or-chord? mus)
        (let* ((mus-length (ly:moment-main (ly:music-length mus)))
               (half-mus-length (/ mus-length 2))
               (new-length-pair
                 (cons
                   (numerator half-mus-length)
                   (denominator half-mus-length)))
               (skip #{ \scaleDurations $new-length-pair s1\> #})
               (start-skip #{ \scaleDurations $new-length-pair s1\< #}))

          (cond ((music-is-of-type? mus 'note-event)
                   (let* ((arts (ly:music-property mus 'articulations)))
                     (ly:music-set-property! mus 'articulations
                       (remove
                          (lambda (m)
                            (music-is-of-type? m 'absolute-dynamic-event))
                            arts))
                     (ly:music-set-property! start-skip 'articulations
                       (append
                         (filter
                            (lambda (m)
                              (music-is-of-type? m 'absolute-dynamic-event))
                              arts)
                         (ly:music-property start-skip 'articulations)))))
                ((music-is-of-type? mus 'event-chord)
                  (let* ((elts (ly:music-property mus 'elements)))
                    (ly:music-set-property! mus 'elements
                      (remove
                         (lambda (m)
                           (music-is-of-type? m 'absolute-dynamic-event))
                           elts))
                    (ly:music-set-property! start-skip 'articulations
                      (append
                        (filter
                           (lambda (m)
                             (music-is-of-type? m 'absolute-dynamic-event))
                             elts)
                        (ly:music-property start-skip 'articulations))))))
        (make-simultaneous-music
          (list
            mus
            #{
              \context Voice = "dyn-skips" {
                \once \override Hairpin.shorten-pair = $(car shorten)
                $start-skip
                \once \override Hairpin.shorten-pair = $(cadr shorten)
                $skip
                <>\!
              }
            #})))
        mus)))

\new Staff {
  %% override in Staff is needed, because the Hairpins are in another Voice
  \override Staff.Hairpin.minimum-length = 10
  \foo c''1
  \foo #'((0 . -1)(1 . 0)) <c'' e''>4..\mf
  \foo #'((0 . -0.5)(0.5 . 2)) c''4..\pp
  \breathe
  r8
  \break
  \makeClusters { \foo b'2..\p g''8 \foo <g' b'>2..\mf <c'' g''>8 }
  \break
  \foo #'((0 . -0.5)(0.5 . 2)) c''2\pp
  \bar "|."
}



Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]