4 texidoc
= "Incipits can be printed using an @code{InstrumentName}
8 %% to prevent warnings/programming errors:
9 #(set-object-property
! 'music
'backend-type? ly
:music?
)
10 #(set-object-property
! 'music
'backend-doc
"Incipit music")
11 #(ly
:add-interface
'incipit-interface
"An incipit." '(music
))
12 #(let
* ((instrument-def
(assoc
'InstrumentName all-grob-descriptions
))
13 (meta-def
(assoc
'meta
(cdr instrument-def
)))
14 (interfaces-def
(assoc
'interfaces
(cdr meta-def
)))
15 (interfaces
(cdr interfaces-def
)))
16 (set-cdr
! interfaces-def
(cons
'incipit-interface interfaces
)))
20 %% All this would be shortcuted by an appropriate music function:
21 \override Staff
.InstrumentName
#'music
= ##{ \clef "petrucci-c1" c'4 d' e' f' #}
22 \override Staff
.InstrumentName
#'self-alignment-X
= #RIGHT
23 \override Staff
.InstrumentName
#'padding
= #0
24 \override Staff
.InstrumentName
#'stencil
=
26 (let
* ((instrument-name
(ly
:grob-property grob
'long-text
))
27 (layout
(ly
:output-def-clone
(ly
:grob-layout grob
)))
28 (music
(make-sequential-music
29 (list
(context-spec-music
30 (make-sequential-music
31 (list
(make-property-set
32 'instrumentName instrument-name
)
33 (make-grob-property-set
35 'Y-extent
'(-
4 . 4))))
37 (ly
:grob-property grob
'music
))))
38 (score
(ly
:make-score music
))
39 (mm
(ly
:output-def-lookup layout
'mm
))
40 (indent
(ly
:output-def-lookup layout
'indent
))
41 (incipit-width
(ly
:output-def-lookup layout
'incipit-width
))
42 (scaled-incipit-width
(if
(number? incipit-width
)
45 (ly
:output-def-set-variable
! layout
'indent
(- indent scaled-incipit-width
))
46 (ly
:output-def-set-variable
! layout
'line-width indent
)
47 (ly
:output-def-set-variable
! layout
'ragged-right
#f)
48 (ly
:score-add-output-def
! score layout
)
49 (set
! (ly
:grob-property grob
'long-text
)
50 (markup
#:score score
))
51 (system-start-text
::print grob
)))
53 %% the instrument name definition is separated:
54 \set Staff
.instrumentName
= #"Instrument"