MIDI: fix regtest failure
[lilypond/patrick.git] / input / regression / incipit.ly
blob35af8f6b9fb621ef88912f52c19b929b98efc14c
1 \version "2.13.4"
3 \header {
4 texidoc = "Incipits can be printed using an @code{InstrumentName}
5 grob."
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)))
18 \score {
19 \new Staff {
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 =
25 #(lambda (grob)
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
34 'VerticalAxisGroup
35 'Y-extent '(-4 . 4))))
36 'MensuralStaff)
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)
43 (* incipit-width mm)
44 (* indent 0.5))))
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"
55 c'4 d' e' f'
56 g'1
58 \layout {
59 indent = 5\cm
60 incipit-width = 3\cm