lilypond-user
[Top][All Lists]
Advanced

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

Re: Simple example with vertical spacing and dynamic contexts


From: Aaron Hill
Subject: Re: Simple example with vertical spacing and dynamic contexts
Date: Thu, 31 Jan 2019 18:53:18 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-01-31 9:11 am, Павел Буданов wrote:
I've solved this problem partially with for lower contexts, but i
can't find the necessary properties for upper contexts. Can you help
me?

\new StaffGroup
<<
  \new Dynamics { s2.\< s4\ff }
  \new Lyrics \lyricmode { Ly4 -- ric ly -- ric }
  \new Staff \with
  { \override VerticalAxisGroup.staff-staff-spacing =
#'((basic-distance . 20) (padding . 0.5)) }
  { a'4 a' a' a' }
  \new Staff { d'4 d' d' d' }
  \new Lyrics \with
  {
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
#'((basic-distance . 10) (padding . 0.5))
    \override VerticalAxisGroup.nonstaff-nonstaff-spacing =
#'((basic-distance . 10) (padding . 0.5))
  }
  \lyricmode { Ly4 -- ric ly -- ric }
  \new Dynamics { s2.\< s4\ff }
>>

Be sure to examine the output of LilyPond for warnings, not just errors:

warning: staff-affinities should only decrease

This is telling you that you need to manually adjust VerticalAxisGroup.staff-affinity. By default, Dynamics uses a staff-affinity of CENTER (0) as it typically appears between two staves, whereas Lyrics uses UP (1) as it typically appears below a staff. Your upper Lyrics context is trying to locate its "relatedstaff" above, but there is none to be found. You will need to set its staff-affinity to DOWN (-1). (You could leave the two Dynamics contexts set to CENTER staff-affinity; but it arguably better to also explicitly set them to UP/DOWN based on where they appear.)

There is a second issue that unfortunately there is no warning for. You are setting basic-distance but not minimum-distance as well. By omitting minimum-distance from the spacing alist, you are using the default value of zero. LilyPond only attempts to honor basic-distance, but will collapse down to minimum-distance if needed (and often a little too eagerly). If you tried to set only basic-distance for the upper contexts, you may find that it has no effect.

It may be easier to see what it going on by only using padding, although a combination of basic-distance, minimum-distance, padding, and stretchability is often required to get the most out of the flexible spacing system. Consider the following:

%%%%
\version "2.19.82"

% Forcibly reset all default spacing variables to zero.
\layout {
  \context { \Dynamics
    \override VerticalAxisGroup.nonstaff-nonstaff-spacing = #'(())
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing = #'(())
    \override VerticalAxisGroup.nonstaff-unrelatedstaff-spacing = #'(())
  }
  \context { \Lyrics
    \override VerticalAxisGroup.nonstaff-nonstaff-spacing = #'(())
    \override VerticalAxisGroup.nonstaff-relatedstaff-spacing = #'(())
    \override VerticalAxisGroup.nonstaff-unrelatedstaff-spacing = #'(())
  }
  \context { \Staff
    \override VerticalAxisGroup.default-staff-staff-spacing = #'(())
    \override VerticalAxisGroup.staff-staff-spacing = #'(())
  }
}

\new StaffGroup <<
  \new Dynamics \with {
      % Dynamics is above Staff.
      \override VerticalAxisGroup.staff-affinity = #DOWN
      % Spacing between this Dynamics and the following Lyrics.
      \override VerticalAxisGroup.nonstaff-nonstaff-spacing =
        #'((padding . 2))
    }
    { s2.\< s4\ff }
  \new Lyrics \with {
      % Lyrics is above Staff.
      \override VerticalAxisGroup.staff-affinity = #DOWN
      % Spacing between this Lyrics and the following Staff.
      \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
        #'((padding . 3))
    }
    \lyricmode { Ly4 -- ric ly -- ric }
  \new Staff \with {
      % Spacing between this Staff and the following Staff.
      \override VerticalAxisGroup.staff-staff-spacing =
        #'((padding . 5))
    }
    { a'4 a' a' a' }
  \new Staff { d'4 d' d' d' }
  \new Lyrics \with {
      % Lyrics is below Staff.
      \override VerticalAxisGroup.staff-affinity = #UP
      % Spacing between this Lyrics and the preceding Staff.
      \override VerticalAxisGroup.nonstaff-relatedstaff-spacing =
        #'((padding . 3))
      % Spacing between this Lyrics and the following Dynamics.
      \override VerticalAxisGroup.nonstaff-nonstaff-spacing =
        #'((padding . 2))
    }
    \lyricmode { Ly4 -- ric ly -- ric }
  \new Dynamics \with {
      % Dynamics is below Staff.
      \override VerticalAxisGroup.staff-affinity = #UP
    }
    { s2.\< s4\ff }
  >>
%%%%

Play around with the various padding amounts in the snippet. It should hopefully be clear which spacing variable affects what spacing. Generally speaking, spacing is done top to bottom, so spacing is almost always below an item. The exception is when a non-staff has its related (or unrelated) staff above it.

Once you have a good feel for that, set padding to a large negative number (e.g. -100) and then experiment with setting minimum-distance as well. The negative padding will permit overlap, so it is easier to see how minimum-distance works. You should notice that you need larger values for minimum-distance than you did with padding to achieve a similar spacing. That is because minimum-distance is measured not from the extents/skylines of the content but from the reference point for each context. The Notation Reference lists these unique reference points.

After that, basic-distance works the same as minimum-distance in terms of being measured from the reference points. Just remember that since LilyPond only tries to respect the basic-distance, you may need to rely more on minimum-distance in practice.

Hope some of this helps.

-- Aaron Hill



reply via email to

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