2 ;;;; beam.scm -- Beam scheme stuff
4 ;;;; source file of the GNU LilyPond music typesetter
6 ;;;; (c) 2000--2007 Jan Nieuwenhuizen <janneke@gnu.org>
9 (define ((check-beam-quant posl posr) beam posns)
10 "Check whether BEAM has POSL and POSR quants. POSL are (POSITION
11 . QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter)
14 (let* ((thick (ly:grob-property beam 'thickness))
15 (layout (ly:grob-layout beam))
16 (lthick (ly:output-def-lookup layout 'line-thickness))
17 (staff-thick lthick) ; fixme.
18 (quant->coord (lambda (p q)
21 (+ p (- (* 0.5 q thick) (* 0.5 q lthick))))))
22 (want-l (quant->coord (car posl) (cdr posl)))
23 (want-r (quant->coord (car posr) (cdr posr)))
24 (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3))))
26 (if (or (not (almost-equal want-l (car posns)))
27 (not (almost-equal want-r (cdr posns))))
29 (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.")
31 (set! (ly:grob-property beam 'annotation)
32 (format "(~S,~S)" want-l want-r))))
37 (define ((check-beam-slope-sign comparison) beam posns)
38 "Check whether the slope of BEAM is correct wrt. COMPARISON."
39 (let* ((slope-sign (- (cdr posns) (car posns)))
40 (correct (comparison slope-sign 0)))
43 (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.")
44 (procedure-name comparison) slope-sign)
45 (set! (ly:grob-property beam 'annotation)
46 (format "~S 0" (procedure-name comparison))))
47 (set! (ly:grob-property beam 'annotation) ""))
51 (define-public (check-quant-callbacks l r)
52 (list ly:beam::calc-least-squares-positions
53 ly:beam::slope-damping
54 ly:beam::shift-region-to-valid
56 (check-beam-quant l r)
60 (define-public (check-slope-callbacks comparison)
61 (list ly:beam::calc-least-squares-positions
62 ly:beam::slope-damping
63 ly:beam::shift-region-to-valid
65 (check-beam-slope-sign comparison)