;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; self-alignment stuff
(define-public self-alignment-interface::y-aligned-on-self
(ly:make-unpure-pure-container
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; self-alignment stuff
(define-public self-alignment-interface::y-aligned-on-self
(ly:make-unpure-pure-container
((baroque)
;; Oops, I actually would not call this "baroque", but, for
;; backwards compatibility to 1.4, this is supposed to take
;; brevis, longa and maxima from the neo-mensural font and all
;; other note heads from the default font. -- jr
(if (< log 0)
((baroque)
;; Oops, I actually would not call this "baroque", but, for
;; backwards compatibility to 1.4, this is supposed to take
;; brevis, longa and maxima from the neo-mensural font and all
;; other note heads from the default font. -- jr
(if (< log 0)
((neomensural)
(string-append (number->string log) (symbol->string style)))
((kievan)
(string-append (number->string log) "kievan"))
(else
(if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
((neomensural)
(string-append (number->string log) (symbol->string style)))
((kievan)
(string-append (number->string log) "kievan"))
(else
(if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
- (log (if (string-match "kievan*" (symbol->string style))
- (min 3 (ly:grob-property grob 'duration-log))
- (min 2 (ly:grob-property grob 'duration-log)))))
+ (log (if (string-match "kievan*" (symbol->string style))
+ (min 3 (ly:grob-property grob 'duration-log))
+ (min 2 (ly:grob-property grob 'duration-log)))))
(select-head-glyph style log)))
(define-public (note-head::brew-ez-stencil grob)
(let* ((log (ly:grob-property grob 'duration-log))
(select-head-glyph style log)))
(define-public (note-head::brew-ez-stencil grob)
(let* ((log (ly:grob-property grob 'duration-log))
- (pitch (ly:event-property (event-cause grob) 'pitch))
- (pitch-index (ly:pitch-notename pitch))
- (note-names (ly:grob-property grob 'note-names))
- (pitch-string (if (and (vector? note-names)
- (> (vector-length note-names) pitch-index))
- (vector-ref note-names pitch-index)
- (string
- (integer->char
- (+ (modulo (+ pitch-index 2) 7)
- (char->integer #\A))))))
- (staff-space (ly:staff-symbol-staff-space grob))
- (line-thickness (ly:staff-symbol-line-thickness grob))
- (stem (ly:grob-object grob 'stem))
- (stem-thickness (* (if (ly:grob? stem)
- (ly:grob-property stem 'thickness)
- 1.3)
- line-thickness))
- (radius (/ (+ staff-space line-thickness) 2))
- (letter (markup #:center-align #:vcenter pitch-string))
- (filled-circle (markup #:draw-circle radius 0 #t)))
+ (pitch (ly:event-property (event-cause grob) 'pitch))
+ (pitch-index (ly:pitch-notename pitch))
+ (note-names (ly:grob-property grob 'note-names))
+ (pitch-string (if (and (vector? note-names)
+ (> (vector-length note-names) pitch-index))
+ (vector-ref note-names pitch-index)
+ (string
+ (integer->char
+ (+ (modulo (+ pitch-index 2) 7)
+ (char->integer #\A))))))
+ (staff-space (ly:staff-symbol-staff-space grob))
+ (line-thickness (ly:staff-symbol-line-thickness grob))
+ (stem (ly:grob-object grob 'stem))
+ (stem-thickness (* (if (ly:grob? stem)
+ (ly:grob-property stem 'thickness)
+ 1.3)
+ line-thickness))
+ (radius (/ (+ staff-space line-thickness) 2))
+ (letter (markup #:center-align #:vcenter pitch-string))
+ (filled-circle (markup #:draw-circle radius 0 #t)))
- (make-combine-markup
- filled-circle
- (make-with-color-markup white letter))
- (make-combine-markup
- (make-combine-markup
- filled-circle
- (make-with-color-markup white (make-draw-circle-markup
- (- radius stem-thickness) 0 #t)))
- letter)))
+ (make-combine-markup
+ filled-circle
+ (make-with-color-markup white letter))
+ (make-combine-markup
+ (make-combine-markup
+ filled-circle
+ (make-with-color-markup white (make-draw-circle-markup
+ (- radius stem-thickness) 0 #t)))
+ letter)))
(define-public (pure-from-neighbor-interface::extra-spacing-height grob)
(let* ((height (ly:grob-pure-height grob grob 0 INFINITY-INT))
(from-neighbors (interval-union
(define-public (pure-from-neighbor-interface::extra-spacing-height grob)
(let* ((height (ly:grob-pure-height grob grob 0 INFINITY-INT))
(from-neighbors (interval-union
;; Print a tuplet denominator with a different number than the one derived from
;; the actual tuplet fraction
(define-public ((tuplet-number::non-default-tuplet-denominator-text denominator)
;; Print a tuplet denominator with a different number than the one derived from
;; the actual tuplet fraction
(define-public ((tuplet-number::non-default-tuplet-denominator-text denominator)
;; Print a tuplet fraction with different numbers than the ones derived from
;; the actual tuplet fraction
(define-public ((tuplet-number::non-default-tuplet-fraction-text
;; Print a tuplet fraction with different numbers than the ones derived from
;; the actual tuplet fraction
(define-public ((tuplet-number::non-default-tuplet-fraction-text
(let* ((ev (event-cause grob))
(den (if denominator denominator (ly:event-property ev 'denominator)))
(num (if numerator numerator (ly:event-property ev 'numerator))))
(let* ((ev (event-cause grob))
(den (if denominator denominator (ly:event-property ev 'denominator)))
(num (if numerator numerator (ly:event-property ev 'numerator))))
(let* ((ev (event-cause grob))
(denominator (ly:event-property ev 'denominator))
(numerator (ly:event-property ev 'numerator)))
(let* ((ev (event-cause grob))
(denominator (ly:event-property ev 'denominator))
(numerator (ly:event-property ev 'numerator)))
(let* ((ev (event-cause grob))
(den (if denominator denominator (ly:event-property ev 'denominator)))
(num (if numerator numerator (ly:event-property ev 'numerator))))
(make-concat-markup (list
(let* ((ev (event-cause grob))
(den (if denominator denominator (ly:event-property ev 'denominator)))
(num (if numerator numerator (ly:event-property ev 'numerator))))
(make-concat-markup (list
- (make-simple-markup (format #f "~a" den))
- (markup #:fontsize -5 #:note denominatornote UP)
- (make-simple-markup " : ")
- (make-simple-markup (format #f "~a" num))
- (markup #:fontsize -5 #:note numeratornote UP)))))
+ (make-simple-markup (format #f "~a" den))
+ (markup #:fontsize -5 #:note denominatornote UP)
+ (make-simple-markup " : ")
+ (make-simple-markup (format #f "~a" num))
+ (markup #:fontsize -5 #:note numeratornote UP)))))
(define-public black '(0.0 0.0 0.0))
(define-public white '(1.0 1.0 1.0))
(define-public red '(1.0 0.0 0.0))
(define-public black '(0.0 0.0 0.0))
(define-public white '(1.0 1.0 1.0))
(define-public red '(1.0 0.0 0.0))
- (list (+ (cdr step) (* (car step) 7) c0-position))
- (let* ((c-position (modulo c0-position 7))
- (positions
- (if (< alter 0)
- ;; See (flat|sharp)-positions in define-grob-properties.scm
- (ly:grob-property grob 'flat-positions '(3))
- (ly:grob-property grob 'sharp-positions '(3))))
- (p (list-ref positions
- (if (< c-position (length positions))
- c-position 0)))
- (max-position (if (pair? p) (cdr p) p))
- (min-position (if (pair? p) (car p) (- max-position 6)))
- (first-position (+ (modulo (- (+ c-position step)
- min-position)
- 7)
- min-position)))
- (define (prepend x l) (if (> x max-position)
- l
- (prepend (+ x 7) (cons x l))))
- (prepend first-position '())))))
+ (list (+ (cdr step) (* (car step) 7) c0-position))
+ (let* ((c-position (modulo c0-position 7))
+ (positions
+ (if (< alter 0)
+ ;; See (flat|sharp)-positions in define-grob-properties.scm
+ (ly:grob-property grob 'flat-positions '(3))
+ (ly:grob-property grob 'sharp-positions '(3))))
+ (p (list-ref positions
+ (if (< c-position (length positions))
+ c-position 0)))
+ (max-position (if (pair? p) (cdr p) p))
+ (min-position (if (pair? p) (car p) (- max-position 6)))
+ (first-position (+ (modulo (- (+ c-position step)
+ min-position)
+ 7)
+ min-position)))
+ (define (prepend x l) (if (> x max-position)
+ l
+ (prepend (+ x 7) (cons x l))))
+ (prepend first-position '())))))
(width 0.5) ; should it be a property?
(angularity 1.5) ; makes angle brackets
(white-padding 0.1) ; should it be a property?
(width 0.5) ; should it be a property?
(angularity 1.5) ; makes angle brackets
(white-padding 0.1) ; should it be a property?
- (interval-widen (ly:stencil-extent lp X) white-padding))
- (rp (ly:stencil-aligned-to
- (ly:stencil-aligned-to
- (make-parenthesis-stencil y-extent
- half-thickness
- width
- angularity)
- Y CENTER)
- X LEFT))
- (rp-x-extent
- (interval-widen (ly:stencil-extent rp X) white-padding)))
+ (interval-widen (ly:stencil-extent lp X) white-padding))
+ (rp (ly:stencil-aligned-to
+ (ly:stencil-aligned-to
+ (make-parenthesis-stencil y-extent
+ half-thickness
+ width
+ angularity)
+ Y CENTER)
+ X LEFT))
+ (rp-x-extent
+ (interval-widen (ly:stencil-extent rp X) white-padding)))
- grob
- (car rest)))
- (elts (ly:grob-object grob 'elements))
- (x-ext (ly:relative-group-extent elts refp X))
- (stencils (ly:grob-property grob 'stencils))
- (lp (car stencils))
- (rp (cadr stencils))
- (padding (ly:grob-property grob 'padding 0.1)))
+ grob
+ (car rest)))
+ (elts (ly:grob-object grob 'elements))
+ (x-ext (ly:relative-group-extent elts refp X))
+ (stencils (ly:grob-property grob 'stencils))
+ (lp (car stencils))
+ (rp (cadr stencils))
+ (padding (ly:grob-property grob 'padding 0.1)))
- (y-ref (ly:grob-common-refpoint-of-array me elts Y))
- (x-ref (ly:grob-common-refpoint-of-array me elts X))
- (stencil (parenthesize-elements me x-ref))
- (elt-y-ext (ly:relative-group-extent elts y-ref Y))
- (y-center (interval-center elt-y-ext)))
+ (y-ref (ly:grob-common-refpoint-of-array me elts Y))
+ (x-ref (ly:grob-common-refpoint-of-array me elts X))
+ (stencil (parenthesize-elements me x-ref))
+ (elt-y-ext (ly:relative-group-extent elts y-ref Y))
+ (y-center (interval-center elt-y-ext)))
- (left-span (ly:spanner-bound spanner LEFT))
- (dots (if (and (grob::has-interface left-span 'note-head-interface)
- (ly:grob? (ly:grob-object left-span 'dot)))
- (ly:grob-object left-span 'dot) #f))
-
- (right-span (ly:spanner-bound spanner RIGHT))
- (thickness (* (ly:grob-property spanner 'thickness)
- (ly:output-def-lookup (ly:grob-layout spanner)
- 'line-thickness)))
- (padding (ly:grob-property spanner 'padding 0.5))
- (common (ly:grob-common-refpoint right-span
- (ly:grob-common-refpoint spanner
- left-span X)
- X))
- (common-y (ly:grob-common-refpoint spanner left-span Y))
- (minimum-length (ly:grob-property spanner 'minimum-length 0.5))
-
- (left-x (+ padding
- (max
- (interval-end (ly:grob-robust-relative-extent
- left-span common X))
- (if
- (and dots
- (close
- (ly:grob-relative-coordinate dots common-y Y)
- (ly:grob-relative-coordinate spanner common-y Y)))
- (interval-end
- (ly:grob-robust-relative-extent dots common X))
- (- INFINITY-INT)))))
- (right-x (max (- (interval-start
- (ly:grob-robust-relative-extent right-span common X))
- padding)
- (+ left-x minimum-length)))
- (self-x (ly:grob-relative-coordinate spanner common X))
- (dx (- right-x left-x))
- (exp (list 'path thickness
- `(quote
- (rmoveto
- ,(- left-x self-x) 0
-
- rcurveto
- ,(/ dx 3)
- 0
- ,dx ,(* 0.66 delta-y)
- ,dx ,delta-y)))))
+ (left-span (ly:spanner-bound spanner LEFT))
+ (dots (if (and (grob::has-interface left-span 'note-head-interface)
+ (ly:grob? (ly:grob-object left-span 'dot)))
+ (ly:grob-object left-span 'dot) #f))
+
+ (right-span (ly:spanner-bound spanner RIGHT))
+ (thickness (* (ly:grob-property spanner 'thickness)
+ (ly:output-def-lookup (ly:grob-layout spanner)
+ 'line-thickness)))
+ (padding (ly:grob-property spanner 'padding 0.5))
+ (common (ly:grob-common-refpoint right-span
+ (ly:grob-common-refpoint spanner
+ left-span X)
+ X))
+ (common-y (ly:grob-common-refpoint spanner left-span Y))
+ (minimum-length (ly:grob-property spanner 'minimum-length 0.5))
+
+ (left-x (+ padding
+ (max
+ (interval-end (ly:grob-robust-relative-extent
+ left-span common X))
+ (if
+ (and dots
+ (close
+ (ly:grob-relative-coordinate dots common-y Y)
+ (ly:grob-relative-coordinate spanner common-y Y)))
+ (interval-end
+ (ly:grob-robust-relative-extent dots common X))
+ (- INFINITY-INT)))))
+ (right-x (max (- (interval-start
+ (ly:grob-robust-relative-extent right-span common X))
+ padding)
+ (+ left-x minimum-length)))
+ (self-x (ly:grob-relative-coordinate spanner common X))
+ (dx (- right-x left-x))
+ (exp (list 'path thickness
+ `(quote
+ (rmoveto
+ ,(- left-x self-x) 0
+
+ rcurveto
+ ,(/ dx 3)
+ 0
+ ,dx ,(* 0.66 delta-y)
+ ,dx ,delta-y)))))
- (get-difference
- (lambda (idx)
- (ly:moment-sub (ly:grob-property
- (ly:grob-array-ref cols (1+ idx)) 'when)
- (ly:grob-property
- (ly:grob-array-ref cols idx) 'when))))
-
- (moment-min (lambda (x y)
- (cond
- ((and x y)
- (if (ly:moment<? x y)
- x
- y))
- (x x)
- (y y)))))
+ (get-difference
+ (lambda (idx)
+ (ly:moment-sub (ly:grob-property
+ (ly:grob-array-ref cols (1+ idx)) 'when)
+ (ly:grob-property
+ (ly:grob-array-ref cols idx) 'when))))
+
+ (moment-min (lambda (x y)
+ (cond
+ ((and x y)
+ (if (ly:moment<? x y)
+ x
+ y))
+ (x x)
+ (y y)))))
(define-public (stroke-finger::calc-text grob)
(let ((event (event-cause grob)))
(or (ly:event-property event 'text #f)
(define-public (stroke-finger::calc-text grob)
(let ((event (event-cause grob)))
(or (ly:event-property event 'text #f)
between the two text elements."
(let ((left-bound (ly:spanner-bound grob LEFT)))
(if (grob::has-interface left-bound 'dynamic-text-interface)
between the two text elements."
(let ((left-bound (ly:spanner-bound grob LEFT)))
(if (grob::has-interface left-bound 'dynamic-text-interface)
- (let* ((details (ly:grob-property grob 'bound-details))
- (left-details (ly:assoc-get 'left details))
- (my-padding (ly:assoc-get 'padding left-details))
- (script-padding (ly:grob-property left-bound 'right-padding 0)))
-
- (and (number? my-padding)
- (ly:grob-set-nested-property! grob
- '(bound-details left attach-dir)
- RIGHT)
- (ly:grob-set-nested-property! grob
- '(bound-details left padding)
- (+ my-padding script-padding)))))))
+ (let* ((details (ly:grob-property grob 'bound-details))
+ (left-details (ly:assoc-get 'left details))
+ (my-padding (ly:assoc-get 'padding left-details))
+ (script-padding (ly:grob-property left-bound 'right-padding 0)))
+
+ (and (number? my-padding)
+ (ly:grob-set-nested-property! grob
+ '(bound-details left attach-dir)
+ RIGHT)
+ (ly:grob-set-nested-property! grob
+ '(bound-details left padding)
+ (+ my-padding script-padding)))))))
- (let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
- (thick (ly:grob-property grob 'thickness 0.1))
- (thick (* thick (layout-line-thickness grob)))
- (xex (ly:stencil-extent sten X))
- (lenx (interval-length xex))
- (yex (ly:stencil-extent sten Y))
- (leny (interval-length yex))
- (xtrans (+ (car xex) (if decresc? lenx 0)))
- (ytrans (car yex))
- (uplist (map pair-to-list
- (normalize-coords coords lenx (/ leny 2))))
- (downlist (map pair-to-list
- (normalize-coords coords lenx (/ leny -2)))))
- (ly:stencil-translate
- (ly:stencil-add
- (my-c-p-s uplist thick decresc?)
- (if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil))
- (cons xtrans ytrans)))
- '())))
+ (let* ((decresc? (eq? (ly:grob-property grob 'grow-direction) LEFT))
+ (thick (ly:grob-property grob 'thickness 0.1))
+ (thick (* thick (layout-line-thickness grob)))
+ (xex (ly:stencil-extent sten X))
+ (lenx (interval-length xex))
+ (yex (ly:stencil-extent sten Y))
+ (leny (interval-length yex))
+ (xtrans (+ (car xex) (if decresc? lenx 0)))
+ (ytrans (car yex))
+ (uplist (map pair-to-list
+ (normalize-coords coords lenx (/ leny 2))))
+ (downlist (map pair-to-list
+ (normalize-coords coords lenx (/ leny -2)))))
+ (ly:stencil-translate
+ (ly:stencil-add
+ (my-c-p-s uplist thick decresc?)
+ (if mirrored? (my-c-p-s downlist thick decresc?) empty-stencil))
+ (cons xtrans ytrans)))
+ '())))
(define-public (script-interface::calc-x-offset grob)
(ly:grob-property grob 'positioning-done)
(let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
(define-public (script-interface::calc-x-offset grob)
(ly:grob-property grob 'positioning-done)
(let* ((shift (ly:grob-property grob 'toward-stem-shift 0.0))
- (note-head-location
- (ly:self-alignment-interface::centered-on-x-parent grob))
- (note-head-grob (ly:grob-parent grob X))
- (stem-grob (ly:grob-object note-head-grob 'stem)))
+ (note-head-location
+ (ly:self-alignment-interface::centered-on-x-parent grob))
+ (note-head-grob (ly:grob-parent grob X))
+ (stem-grob (ly:grob-object note-head-grob 'stem)))
- (let ((dir1 (ly:grob-property grob 'direction))
- (dir2 (ly:grob-property stem-grob 'direction)))
- (if (equal? dir1 dir2)
- (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
- (stem-location
- (ly:grob-relative-coordinate stem-grob common-refp X)))
- (* shift (- stem-location note-head-location)))
- 0.0))
- 0.0))))
+ (let ((dir1 (ly:grob-property grob 'direction))
+ (dir2 (ly:grob-property stem-grob 'direction)))
+ (if (equal? dir1 dir2)
+ (let* ((common-refp (ly:grob-common-refpoint grob stem-grob X))
+ (stem-location
+ (ly:grob-relative-coordinate stem-grob common-refp X)))
+ (* shift (- stem-location note-head-location)))
+ 0.0))
+ 0.0))))
- (left-mom (ly:grob-property left-bound 'when))
- (name (if (moment<=? left-mom ZERO-MOMENT)
- (ly:grob-property grob 'long-text)
- (ly:grob-property grob 'text))))
+ (left-mom (ly:grob-property left-bound 'when))
+ (name (if (moment<=? left-mom ZERO-MOMENT)
+ (ly:grob-property grob 'long-text)
+ (ly:grob-property grob 'text))))
- (left-mom (ly:grob-property left-bound 'when))
- (layout (ly:grob-layout grob))
- (indent (ly:output-def-lookup layout
- (if (moment<=? left-mom ZERO-MOMENT)
- 'indent
- 'short-indent)
- 0.0))
- (system (ly:grob-system grob))
- (my-extent (ly:grob-extent grob system X))
- (elements (ly:grob-object system 'elements))
- (common (ly:grob-common-refpoint-of-array system elements X))
- (total-ext empty-interval)
- (align-x (ly:grob-property grob 'self-alignment-X 0))
- (padding (min 0 (- (interval-length my-extent) indent)))
- (right-padding (- padding
- (/ (* padding (1+ align-x)) 2))))
+ (left-mom (ly:grob-property left-bound 'when))
+ (layout (ly:grob-layout grob))
+ (indent (ly:output-def-lookup layout
+ (if (moment<=? left-mom ZERO-MOMENT)
+ 'indent
+ 'short-indent)
+ 0.0))
+ (system (ly:grob-system grob))
+ (my-extent (ly:grob-extent grob system X))
+ (elements (ly:grob-object system 'elements))
+ (common (ly:grob-common-refpoint-of-array system elements X))
+ (total-ext empty-interval)
+ (align-x (ly:grob-property grob 'self-alignment-X 0))
+ (padding (min 0 (- (interval-length my-extent) indent)))
+ (right-padding (- padding
+ (/ (* padding (1+ align-x)) 2))))
;; compensate for the variation in delimiter extents by
;; calculating an X-offset correction based on united extents
;; of all delimiters in this system
(let unite-delims ((l (ly:grob-array-length elements)))
(if (> l 0)
;; compensate for the variation in delimiter extents by
;; calculating an X-offset correction based on united extents
;; of all delimiters in this system
(let unite-delims ((l (ly:grob-array-length elements)))
(if (> l 0)
- (if (grob::has-interface elt 'system-start-delimiter-interface)
- (let ((dims (ly:grob-extent elt common X)))
- (if (interval-sane? dims)
- (set! total-ext (interval-union total-ext dims)))))
- (unite-delims (1- l)))))
+ (if (grob::has-interface elt 'system-start-delimiter-interface)
+ (let ((dims (ly:grob-extent elt common X)))
+ (if (interval-sane? dims)
+ (set! total-ext (interval-union total-ext dims)))))
+ (unite-delims (1- l)))))
- (live-elts (live-elements-list grob))
- (system (ly:grob-system grob))
- (extent empty-interval))
+ (live-elts (live-elements-list grob))
+ (system (ly:grob-system grob))
+ (extent empty-interval))
- (interval-sane? (ly:grob-extent grob system Y)))
- (let get-extent ((lst live-elts))
- (if (pair? lst)
- (let ((axis-group (car lst)))
-
- (if (and (ly:spanner? axis-group)
- (equal? (ly:spanner-bound axis-group LEFT)
- left-bound))
- (set! extent (add-point extent
- (ly:grob-relative-coordinate
- axis-group system Y))))
- (get-extent (cdr lst)))))
- ;; no live axis group(s) for this instrument name -> remove from system
- (ly:grob-suicide! grob))
+ (interval-sane? (ly:grob-extent grob system Y)))
+ (let get-extent ((lst live-elts))
+ (if (pair? lst)
+ (let ((axis-group (car lst)))
+
+ (if (and (ly:spanner? axis-group)
+ (equal? (ly:spanner-bound axis-group LEFT)
+ left-bound))
+ (set! extent (add-point extent
+ (ly:grob-relative-coordinate
+ axis-group system Y))))
+ (get-extent (cdr lst)))))
+ ;; no live axis group(s) for this instrument name -> remove from system
+ (ly:grob-suicide! grob))
+;; Calculate the gaps between ambitus heads and ends of ambitus line.
+;; Start by determining desired length of the ambitus line (based on
+;; length-fraction property), calc gap from that and make sure that
+;; it doesn't exceed maximum allowed value.
+
+(define-public (ambitus-line::calc-gap grob)
+ (let ((heads (ly:grob-object grob 'note-heads)))
+
+ (if (and (ly:grob-array? heads)
+ (= (ly:grob-array-length heads) 2))
+ (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
+ (head-down (ly:grob-array-ref heads 0))
+ (head-up (ly:grob-array-ref heads 1))
+ (fraction (ly:grob-property grob 'length-fraction 0.7))
+ (max-gap (ly:grob-property grob 'maximum-gap 0.45))
+ ;; distance between noteheads:
+ (distance (- (interval-start (ly:grob-extent head-up common Y))
+ (interval-end (ly:grob-extent head-down common Y))))
+ (gap (* 0.5 distance (- 1 fraction))))
+
+ (min gap max-gap))
+ 0)))
+
+;; Print a line connecting ambitus heads:
+
(define-public (ambitus::print grob)
(let ((heads (ly:grob-object grob 'note-heads)))
(if (and (ly:grob-array? heads)
(define-public (ambitus::print grob)
(let ((heads (ly:grob-object grob 'note-heads)))
(if (and (ly:grob-array? heads)
- (= (ly:grob-array-length heads) 2))
- (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
- (head-down (ly:grob-array-ref heads 0))
- (head-up (ly:grob-array-ref heads 1))
- (gap (ly:grob-property grob 'gap 0.35))
- (point-min (+ (interval-end (ly:grob-extent head-down common Y))
- gap))
- (point-max (- (interval-start (ly:grob-extent head-up common Y))
- gap)))
-
- (if (< point-min point-max)
- (let* ((layout (ly:grob-layout grob))
- (line-thick (ly:output-def-lookup layout 'line-thickness))
- (blot (ly:output-def-lookup layout 'blot-diameter))
- (grob-thick (ly:grob-property grob 'thickness 2))
- (width (* line-thick grob-thick))
- (x-ext (symmetric-interval (/ width 2)))
- (y-ext (cons point-min point-max))
- (line (ly:round-filled-box x-ext y-ext blot))
- (y-coord (ly:grob-relative-coordinate grob common Y)))
-
- (ly:stencil-translate-axis line (- y-coord) Y))
- empty-stencil))
- (begin
- (ly:grob-suicide! grob)
- (list)))))
+ (= (ly:grob-array-length heads) 2))
+ (let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
+ (head-down (ly:grob-array-ref heads 0))
+ (head-up (ly:grob-array-ref heads 1))
+ ;; The value used when 'gap' property cannot be read is small
+ ;; to make sure that ambitus of a fifth will have a visible line.
+ (gap (ly:grob-property grob 'gap 0.25))
+ (point-min (+ (interval-end (ly:grob-extent head-down common Y))
+ gap))
+ (point-max (- (interval-start (ly:grob-extent head-up common Y))
+ gap)))
+
+ (if (< (+ point-min 0.1) point-max) ; don't print lines shorter than 0.1ss
+ (let* ((layout (ly:grob-layout grob))
+ (line-thick (ly:output-def-lookup layout 'line-thickness))
+ (blot (ly:output-def-lookup layout 'blot-diameter))
+ (grob-thick (ly:grob-property grob 'thickness 2))
+ (width (* line-thick grob-thick))
+ (x-ext (symmetric-interval (/ width 2)))
+ (y-ext (cons point-min point-max))
+ (line (ly:round-filled-box x-ext y-ext blot))
+ (y-coord (ly:grob-relative-coordinate grob common Y)))
+
+ (ly:stencil-translate-axis line (- y-coord) Y))
+ empty-stencil))
+ (begin
+ (ly:grob-suicide! grob)
+ (list)))))
(define-public (volta-bracket-interface::pure-height grob start end)
(let ((edge-height (ly:grob-property grob 'edge-height)))
(if (number-pair? edge-height)
(define-public (volta-bracket-interface::pure-height grob start end)
(let ((edge-height (ly:grob-property grob 'edge-height)))
(if (number-pair? edge-height)
- (let ((smaller (min (car edge-height) (cdr edge-height)))
- (larger (max (car edge-height) (cdr edge-height))))
- (interval-union '(0 . 0) (cons smaller larger)))
- '(0 . 0))))
+ (let ((smaller (min (car edge-height) (cdr edge-height)))
+ (larger (max (car edge-height) (cdr edge-height))))
+ (interval-union '(0 . 0) (cons smaller larger)))
+ '(0 . 0))))