X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Flayout-beam.scm;h=aa35be0d63eb2684f78562f0fcd9319025607d1c;hb=bb7cac7b276bd7d1335523f3be8df815cf894ece;hp=e92edc0e84c44a0fd5c060a1f6ad92c5cda1879c;hpb=4a4b9008d4e571eb5714314661f5eaf35b117ef0;p=lilypond.git diff --git a/scm/layout-beam.scm b/scm/layout-beam.scm index e92edc0e84..aa35be0d63 100644 --- a/scm/layout-beam.scm +++ b/scm/layout-beam.scm @@ -1,69 +1,30 @@ +;;;; This file is part of LilyPond, the GNU music typesetter. ;;;; -;;;; beam.scm -- Beam scheme stuff +;;;; Copyright (C) 2000--2011 Jan Nieuwenhuizen ;;;; -;;;; source file of the GNU LilyPond music typesetter -;;;; -;;;; (c) 2000--2005 Jan Nieuwenhuizen +;;;; LilyPond is free software: you can redistribute it and/or modify +;;;; it under the terms of the GNU General Public License as published by +;;;; the Free Software Foundation, either version 3 of the License, or +;;;; (at your option) any later version. ;;;; +;;;; LilyPond is distributed in the hope that it will be useful, +;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;;; GNU General Public License for more details. +;;;; +;;;; You should have received a copy of the GNU General Public License +;;;; along with LilyPond. If not, see . -;; -;; width in staff space. -;; -(define (beam-flag-width-function type) - (cond - ((eq? type 1) 1.98) - ((eq? type 1) 1.65) ;; FIXME: check what this should be and why - (else 1.32))) - -;; There are several ways to calculate the direction of a beam -;; -;; * majority: number count of up or down notes -;; * mean : mean centre distance of all notes -;; * median : mean centre distance weighted per note -;; -;; [Ross] states that the majority of the notes dictates the -;; direction (and not the mean of "center distance") -;; -;; But is that because it really looks better, or because he wants -;; to provide some real simple hands-on rules? -;; -;; We have our doubts, so we simply provide all sensible alternatives. - - -;; -;; DOCME: what goes into this func, what comes out. -(define (dir-compare up down) - (sign (- up down))) - -;; arguments are in the form (up . down) -(define-public (beam-dir-majority count total) - (dir-compare (car count) (cdr count))) - -(define-public (beam-dir-majority-median count total) - "First try majority. If that doesn't work, try median." - (let ((maj (dir-compare (car count) (cdr count)))) - (if (not (= maj 0)) - maj - (beam-dir-median count total)))) - -(define-public (beam-dir-mean count total) - (dir-compare (car total) (cdr total))) - -(define-public (beam-dir-median count total) - (if (and (> (car count) 0) - (> (cdr count) 0)) - (dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count))) - (dir-compare (car count) (cdr count)))) - -(define ((check-beam-quant posl posr) beam) +(define check-beam-quant + (lambda (posl posr) + (lambda (beam posns) "Check whether BEAM has POSL and POSR quants. POSL are (POSITION . QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter) " - (let* ((posns (ly:grob-property beam 'positions)) - (thick (ly:grob-property beam 'thickness)) + (let* ((thick (ly:grob-property beam 'beam-thickness)) (layout (ly:grob-layout beam)) - (lthick (ly:output-def-lookup layout 'linethickness)) + (lthick (ly:output-def-lookup layout 'line-thickness)) (staff-thick lthick) ; fixme. (quant->coord (lambda (p q) (if (= 2 (abs q)) @@ -78,38 +39,40 @@ (begin (ly:warning (_ "Error in beam quanting. Expected (~S,~S) found ~S.") want-l want-r posns) - (set! (ly:grob-property beam 'quant-score) - (format "(~S,~S)" want-l want-r))) - (set! (ly:grob-property beam 'quant-score) "")))) + (set! (ly:grob-property beam 'annotation) + (format #f "(~S,~S)" want-l want-r)))) + posns)))) -(define ((check-beam-slope-sign comparison) beam) +(define check-beam-slope-sign + (lambda (comparison) + (lambda (beam posns) "Check whether the slope of BEAM is correct wrt. COMPARISON." - (let* ((posns (ly:grob-property beam 'positions)) - (slope-sign (- (cdr posns) (car posns))) + (let* ((slope-sign (- (cdr posns) (car posns))) (correct (comparison slope-sign 0))) - (if (not correct) (begin (ly:warning (_ "Error in beam quanting. Expected ~S 0, found ~S.") - (procedure-name comparison) "0" slope-sign) - (set! (ly:grob-property beam 'quant-score) - (format "~S 0" (procedure-name comparison)))) - (set! (ly:grob-property beam 'quant-score) "")))) + (procedure-name comparison) slope-sign) + (set! (ly:grob-property beam 'annotation) + (format #f "~S 0" (procedure-name comparison)))) + (set! (ly:grob-property beam 'annotation) "")) + posns)))) + (define-public (check-quant-callbacks l r) - (list Beam::least_squares - Beam::check_concave - Beam::slope_damping - Beam::shift_region_to_valid - Beam::quanting - (check-beam-quant l r))) + (list ly:beam::calc-least-squares-positions + ly:beam::slope-damping + ly:beam::shift-region-to-valid + ly:beam::quanting + (check-beam-quant l r) + )) (define-public (check-slope-callbacks comparison) - (list Beam::least_squares - Beam::check_concave - Beam::slope_damping - Beam::shift_region_to_valid - Beam::quanting - (check-beam-slope-sign comparison))) + (list ly:beam::calc-least-squares-positions + ly:beam::slope-damping + ly:beam::shift-region-to-valid + ly:beam::quanting + (check-beam-slope-sign comparison) + ))