1 %% DO NOT EDIT this file manually; it is automatically
2 %% generated from LSR http://lsr.dsi.unimi.it
3 %% Make any changes in LSR itself, or in Documentation/snippets/new/ ,
4 %% and then run scripts/auxiliar/makelsr.py
6 %% This file is in the public domain.
10 lsrtags = "expressive-marks, really-cool, scheme-language, text"
13 This example provides a function to typeset a hairpin (de)crescendo
14 with some additional text below it, such as @qq{molto} or @qq{poco}.
15 The added text will change the direction according to the direction of
16 the hairpin. The Hairpin is aligned to DynamicText. The example also
17 illustrates how to modify the way an object is normally printed, using
21 doctitle = "Center text below hairpin dynamics"
24 hairpinWithCenteredText =
25 #(define-music-function (parser location text) (markup?)
27 \once \override Voice.Hairpin.after-line-breaking =
29 (let* ((stencil (ly:hairpin::print grob))
30 (par-y (ly:grob-parent grob Y))
31 (dir (ly:grob-property par-y 'direction))
32 (new-stencil (ly:stencil-aligned-to
33 (ly:stencil-combine-at-edge
34 (ly:stencil-aligned-to stencil X CENTER)
36 (ly:stencil-aligned-to (grob-interpret-markup grob text) X CENTER))
38 (staff-space (ly:output-def-lookup (ly:grob-layout grob) 'staff-space))
39 (staff-line-thickness (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
40 (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
41 (par-x (ly:grob-parent grob X))
42 (dyn-text (eq? (grob-name par-x) 'DynamicText ))
43 (dyn-text-stencil-x-length (if dyn-text
44 (interval-length (ly:stencil-extent (ly:grob-property par-x 'stencil) X))
46 (x-shift (if dyn-text (- (+ staff-space dyn-text-stencil-x-length) (* 0.5 staff-line-thickness)) 0)))
48 (ly:grob-set-property! grob 'Y-offset 0)
49 (ly:grob-set-property! grob 'stencil
50 (ly:stencil-translate-axis
56 \hairpinWithCenteredText \markup { \italic molto }
59 \hairpinWithCenteredText \markup { \larger moltissimo }
61 \layout { ragged-right = ##f }