Hi again,

below is a slight improvement of the previous version which saves you
from typing the whole function definition over and over again just to
change the markup text. The function 'hairpinWithCenteredText' takes a
single markup as argument. The usage should be straightforward (see the
example).

Max


%%% begin code %%%

hairpinWithCenteredText = #(define-music-function
                           (parser location text) (markup?)
#{
 \override Voice.Hairpin #'stencil = #(lambda (grob)
   (let ((ext (ly:stencil-extent (ly:hairpin::print grob) 0)))
      (ly:stencil-combine-at-edge
         (ly:stencil-aligned-to (ly:hairpin::print grob) 0 -1)
          1
         -1
          (ly:stencil-translate-axis
             (ly:stencil-aligned-to (ly:text-interface::print grob) 0 0)
             (/ (- (cdr ext) (car ext)) 2)
             0))))
        \override Voice.Hairpin #'text = $text
#})

hairpinMolto = \hairpinWithCenteredText \markup {\italic "molto"}
hairpinMore  = \hairpinWithCenteredText \markup {\bigger "moltissimo"}

\new Staff {
   \hairpinMolto c'2\< c'2\f
   \hairpinMore  c'2\< c'2\f
}

%%% end code %%%


_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to