* lily/beam-performer.cc (process_music): idem.
[lilypond.git] / scm / beam.scm
blobd20458eb5364b5b6bd1b5a82268490b2e764ab37
1 ;;;;
2 ;;;; beam.scm -- Beam scheme stuff
3 ;;;;
4 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; 
6 ;;;; (c)  2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;;;
9 ;;
10 ;; width in staff space.
12 (define (beam-flag-width-function type)
13   (cond
14    ((eq? type 1) 1.98) 
15    ((eq? type 1) 1.65) ;; FIXME: check what this should be and why
16    (else 1.32)))
18 ;; There are several ways to calculate the direction of a beam
20 ;; * majority: number count of up or down notes
21 ;; * mean    : mean centre distance of all notes
22 ;; * median  : mean centre distance weighted per note
24 ;; [Ross] states that the majority of the notes dictates the
25 ;; direction (and not the mean of "center distance")
27 ;; But is that because it really looks better, or because he wants
28 ;; to provide some real simple hands-on rules?
29 ;;     
30 ;; We have our doubts, so we simply provide all sensible alternatives.
35 ; DOCME: what goes into this func, what comes out.
37 (define (dir-compare up down)
38   (sign (- up down)))
40 ;; arguments are in the form (up . down)
41 (define-public (beam-dir-majority count total)
42   (dir-compare (car count) (cdr count)))
44 (define-public (beam-dir-majority-median count total)
45   "First try majority. If that doesn't work, try median."
46   (let ((maj (dir-compare (car count) (cdr count))))
47     (if (not (= maj 0))
48         maj
49         (beam-dir-median count total))
50     ))
53 (define-public (beam-dir-mean count total)
54   (dir-compare (car total) (cdr total)))
56 (define-public (beam-dir-median count total)
57   (if (and (> (car count) 0)
58            (> (cdr count) 0))
59       (dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count)))
60       (dir-compare (car count) (cdr count))))
61