1 ;;;; This file is part of LilyPond, the GNU music typesetter.
3 ;;;; Copyright (C) 2000--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5 ;;;; LilyPond is free software: you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version.
10 ;;;; LilyPond is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;;;; GNU General Public License for more details.
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
18 (define ((check-beam-quant posl posr) beam posns)
19 "Check whether BEAM has POSL and POSR quants. POSL are (POSITION
20 . QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter)
23 (let* ((thick (ly:grob-property beam 'beam-thickness))
24 (layout (ly:grob-layout beam))
25 (lthick (ly:output-def-lookup layout 'line-thickness))
26 (staff-thick lthick) ; fixme.
27 (quant->coord (lambda (p q)
30 (+ p (- (* 0.5 q thick) (* 0.5 q lthick))))))
31 (want-l (quant->coord (car posl) (cdr posl)))
32 (want-r (quant->coord (car posr) (cdr posr)))
33 (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3))))
35 (if (or (not (almost-equal want-l (car posns)))
36 (not (almost-equal want-r (cdr posns))))
38 (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.")
40 (set! (ly:grob-property beam 'annotation)
41 (format "(~S,~S)" want-l want-r))))
46 (define ((check-beam-slope-sign comparison) beam posns)
47 "Check whether the slope of BEAM is correct wrt. COMPARISON."
48 (let* ((slope-sign (- (cdr posns) (car posns)))
49 (correct (comparison slope-sign 0)))
52 (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.")
53 (procedure-name comparison) slope-sign)
54 (set! (ly:grob-property beam 'annotation)
55 (format "~S 0" (procedure-name comparison))))
56 (set! (ly:grob-property beam 'annotation) ""))
60 (define-public (check-quant-callbacks l r)
61 (list ly:beam::calc-least-squares-positions
62 ly:beam::slope-damping
63 ly:beam::shift-region-to-valid
65 (check-beam-quant l r)
69 (define-public (check-slope-callbacks comparison)
70 (list ly:beam::calc-least-squares-positions
71 ly:beam::slope-damping
72 ly:beam::shift-region-to-valid
74 (check-beam-slope-sign comparison)