lilypond-user
[Top][All Lists]
Advanced

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

Re: Forcing a DynamicText to appear inside the staff


From: David Nalesnik
Subject: Re: Forcing a DynamicText to appear inside the staff
Date: Thu, 11 Aug 2016 10:32:20 -0500

Hi Thomas,

On Thu, Aug 11, 2016 at 1:22 AM, Thomas Weber <address@hidden> wrote:
>
> I think a scheme function would be useful that determines how much it needs 
> to offset the dynamic to the left in order to move it into the staff.

I'm not sure how useful the code below is, but it may get you started.

The code illustrates several problems.

When you set outside-staff-priority to #f, you lose the mechanism
which causes Dynamics to move vertically in the
absence of a collision.  So there will be no automatic vertical shift
based on X-offset.  This is very apparent if you comment out the
X-offset override in the function \shiftWithinStaff below -- the
dynamic moves up regardless of its horizontal position.

Also, there appears to be no mechanism to accommodate dynamics within
the staff in horizontal spacing.

The function shiftToClear achieves the shifting based on X-offset, but
it won't move anything into the staff.  Additionally, It suffers from
the fact that it can't push notes apart to allow the shift to occur.
You have to do that manually.

Hope this helps a little,
David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.19.45"

#(define move-dynamic-left
   (lambda (grob)
     (let* ((parent-X (ly:grob-parent grob X))
            (d-ex (ly:grob-extent grob parent-X X))
            (width (interval-length d-ex))
            (dynamic-line-spanner (ly:grob-parent grob Y))
            (padding (ly:grob-property dynamic-line-spanner 'padding 0.6)))

       (- (+ width padding)))))

shiftToClear = \once \override DynamicText.X-offset = #move-dynamic-left

shiftWithinStaff = {
  \once \override DynamicLineSpanner.outside-staff-priority = ##f
  \once \override DynamicText.X-offset = #move-dynamic-left
  \once \override DynamicLineSpanner.Y-offset = #-1
}

{
  \voiceTwo
  <d' g' c''>2\f
  \shiftWithinStaff
  <d' g' c''>2\f
  <d' g' c''>1\f
  \shiftWithinStaff
  <d' g' c''>\f
  <d' g' c''>4\f
  \shiftWithinStaff
  <d' g' c''>4\f
}

{
  \voiceTwo
  <d' g' c''>2\f
  \shiftToClear
  <d' g' c''>2\f
  <d' g' c''>1\f
  \shiftToClear
  <d' g' c''>\f
  % add horizontal space b/c dynamic alone won't create it
  \newSpacingSection
  \once \override Score.SpacingSpanner.spacing-increment = #2
  <d' g' c''>4\f
  \shiftToClear
  <d' g' c''>4\f
}



reply via email to

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