Here is a compilable example.  It is a bit long, but I think it is
pretty close to minimal.

In its defence: the first 32 lines are, effectively, snippet 739
modified to produce "dynamic text" instead of "text dynamic" (in this
case, "mp dolce" instead of, say, "meno f").

The remaining few lines are one part from a very heavily redacted
movement of a quintet.



The unwelcome spacing between the 4th and 5th notes goes away if one:

      * transposes the second bar up an octave; or
      * comments out the key signature; or
      * comments out \new StaffGroup; or
      * uncomments the line containing DynamicLineSpanner.staff-padding

I think I can live with the final option, assuming I can localise the
staff-padding change when I apply it to the big score.  Problem solved;
sorry for the noise.

Here's the code, attached, in case either I'm missing something obvious,
or the modified snippet 739 is useful to someone.

-- Graham
\version "2.19.35"

%%%%%%%%%% The relevant parts of my modified version of snippet 739 %%%%%%%%%%
% calculate x-alignment based on attribute text + dynamic text
% this has to be a markup-command to get stencil-extent based on 
(interpret-markup layout props ...)
#(define-markup-command (center-dynatr layout props atr-text dyn)(markup? 
string?)
   "x-align on center of dynamic"
   (let* (
           (text (string-append " " atr-text ))
           (atr-stencil (interpret-markup layout props (markup #:normal-text 
#:italic text)))
           (dyn-stencil (interpret-markup layout props (markup #:dynamic dyn)))
           (atr-x-ext (ly:stencil-extent atr-stencil X))
           (dyn-x-ext (ly:stencil-extent dyn-stencil X))
           (atr-x (- (cdr atr-x-ext)(car atr-x-ext)))
           (dyn-x (- (cdr dyn-x-ext)(car dyn-x-ext)))
           (x-align
            (* (-
                (/ (/ dyn-x 2) (+ atr-x dyn-x) )
                0.5) 2)
            )
           )
     (interpret-markup layout props (markup #:halign x-align #:concat 
(#:dynamic dyn #:normal-text #:italic text)))
     ))
% define a 'new' attributed dynamic script
#(define (make-dynamic-atr-script dyn atr)
   (let ((dynamic (make-dynamic-script (markup #:center-dynatr atr dyn))))
     (ly:music-set-property! dynamic 'tweaks (acons 'X-offset 0 
(ly:music-property dynamic 'tweaks)))
     dynamic))

% define some attributed dynamics
mpdolce = #(make-dynamic-atr-script "mp" "dolce")
%%%%%%%%%% Modified version of snippet 739 (ends) %%%%%%%%%%

music = \new Voice {
  \relative {
    \clef bass
    \key es \major
    r2 r8 f8(\mpdolce e f) |
    %        \override DynamicLineSpanner.staff-padding = #2.5
    r2 r8 bes,8(\mpdolce a bes) |
  }
}

\score {
  \new StaffGroup
  \new Staff {
    \music
  }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to