1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 1998--2014 Jan Nieuwenhuizen <janneke@gnu.org>
4 ;;;; Han-Wen Nienhuys <hanwen@xs4all.nl>
6 ;;;; LilyPond is free software: you can redistribute it and/or modify
7 ;;;; it under the terms of the GNU General Public License as published by
8 ;;;; the Free Software Foundation, either version 3 of the License, or
9 ;;;; (at your option) any later version.
11 ;;;; LilyPond is distributed in the hope that it will be useful,
12 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;;; GNU General Public License for more details.
16 ;;;; You should have received a copy of the GNU General Public License
17 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
23 (define-public (grob::has-interface grob iface)
24 (memq iface (ly:grob-interfaces grob)))
26 (define-public (grob::is-live? grob)
27 (pair? (ly:grob-basic-properties grob)))
29 (define-public (make-stencil-boxer thickness padding callback)
30 "Return function that adds a box around the grob passed as argument."
32 (box-stencil (callback grob) thickness padding)))
34 (define-public (make-stencil-circler thickness padding callback)
35 "Return function that adds a circle around the grob passed as argument."
37 (circle-stencil (callback grob) thickness padding)))
39 (define-public (print-circled-text-callback grob)
40 (grob-interpret-markup grob (make-circle-markup
41 (ly:grob-property grob 'text))))
43 (define-public (event-cause grob)
44 (let ((cause (ly:grob-property grob 'cause)))
47 ((ly:stream-event? cause) cause)
48 ((ly:grob? cause) (event-cause cause))
51 (define-public (grob-interpret-markup grob text)
52 (let* ((layout (ly:grob-layout grob))
53 (defs (ly:output-def-lookup layout 'text-font-defaults))
54 (props (ly:grob-alist-chain grob defs)))
56 (ly:text-interface::interpret-markup layout props text)))
58 (define-public (grob::unpure-Y-extent-from-stencil pure-function)
59 "The unpure height will come from a stencil whereas the pure
60 height will come from @code{pure-function}."
61 (ly:make-unpure-pure-container ly:grob::stencil-height pure-function))
63 (define-public grob::unpure-horizontal-skylines-from-stencil
64 (ly:make-unpure-pure-container
65 ly:grob::horizontal-skylines-from-stencil
66 ly:grob::pure-simple-horizontal-skylines-from-extents))
68 (define-public grob::always-horizontal-skylines-from-stencil
69 (ly:make-unpure-pure-container
70 ly:grob::horizontal-skylines-from-stencil))
72 (define-public grob::unpure-vertical-skylines-from-stencil
73 (ly:make-unpure-pure-container
74 ly:grob::vertical-skylines-from-stencil
75 ly:grob::pure-simple-vertical-skylines-from-extents))
77 (define-public grob::always-vertical-skylines-from-stencil
78 (ly:make-unpure-pure-container
79 ly:grob::vertical-skylines-from-stencil))
81 (define-public grob::always-vertical-skylines-from-element-stencils
82 (ly:make-unpure-pure-container
83 ly:grob::vertical-skylines-from-element-stencils
84 ly:grob::pure-vertical-skylines-from-element-stencils))
86 (define-public grob::always-horizontal-skylines-from-element-stencils
87 (ly:make-unpure-pure-container
88 ly:grob::horizontal-skylines-from-element-stencils
89 ly:grob::pure-horizontal-skylines-from-element-stencils))
91 ;; Using this as a callback for a grob's Y-extent promises
92 ;; that the grob's stencil does not depend on line-spacing.
93 ;; We use this promise to figure the space required by Clefs
94 ;; and such at the note-spacing stage.
96 (define-public grob::always-Y-extent-from-stencil
97 (ly:make-unpure-pure-container ly:grob::stencil-height))
99 (define-public (layout-line-thickness grob)
100 "Get the line thickness of the @var{grob}'s corresponding layout."
101 (let* ((layout (ly:grob-layout grob))
102 (line-thickness (ly:output-def-lookup layout 'line-thickness)))
106 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
109 ;; even though kievan noteheads do not have stems, their
110 ;; invisible stems help with beam placement
111 ;; this assures that invisible stems for kievan notes are aligned
112 ;; to the center of kievan noteheads. that is thus where the beams'
113 ;; x extrema will fall
114 (define-public (stem::kievan-offset-callback grob)
115 (let* ((note-heads (ly:grob-object grob 'note-heads))
116 (note-heads-grobs (if (not (null? note-heads))
117 (ly:grob-array->list note-heads)
119 (first-note-head (if (not (null? note-heads-grobs))
120 (car note-heads-grobs)
122 (note-head-w (if (not (null? first-note-head))
123 (ly:grob-extent first-note-head first-note-head X)
125 (interval-center note-head-w)))
128 ;; sets position of beams for Kievan notation
129 (define-public (beam::get-kievan-positions grob)
130 (let* ((stems (ly:grob-object grob 'stems))
131 (stems-grobs (if (not (null? stems))
132 (ly:grob-array->list stems)
134 (first-stem (if (not (null? stems-grobs))
137 (note-heads (if (not (null? first-stem))
138 (ly:grob-object first-stem 'note-heads)
140 (note-heads-grobs (if (not (null? note-heads))
141 (ly:grob-array->list note-heads)
143 (first-note-head (if (not (null? note-heads-grobs))
144 (car note-heads-grobs)
146 (next-stem (if (not (null? stems))
149 (next-note-heads (if (not (null? next-stem))
150 (ly:grob-object next-stem 'note-heads)
152 (next-note-heads-grobs (if (not (null? next-note-heads))
153 (ly:grob-array->list next-note-heads)
155 (next-note-head (if (not (null? next-note-heads-grobs))
156 (car next-note-heads-grobs)
158 (left-pos (ly:grob-property first-note-head 'Y-offset))
159 (right-pos (ly:grob-property next-note-head 'Y-offset))
160 (direction (ly:grob-property grob 'direction))
161 (first-nh-height (ly:grob::stencil-height first-note-head))
162 (next-nh-height (ly:grob::stencil-height next-note-head))
163 (left-height (if (= direction DOWN)
164 (+ (car first-nh-height) 0.75)
165 (- (cdr first-nh-height) 0.75)))
166 (right-height (if (= direction DOWN)
167 (+ (car next-nh-height) 0.75)
168 (- (cdr next-nh-height) 0.75))))
169 (cons (+ left-pos left-height) (+ right-pos right-height))))
171 (define-public (beam::get-kievan-quantized-positions grob)
172 (let* ((pos (ly:grob-property grob 'positions))
173 (stems (ly:grob-object grob 'stems))
174 (stems-grobs (if (not (null? stems))
175 (ly:grob-array->list stems)
179 (ly:grob-set-property! g 'stem-begin-position 0)
180 (ly:grob-set-property! g 'length 0))
184 ;; calculates each slope of a broken beam individually
185 (define-public (beam::place-broken-parts-individually grob)
186 (ly:beam::quanting grob '(+inf.0 . -inf.0) #f))
188 ;; calculates the slope of a beam as a single unit,
189 ;; even if it is broken. this assures that the beam
190 ;; will pick up where it left off after a line break
191 (define-public (beam::align-with-broken-parts grob)
192 (ly:beam::quanting grob '(+inf.0 . -inf.0) #t))
194 ;; uses the broken beam style from edition peters combines the
195 ;; values of place-broken-parts-individually and align-with-broken-parts above,
196 ;; favoring place-broken-parts-individually when the beam naturally has a steeper
197 ;; incline and align-with-broken-parts when the beam is flat
198 (define-public (beam::slope-like-broken-parts grob)
200 (/ (- (cdr y) (car y)) (- (cdr x) (car x))))
201 (let* ((quant1 (ly:beam::quanting grob '(+inf.0 . -inf.0) #t))
202 (original (ly:grob-original grob))
203 (siblings (if (ly:grob? original)
204 (ly:spanner-broken-into original)
208 (let* ((quant2 (ly:beam::quanting grob '(+inf.0 . -inf.0) #f))
209 (x-span (ly:grob-property grob 'X-positions))
210 (slope1 (slope quant1 x-span))
211 (slope2 (slope quant2 x-span))
212 (quant2 (if (not (= (sign slope1) (sign slope2)))
215 (factor (/ (atan (abs slope1)) PI-OVER-TWO))
218 (+ (* (x quant1) (- 1 factor))
219 (* (x quant2) factor)))
221 (ly:beam::quanting grob base #f)))))
223 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
226 (define-public (script-or-side-position-cross-staff g)
228 (ly:script-interface::calc-cross-staff g)
229 (ly:side-position-interface::calc-cross-staff g)))
232 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
233 ;; side-position stuff
235 (define-public (only-if-beamed g)
236 (any (lambda (x) (ly:grob? (ly:grob-object x 'beam)))
237 (ly:grob-array->list (ly:grob-object g 'side-support-elements))))
239 (define-public side-position-interface::y-aligned-side
240 (ly:make-unpure-pure-container
241 ly:side-position-interface::y-aligned-side
242 ly:side-position-interface::pure-y-aligned-side))
244 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
245 ;; self-alignment stuff
247 (define-public self-alignment-interface::y-aligned-on-self
248 (ly:make-unpure-pure-container
249 ly:self-alignment-interface::y-aligned-on-self
250 ly:self-alignment-interface::pure-y-aligned-on-self))
252 (define-public (self-alignment-interface::self-aligned-on-breakable grob)
253 "Return the @code{X-offset} that places @var{grob} according to its
254 @code{self-alignment-X} over the reference point defined by the
255 @code{break-align-anchor-alignment} of a @code{break-aligned} item
256 such as a @code{Clef}."
257 (+ (ly:break-alignable-interface::self-align-callback grob)
258 (ly:self-alignment-interface::x-aligned-on-self grob)))
260 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
263 (define staff-symbol-referencer::callback
264 (ly:make-unpure-pure-container ly:staff-symbol-referencer::callback))
266 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
269 (define-public (stem::calc-duration-log grob)
271 (ly:event-property (event-cause grob) 'duration)))
273 (define (stem-stub::do-calculations grob)
274 (and (ly:grob-property (ly:grob-parent grob X) 'cross-staff)
275 (not (ly:grob-property (ly:grob-parent grob X) 'transparent))))
277 (define-public (stem-stub::pure-height grob beg end)
278 (if (stem-stub::do-calculations grob)
282 (define-public (stem-stub::width grob)
283 (if (stem-stub::do-calculations grob)
284 (grob::x-parent-width grob)
287 (define-public (stem-stub::extra-spacing-height grob)
288 (if (stem-stub::do-calculations grob)
289 (let* ((dad (ly:grob-parent grob X))
290 (refp (ly:grob-common-refpoint grob dad Y))
291 (stem_ph (ly:grob-pure-height dad refp 0 INFINITY-INT))
292 (my_ph (ly:grob-pure-height grob refp 0 INFINITY-INT))
293 ;; only account for distance if stem is on different staff than stub
294 (dist (if (grob::has-interface refp 'hara-kiri-group-spanner-interface)
296 (- (car my_ph) (car stem_ph)))))
297 (if (interval-empty? (interval-intersection stem_ph my_ph)) #f (coord-translate stem_ph dist)))
300 (define-public (note-head::calc-kievan-duration-log grob)
303 (ly:event-property (event-cause grob) 'duration))))
305 (define-public (note-head::calc-duration-log grob)
308 (ly:event-property (event-cause grob) 'duration))))
310 (define-public (dots::calc-dot-count grob)
311 (ly:duration-dot-count
312 (ly:event-property (event-cause grob) 'duration)))
314 (define-public (dots::calc-staff-position grob)
315 (let* ((head (ly:grob-parent grob Y))
316 (log (ly:grob-property head 'duration-log)))
319 ((or (not (grob::has-interface head 'rest-interface))
320 (not (integer? log))) 0)
328 ;; Kept separate from note-head::calc-glyph-name to allow use by
329 ;; markup commands \note and \note-by-number
330 (define-public (select-head-glyph style log)
331 "Select a note head glyph string based on note head style @var{style}
332 and duration-log @var{log}."
334 ;; "default" style is directly handled in note-head.cc as a
335 ;; special case (HW says, mainly for performance reasons).
336 ;; Therefore, style "default" does not appear in this case
338 ((xcircle) "2xcircle")
339 ((harmonic) "0harmonic")
340 ((harmonic-black) "2harmonic")
341 ((harmonic-mixed) (if (<= log 1) "0harmonic"
344 ;; Oops, I actually would not call this "baroque", but, for
345 ;; backwards compatibility to 1.4, this is supposed to take
346 ;; brevis, longa and maxima from the neo-mensural font and all
347 ;; other note heads from the default font. -- jr
349 (string-append (number->string log) "neomensural")
350 (number->string log)))
352 ;; Like default, but brevis is drawn with double vertical lines
354 (string-append (number->string log) "double")
355 (number->string log)))
357 (string-append (number->string log) (symbol->string style)))
360 (string-append (number->string log) "mensural")
361 (string-append (number->string log) (symbol->string style))))
364 (string-append (number->string log) "blackmensural")
365 (string-append (number->string log) (symbol->string style))))
368 (string-append (number->string log) "semimensural")
369 (string-append (number->string log) "petrucci")))
371 (string-append (number->string log) (symbol->string style)))
373 (string-append (number->string log) "kievan"))
375 (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
376 (symbol->string style)
377 (string-append (number->string (max 0 log))
378 (symbol->string style))))))
380 (define-public (note-head::calc-glyph-name grob)
381 (let* ((style (ly:grob-property grob 'style))
382 (log (if (string-match "kievan*" (symbol->string style))
383 (min 3 (ly:grob-property grob 'duration-log))
384 (min 2 (ly:grob-property grob 'duration-log)))))
385 (select-head-glyph style log)))
387 (define-public (note-head::brew-ez-stencil grob)
388 (let* ((log (ly:grob-property grob 'duration-log))
389 (pitch (ly:event-property (event-cause grob) 'pitch))
390 (pitch-index (ly:pitch-notename pitch))
391 (note-names (ly:grob-property grob 'note-names))
392 (pitch-string (if (and (vector? note-names)
393 (> (vector-length note-names) pitch-index))
394 (vector-ref note-names pitch-index)
397 (+ (modulo (+ pitch-index 2) 7)
398 (char->integer #\A))))))
399 (staff-space (ly:staff-symbol-staff-space grob))
400 (line-thickness (ly:staff-symbol-line-thickness grob))
401 (stem (ly:grob-object grob 'stem))
402 (stem-thickness (* (if (ly:grob? stem)
403 (ly:grob-property stem 'thickness)
406 (radius (/ (+ staff-space line-thickness) 2))
407 (letter (markup #:center-align #:vcenter pitch-string))
408 (filled-circle (markup #:draw-circle radius 0 #t)))
410 (ly:stencil-translate-axis
411 (grob-interpret-markup
416 (make-with-color-markup white letter))
420 (make-with-color-markup white (make-draw-circle-markup
421 (- radius stem-thickness) 0 #t)))
425 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
428 (define-public (make-rhythmic-location bar-num num den)
430 bar-num (ly:make-moment num den)))
432 (define-public (rhythmic-location? a)
435 (ly:moment? (cdr a))))
437 (define-public (make-graceless-rhythmic-location loc)
438 (make-rhythmic-location
440 (ly:moment-main-numerator (rhythmic-location-measure-position loc))
441 (ly:moment-main-denominator (rhythmic-location-measure-position loc))))
443 (define-public rhythmic-location-measure-position cdr)
444 (define-public rhythmic-location-bar-number car)
446 (define-public (rhythmic-location<? a b)
448 ((< (car a) (car b)) #t)
449 ((> (car a) (car b)) #f)
451 (ly:moment<? (cdr a) (cdr b)))))
453 (define-public (rhythmic-location<=? a b)
454 (not (rhythmic-location<? b a)))
455 (define-public (rhythmic-location>=? a b)
456 (not (rhythmic-location<? a b)))
457 (define-public (rhythmic-location>? a b)
458 (rhythmic-location<? b a))
460 (define-public (rhythmic-location=? a b)
461 (and (rhythmic-location<=? a b)
462 (rhythmic-location<=? b a)))
464 (define-public (rhythmic-location->file-string a)
465 (ly:format "~a.~a.~a"
467 (ly:moment-main-numerator (cdr a))
468 (ly:moment-main-denominator (cdr a))))
470 (define-public (rhythmic-location->string a)
471 (ly:format "bar ~a ~a"
473 (ly:moment->string (cdr a))))
475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
478 (define-public all-visible #(#t #t #t))
479 (define-public begin-of-line-invisible #(#t #t #f))
480 (define-public center-invisible #(#t #f #t))
481 (define-public end-of-line-invisible #(#f #t #t))
482 (define-public begin-of-line-visible #(#f #f #t))
483 (define-public center-visible #(#f #t #f))
484 (define-public end-of-line-visible #(#t #f #f))
485 (define-public all-invisible #(#f #f #f))
487 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
488 ;; neighbor-interface routines
491 (define-public (shift-right-at-line-begin g)
492 "Shift an item to the right, but only at the start of the line."
493 (if (and (ly:item? g)
494 (equal? (ly:item-break-dir g) RIGHT))
495 (ly:grob-translate-axis! g 3.5 X)))
497 (define-public (pure-from-neighbor-interface::extra-spacing-height-at-beginning-of-line grob)
498 (if (= 1 (ly:item-break-dir grob))
499 (pure-from-neighbor-interface::extra-spacing-height grob)
502 (define-public (pure-from-neighbor-interface::extra-spacing-height grob)
503 (let* ((height (ly:grob-pure-height grob grob 0 INFINITY-INT))
504 (from-neighbors (interval-union
506 (ly:axis-group-interface::pure-height
510 (coord-operation - from-neighbors height)))
512 ;; If there are neighbors, we place the height at their midpoint
513 ;; to avoid protrusion of this pure height out of the vertical
514 ;; axis group on either side. This will minimize the impact of the
515 ;; grob on pure minimum translations.
517 ;; TODO - there is a double call to axis-group-interface::pure-height
518 ;; here and then in the extra-spacing-height function above. Can/should this
519 ;; be rolled into one?
520 (define-public (pure-from-neighbor-interface::pure-height grob beg end)
521 (let* ((height (ly:axis-group-interface::pure-height
525 (c (interval-center height)))
526 (if (interval-empty? height) empty-interval (cons c c))))
528 ;; Minimizes the impact of the height on vertical spacing while allowing
529 ;; it to appear in horizontal skylines of paper columns if necessary.
530 (define-public pure-from-neighbor-interface::height-if-pure
531 (ly:make-unpure-pure-container #f pure-from-neighbor-interface::pure-height))
533 (define-public (pure-from-neighbor-interface::account-for-span-bar grob)
534 (let* ((esh (pure-from-neighbor-interface::extra-spacing-height grob))
535 (hsb (ly:grob-property grob 'has-span-bar))
536 (ii (interval-intersection esh (cons -1.01 1.01))))
538 (cons (car (if (and (car hsb)
539 (ly:grob-property grob 'allow-span-bar))
541 (cdr (if (cdr hsb) esh ii)))
544 (define-public (pure-from-neighbor-interface::extra-spacing-height-including-staff grob)
545 (let ((esh (pure-from-neighbor-interface::extra-spacing-height grob))
546 (to-staff (coord-operation -
549 (ly:staff-symbol-staff-radius grob))
550 (ly:grob::stencil-height grob))))
551 (interval-union esh to-staff)))
554 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
557 (define-public (tuplet-number::calc-direction grob)
558 (ly:tuplet-bracket::calc-direction (ly:grob-object grob 'bracket)))
560 (define-public (tuplet-number::calc-denominator-text grob)
561 (number->string (ly:event-property (event-cause grob) 'denominator)))
563 (define-public (tuplet-number::calc-fraction-text grob)
564 (let ((ev (event-cause grob)))
567 (ly:event-property ev 'denominator)
568 (ly:event-property ev 'numerator))))
570 ;; a formatter function, which is simply a wrapper around an existing
571 ;; tuplet formatter function. It takes the value returned by the given
572 ;; function and appends a note of given length.
573 (define ((tuplet-number::append-note-wrapper function note) grob)
574 (let ((txt (if function (function grob) #f)))
577 (markup txt #:fontsize -5 #:note note UP)
578 (markup #:fontsize -5 #:note note UP))))
579 (export tuplet-number::append-note-wrapper)
581 ;; Print a tuplet denominator with a different number than the one derived from
582 ;; the actual tuplet fraction
583 (define ((tuplet-number::non-default-tuplet-denominator-text denominator)
585 (number->string (if denominator
587 (ly:event-property (event-cause grob) 'denominator))))
588 (export tuplet-number::non-default-tuplet-denominator-text)
590 ;; Print a tuplet fraction with different numbers than the ones derived from
591 ;; the actual tuplet fraction
592 (define ((tuplet-number::non-default-tuplet-fraction-text
593 denominator numerator) grob)
594 (let* ((ev (event-cause grob))
595 (den (if denominator denominator (ly:event-property ev 'denominator)))
596 (num (if numerator numerator (ly:event-property ev 'numerator))))
598 (format #f "~a:~a" den num)))
599 (export tuplet-number::non-default-tuplet-fraction-text)
601 ;; Print a tuplet fraction with note durations appended to the numerator and the
603 (define ((tuplet-number::fraction-with-notes
604 denominatornote numeratornote) grob)
605 (let* ((ev (event-cause grob))
606 (denominator (ly:event-property ev 'denominator))
607 (numerator (ly:event-property ev 'numerator)))
609 ((tuplet-number::non-default-fraction-with-notes
610 denominator denominatornote numerator numeratornote) grob)))
611 (export tuplet-number::fraction-with-notes)
613 ;; Print a tuplet fraction with note durations appended to the numerator and the
615 (define ((tuplet-number::non-default-fraction-with-notes
616 denominator denominatornote numerator numeratornote) grob)
617 (let* ((ev (event-cause grob))
618 (den (if denominator denominator (ly:event-property ev 'denominator)))
619 (num (if numerator numerator (ly:event-property ev 'numerator))))
621 (make-concat-markup (list
622 (make-simple-markup (format #f "~a" den))
623 (markup #:fontsize -5 #:note denominatornote UP)
624 (make-simple-markup " : ")
625 (make-simple-markup (format #f "~a" num))
626 (markup #:fontsize -5 #:note numeratornote UP)))))
627 (export tuplet-number::non-default-fraction-with-notes)
630 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
633 (define-public (color? x)
637 (every (lambda (y) (<= 0 y 1)) x)))
639 (define-public (rgb-color r g b) (list r g b))
642 (define-public black '(0.0 0.0 0.0))
643 (define-public white '(1.0 1.0 1.0))
644 (define-public red '(1.0 0.0 0.0))
645 (define-public green '(0.0 1.0 0.0))
646 (define-public blue '(0.0 0.0 1.0))
647 (define-public cyan '(0.0 1.0 1.0))
648 (define-public magenta '(1.0 0.0 1.0))
649 (define-public yellow '(1.0 1.0 0.0))
651 (define-public grey '(0.5 0.5 0.5))
652 (define-public darkred '(0.5 0.0 0.0))
653 (define-public darkgreen '(0.0 0.5 0.0))
654 (define-public darkblue '(0.0 0.0 0.5))
655 (define-public darkcyan '(0.0 0.5 0.5))
656 (define-public darkmagenta '(0.5 0.0 0.5))
657 (define-public darkyellow '(0.5 0.5 0.0))
660 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
663 (define-public (key-signature-interface::alteration-positions
664 entry c0-position grob)
665 (let ((step (car entry))
668 (list (+ (cdr step) (* (car step) 7) c0-position))
669 (let* ((c-position (modulo c0-position 7))
672 ;; See (flat|sharp)-positions in define-grob-properties.scm
673 (ly:grob-property grob 'flat-positions '(3))
674 (ly:grob-property grob 'sharp-positions '(3))))
675 (p (list-ref positions
676 (if (< c-position (length positions))
678 (max-position (if (pair? p) (cdr p) p))
679 (min-position (if (pair? p) (car p) (- max-position 6)))
680 (first-position (+ (modulo (- (+ c-position step)
684 (define (prepend x l) (if (> x max-position)
686 (prepend (+ x 7) (cons x l))))
687 (prepend first-position '())))))
689 (define-public (key-signature-interface::alteration-position
690 step alter c0-position)
691 ;; Deprecated. Not a documented interface, and no longer used in LilyPond,
692 ;; but needed for a popular file, LilyJAZZ.ily for version 2.16
694 (+ (cdr step) (* (car step) 7) c0-position)
695 (let* ((c-pos (modulo c0-position 7))
698 '(2 3 4 2 1 2 1) ; position of highest flat
699 '(4 5 4 2 3 2 3)); position of highest sharp
701 (- hi (modulo (- hi (+ c-pos step)) 7)))))
703 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
706 (define-public (numbered-footnotes int)
707 (markup #:tiny (number->string (+ 1 int))))
709 (define-public (symbol-footnotes int)
710 (define (helper symbols out idx n)
714 (string-append out (list-ref symbols idx))
717 (markup #:tiny (helper '("*" "†" "‡" "§" "¶")
720 (+ 1 (quotient int 5)))))
722 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
725 (define-public (accidental-interface::calc-alteration grob)
726 (ly:pitch-alteration (ly:event-property (event-cause grob) 'pitch)))
728 (define-public (accidental-interface::glyph-name grob)
729 (assoc-get (ly:grob-property grob 'alteration)
730 standard-alteration-glyph-name-alist))
732 (define-public accidental-interface::height
733 (ly:make-unpure-pure-container
734 ly:accidental-interface::height))
736 (define-public cancellation-glyph-name-alist
737 '((0 . "accidentals.natural")))
739 (define-public standard-alteration-glyph-name-alist
741 ;; ordered for optimal performance.
742 (0 . "accidentals.natural")
743 (-1/2 . "accidentals.flat")
744 (1/2 . "accidentals.sharp")
746 (1 . "accidentals.doublesharp")
747 (-1 . "accidentals.flatflat")
749 (3/4 . "accidentals.sharp.slashslash.stemstemstem")
750 (1/4 . "accidentals.sharp.slashslash.stem")
751 (-1/4 . "accidentals.mirroredflat")
752 (-3/4 . "accidentals.mirroredflat.flat")))
754 ;; FIXME: standard vs default, alteration-FOO vs FOO-alteration
755 (define-public alteration-default-glyph-name-alist
756 standard-alteration-glyph-name-alist)
758 (define-public makam-alteration-glyph-name-alist
759 '((1 . "accidentals.doublesharp")
760 (8/9 . "accidentals.sharp.slashslashslash.stemstem")
761 (5/9 . "accidentals.sharp.slashslashslash.stem")
762 (4/9 . "accidentals.sharp")
763 (1/9 . "accidentals.sharp.slashslash.stem")
764 (0 . "accidentals.natural")
765 (-1/9 . "accidentals.mirroredflat")
766 (-4/9 . "accidentals.flat.slash")
767 (-5/9 . "accidentals.flat")
768 (-8/9 . "accidentals.flat.slashslash")
769 (-1 . "accidentals.flatflat")))
771 (define-public alteration-hufnagel-glyph-name-alist
772 '((-1/2 . "accidentals.hufnagelM1")
773 (0 . "accidentals.vaticana0")
774 (1/2 . "accidentals.mensural1")))
776 (define-public alteration-medicaea-glyph-name-alist
777 '((-1/2 . "accidentals.medicaeaM1")
778 (0 . "accidentals.vaticana0")
779 (1/2 . "accidentals.mensural1")))
781 (define-public alteration-vaticana-glyph-name-alist
782 '((-1/2 . "accidentals.vaticanaM1")
783 (0 . "accidentals.vaticana0")
784 (1/2 . "accidentals.mensural1")))
786 (define-public alteration-mensural-glyph-name-alist
787 '((-1/2 . "accidentals.mensuralM1")
788 (0 . "accidentals.vaticana0")
789 (1/2 . "accidentals.mensural1")))
791 (define-public alteration-kievan-glyph-name-alist
792 '((-1/2 . "accidentals.kievanM1")
793 (1/2 . "accidentals.kievan1")))
795 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
796 ;; * Pitch Trill Heads
799 (define-public (parentheses-item::calc-parenthesis-stencils grob)
800 (let* ((font (ly:grob-default-font grob))
801 (lp (ly:font-get-glyph font "accidentals.leftparen"))
802 (rp (ly:font-get-glyph font "accidentals.rightparen")))
806 (define-public (parentheses-item::calc-angled-bracket-stencils grob)
807 (let* ((parent (ly:grob-parent grob Y))
808 (y-extent (ly:grob-extent parent parent Y))
809 (half-thickness 0.05) ; should it be a property?
810 (width 0.5) ; should it be a property?
811 (angularity 1.5) ; makes angle brackets
812 (white-padding 0.1) ; should it be a property?
813 (lp (ly:stencil-aligned-to
814 (ly:stencil-aligned-to
815 (make-parenthesis-stencil y-extent
822 (interval-widen (ly:stencil-extent lp X) white-padding))
823 (rp (ly:stencil-aligned-to
824 (ly:stencil-aligned-to
825 (make-parenthesis-stencil y-extent
832 (interval-widen (ly:stencil-extent rp X) white-padding)))
833 (set! lp (ly:make-stencil (ly:stencil-expr lp)
835 (ly:stencil-extent lp Y)))
836 (set! rp (ly:make-stencil (ly:stencil-expr rp)
838 (ly:stencil-extent rp Y)))
839 (list (stencil-whiteout lp)
840 (stencil-whiteout rp))))
842 (define (parenthesize-elements grob . rest)
843 (let* ((refp (if (null? rest)
846 (elts (ly:grob-object grob 'elements))
847 (x-ext (ly:relative-group-extent elts refp X))
848 (stencils (ly:grob-property grob 'stencils))
851 (padding (ly:grob-property grob 'padding 0.1)))
854 (ly:stencil-translate-axis lp (- (car x-ext) padding) X)
855 (ly:stencil-translate-axis rp (+ (cdr x-ext) padding) X))))
858 (define-public (parentheses-item::print me)
859 (let* ((elts (ly:grob-object me 'elements))
860 (y-ref (ly:grob-common-refpoint-of-array me elts Y))
861 (x-ref (ly:grob-common-refpoint-of-array me elts X))
862 (stencil (parenthesize-elements me x-ref))
863 (elt-y-ext (ly:relative-group-extent elts y-ref Y))
864 (y-center (interval-center elt-y-ext)))
866 (ly:stencil-translate
869 (- (ly:grob-relative-coordinate me x-ref X))
870 (- y-center (ly:grob-relative-coordinate me y-ref Y))))))
873 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
876 (define-public (pure-chain-offset-callback grob start end prev-offset)
877 "Sometimes, a chained offset callback is unpure and there is
878 no way to write a pure function that estimates its behavior.
879 In this case, we use a pure equivalent that will simply pass
880 the previous calculated offset value."
883 (define-public (scale-by-font-size x)
884 (ly:make-unpure-pure-container
886 (* x (magstep (ly:grob-property grob 'font-size 0))))))
888 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
891 (define-public (chain-grob-member-functions grob value . funcs)
894 (set! value (func grob value)))
900 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
903 (define-public (bend::print spanner)
905 (< (abs (- a b)) 0.01))
907 (let* ((delta-y (* 0.5 (ly:grob-property spanner 'delta-position)))
908 (left-span (ly:spanner-bound spanner LEFT))
909 (dots (if (and (grob::has-interface left-span 'note-head-interface)
910 (ly:grob? (ly:grob-object left-span 'dot)))
911 (ly:grob-object left-span 'dot) #f))
913 (right-span (ly:spanner-bound spanner RIGHT))
914 (thickness (* (ly:grob-property spanner 'thickness)
915 (ly:output-def-lookup (ly:grob-layout spanner)
917 (padding (ly:grob-property spanner 'padding 0.5))
918 (common (ly:grob-common-refpoint right-span
919 (ly:grob-common-refpoint spanner
922 (common-y (ly:grob-common-refpoint spanner left-span Y))
923 (minimum-length (ly:grob-property spanner 'minimum-length 0.5))
927 (interval-end (ly:generic-bound-extent
932 (ly:grob-relative-coordinate dots common-y Y)
933 (ly:grob-relative-coordinate spanner common-y Y)))
935 (ly:grob-robust-relative-extent dots common X))
937 (right-x (max (- (interval-start
938 (ly:generic-bound-extent right-span common))
940 (+ left-x minimum-length)))
941 (self-x (ly:grob-relative-coordinate spanner common X))
942 (dx (- right-x left-x))
943 (exp (list 'path thickness
951 ,dx ,(* 0.66 delta-y)
956 (cons (- left-x self-x) (- right-x self-x))
957 (cons (min 0 delta-y)
961 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
964 (define-public (grace-spacing::calc-shortest-duration grob)
965 (let* ((cols (ly:grob-object grob 'columns))
968 (ly:moment-sub (ly:grob-property
969 (ly:grob-array-ref cols (1+ idx)) 'when)
971 (ly:grob-array-ref cols idx) 'when))))
973 (moment-min (lambda (x y)
976 (if (ly:moment<? x y)
982 (fold moment-min #f (map get-difference
983 (iota (1- (ly:grob-array-length cols)))))))
986 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
989 (define-public (fingering::calc-text grob)
990 (let ((event (event-cause grob)))
991 (or (ly:event-property event 'text #f)
992 (number->string (ly:event-property event 'digit) 10))))
994 (define-public (string-number::calc-text grob)
995 (let ((event (event-cause grob)))
996 (or (ly:event-property event 'text #f)
997 (number->string (ly:event-property event 'string-number) 10))))
999 (define-public (stroke-finger::calc-text grob)
1000 (let ((event (event-cause grob)))
1001 (or (ly:event-property event 'text #f)
1002 (vector-ref (ly:grob-property grob 'digit-names)
1004 (min 5 (ly:event-property event 'digit))))))))
1007 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1010 (define-public (hairpin::calc-grow-direction grob)
1011 (if (ly:in-event-class? (event-cause grob) 'decrescendo-event)
1015 (define-public (dynamic-text-spanner::before-line-breaking grob)
1016 "Monitor left bound of @code{DynamicTextSpanner} for absolute dynamics.
1017 If found, ensure @code{DynamicText} does not collide with spanner text by
1018 changing @code{'attach-dir} and @code{'padding}. Reads the
1019 @code{'right-padding} property of @code{DynamicText} to fine tune space
1020 between the two text elements."
1021 (let ((left-bound (ly:spanner-bound grob LEFT)))
1022 (if (grob::has-interface left-bound 'dynamic-text-interface)
1023 (let* ((details (ly:grob-property grob 'bound-details))
1024 (left-details (ly:assoc-get 'left details))
1025 (my-padding (ly:assoc-get 'padding left-details))
1026 (script-padding (ly:grob-property left-bound 'right-padding 0)))
1028 (and (number? my-padding)
1029 (ly:grob-set-nested-property! grob
1030 '(bound-details left attach-dir)
1032 (ly:grob-set-nested-property! grob
1033 '(bound-details left padding)
1034 (+ my-padding script-padding)))))))
1036 (define ((elbowed-hairpin coords mirrored?) grob)
1037 "Create hairpin based on a list of @var{coords} in @code{(cons x y)}
1038 form. @code{x} is the portion of the width consumed for a given line
1039 and @code{y} is the portion of the height. For example,
1040 @code{'((0.3 . 0.7) (0.8 . 0.9) (1.0 . 1.0))} means that at the point
1041 where the hairpin has consumed 30% of its width, it must
1042 be at 70% of its height. Once it is to 80% width, it
1043 must be at 90% height. It finishes at
1044 100% width and 100% height. @var{mirrored?} indicates if the hairpin
1045 is mirrored over the Y-axis or if just the upper part is drawn.
1046 Returns a function that accepts a hairpin grob as an argument
1047 and draws the stencil based on its coordinates.
1048 @lilypond[verbatim,quote]
1049 #(define simple-hairpin
1050 (elbowed-hairpin '((1.0 . 1.0)) #t))
1053 \\override Hairpin #'stencil = #simple-hairpin
1058 (define (pair-to-list pair)
1059 (list (car pair) (cdr pair)))
1060 (define (normalize-coords goods x y)
1063 (cons (* x (car coord)) (* y (cdr coord))))
1065 (define (my-c-p-s points thick decresc?)
1066 (make-connected-path-stencil
1069 (if decresc? -1.0 1.0)
1073 ;; outer let to trigger suicide
1074 (let ((sten (ly:hairpin::print grob)))
1075 (if (grob::is-live? grob)
1076 (let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
1077 (thick (ly:grob-property grob 'thickness 0.1))
1078 (thick (* thick (layout-line-thickness grob)))
1079 (xex (ly:stencil-extent sten X))
1080 (lenx (interval-length xex))
1081 (yex (ly:stencil-extent sten Y))
1082 (leny (interval-length yex))
1083 (xtrans (+ (car xex) (if decresc? lenx 0)))
1085 (uplist (map pair-to-list
1086 (normalize-coords coords lenx (/ leny 2))))
1087 (downlist (map pair-to-list
1088 (normalize-coords coords lenx (/ leny -2)))))
1089 (ly:stencil-translate
1091 (my-c-p-s uplist thick decresc?)
1092 (if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil))
1093 (cons xtrans ytrans)))
1095 (export elbowed-hairpin)
1097 (define-public flared-hairpin
1098 (elbowed-hairpin '((0.95 . 0.4) (1.0 . 1.0)) #t))
1100 (define-public constante-hairpin
1101 (elbowed-hairpin '((1.0 . 0.0) (1.0 . 1.0)) #f))
1103 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1106 (define-public (lyric-text::print grob)
1107 "Allow interpretation of tildes as lyric tieing marks."
1109 (let ((text (ly:grob-property grob 'text)))
1111 (grob-interpret-markup grob (if (string? text)
1112 (make-tied-lyric-markup text)
1115 (define ((grob::calc-property-by-copy prop) grob)
1116 (ly:event-property (event-cause grob) prop))
1117 (export grob::calc-property-by-copy)
1119 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1120 ;; general inheritance
1122 (define ((grob::inherit-parent-property axis property . default) grob)
1123 "@var{grob} callback generator for inheriting a @var{property} from
1124 an @var{axis} parent, defaulting to @var{default} if there is no
1125 parent or the parent has no setting."
1126 (let ((parent (ly:grob-parent grob axis)))
1129 (apply ly:grob-property parent property default))
1130 ((pair? default) (car default))
1132 (export grob::inherit-parent-property)
1134 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1137 (define-public (fret-board::calc-stencil grob)
1138 (grob-interpret-markup
1140 (make-fret-diagram-verbose-markup
1141 (ly:grob-property grob 'dot-placement-list))))
1144 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1147 (define-public slur::height
1148 (ly:make-unpure-pure-container
1150 ly:slur::pure-height))
1152 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1155 (define-public (script-interface::calc-x-offset grob)
1156 (ly:grob-property grob 'positioning-done)
1157 (let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
1159 (ly:self-alignment-interface::aligned-on-x-parent grob))
1160 (note-head-grob (ly:grob-parent grob X))
1161 (stem-grob (ly:grob-object note-head-grob 'stem)))
1163 (+ note-head-location
1164 ;; If the property 'toward-stem-shift is defined and the script
1165 ;; has the same direction as the stem, move the script accordingly.
1166 ;; Since scripts can also be over skips, we need to check whether
1167 ;; the grob has a stem at all.
1168 (if (ly:grob? stem-grob)
1169 (let ((dir1 (ly:grob-property grob 'direction))
1170 (dir2 (ly:grob-property stem-grob 'direction)))
1171 (if (equal? dir1 dir2)
1172 (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
1174 (ly:grob-relative-coordinate stem-grob common-refp X)))
1175 (* shift (- stem-location note-head-location)))
1180 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1183 (define-public (system-start-text::print grob)
1184 (let* ((left-bound (ly:spanner-bound grob LEFT))
1185 (left-mom (ly:grob-property left-bound 'when))
1186 (name (if (moment<=? left-mom ZERO-MOMENT)
1187 (ly:grob-property grob 'long-text)
1188 (ly:grob-property grob 'text))))
1190 (if (and (markup? name)
1191 (!= (ly:item-break-dir left-bound) CENTER))
1193 (grob-interpret-markup grob name)
1194 (ly:grob-suicide! grob))))
1196 (define-public (system-start-text::calc-x-offset grob)
1197 (let* ((left-bound (ly:spanner-bound grob LEFT))
1198 (left-mom (ly:grob-property left-bound 'when))
1199 (layout (ly:grob-layout grob))
1200 (indent (ly:output-def-lookup layout
1201 (if (moment<=? left-mom ZERO-MOMENT)
1205 (system (ly:grob-system grob))
1206 (my-extent (ly:grob-extent grob system X))
1207 (elements (ly:grob-object system 'elements))
1208 (common (ly:grob-common-refpoint-of-array system elements X))
1209 (total-ext empty-interval)
1210 (align-x (ly:grob-property grob 'self-alignment-X 0))
1211 (padding (min 0 (- (interval-length my-extent) indent)))
1212 (right-padding (- padding
1213 (/ (* padding (1+ align-x)) 2))))
1215 ;; compensate for the variation in delimiter extents by
1216 ;; calculating an X-offset correction based on united extents
1217 ;; of all delimiters in this system
1218 (let unite-delims ((l (ly:grob-array-length elements)))
1220 (let ((elt (ly:grob-array-ref elements (1- l))))
1222 (if (grob::has-interface elt 'system-start-delimiter-interface)
1223 (let ((dims (ly:grob-extent elt common X)))
1224 (if (interval-sane? dims)
1225 (set! total-ext (interval-union total-ext dims)))))
1226 (unite-delims (1- l)))))
1229 (ly:side-position-interface::x-aligned-side grob)
1231 (- (interval-length total-ext)))))
1233 (define-public (system-start-text::calc-y-offset grob)
1235 (define (live-elements-list me)
1236 (let ((elements (ly:grob-object me 'elements)))
1238 (filter! grob::is-live?
1239 (ly:grob-array->list elements))))
1241 (let* ((left-bound (ly:spanner-bound grob LEFT))
1242 (live-elts (live-elements-list grob))
1243 (system (ly:grob-system grob))
1244 (extent empty-interval))
1246 (if (and (pair? live-elts)
1247 (interval-sane? (ly:grob-extent grob system Y)))
1248 (let get-extent ((lst live-elts))
1250 (let ((axis-group (car lst)))
1252 (if (and (ly:spanner? axis-group)
1253 (equal? (ly:spanner-bound axis-group LEFT)
1255 (set! extent (add-point extent
1256 (ly:grob-relative-coordinate
1257 axis-group system Y))))
1258 (get-extent (cdr lst)))))
1259 ;; no live axis group(s) for this instrument name -> remove from system
1260 (ly:grob-suicide! grob))
1263 (ly:self-alignment-interface::y-aligned-on-self grob)
1264 (interval-center extent))))
1267 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1268 ;; axis group interface
1270 (define-public axis-group-interface::height
1271 (ly:make-unpure-pure-container
1272 ly:axis-group-interface::height
1273 ly:axis-group-interface::pure-height))
1275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1278 ;; Calculate the gaps between ambitus heads and ends of ambitus line.
1279 ;; Start by determining desired length of the ambitus line (based on
1280 ;; length-fraction property), calc gap from that and make sure that
1281 ;; it doesn't exceed maximum allowed value.
1283 (define-public (ambitus-line::calc-gap grob)
1284 (let ((heads (ly:grob-object grob 'note-heads)))
1286 (if (and (ly:grob-array? heads)
1287 (= (ly:grob-array-length heads) 2))
1288 (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
1289 (head-down (ly:grob-array-ref heads 0))
1290 (head-up (ly:grob-array-ref heads 1))
1291 (fraction (ly:grob-property grob 'length-fraction 0.7))
1292 (max-gap (ly:grob-property grob 'maximum-gap 0.45))
1293 ;; distance between noteheads:
1294 (distance (- (interval-start (ly:grob-extent head-up common Y))
1295 (interval-end (ly:grob-extent head-down common Y))))
1296 (gap (* 0.5 distance (- 1 fraction))))
1301 ;; Print a line connecting ambitus heads:
1303 (define-public (ambitus::print grob)
1304 (let ((heads (ly:grob-object grob 'note-heads)))
1306 (if (and (ly:grob-array? heads)
1307 (= (ly:grob-array-length heads) 2))
1308 (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
1309 (head-down (ly:grob-array-ref heads 0))
1310 (head-up (ly:grob-array-ref heads 1))
1311 ;; The value used when 'gap' property cannot be read is small
1312 ;; to make sure that ambitus of a fifth will have a visible line.
1313 (gap (ly:grob-property grob 'gap 0.25))
1314 (point-min (+ (interval-end (ly:grob-extent head-down common Y))
1316 (point-max (- (interval-start (ly:grob-extent head-up common Y))
1319 (if (< (+ point-min 0.1) point-max) ; don't print lines shorter than 0.1ss
1320 (let* ((layout (ly:grob-layout grob))
1321 (line-thick (ly:output-def-lookup layout 'line-thickness))
1322 (blot (ly:output-def-lookup layout 'blot-diameter))
1323 (grob-thick (ly:grob-property grob 'thickness 2))
1324 (width (* line-thick grob-thick))
1325 (x-ext (symmetric-interval (/ width 2)))
1326 (y-ext (cons point-min point-max))
1327 (line (ly:round-filled-box x-ext y-ext blot))
1328 (y-coord (ly:grob-relative-coordinate grob common Y)))
1330 (ly:stencil-translate-axis line (- y-coord) Y))
1333 (ly:grob-suicide! grob)
1336 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1337 ;; laissez-vibrer tie
1339 ;; needed so we can make laissez-vibrer a pure print
1341 (define-public (laissez-vibrer::print grob)
1342 (ly:tie::print grob))
1344 (define-public (semi-tie::calc-cross-staff grob)
1345 (let* ((note-head (ly:grob-object grob 'note-head))
1346 (stem (ly:grob-object note-head 'stem)))
1347 (and (ly:grob? stem)
1348 (ly:grob-property stem 'cross-staff #f))))
1350 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1353 (define-public (volta-bracket-interface::pure-height grob start end)
1354 (let ((edge-height (ly:grob-property grob 'edge-height)))
1355 (if (number-pair? edge-height)
1356 (let ((smaller (min (car edge-height) (cdr edge-height)))
1357 (larger (max (car edge-height) (cdr edge-height))))
1358 (interval-union '(0 . 0) (cons smaller larger)))