]> git.donarmstrong.com Git - lilypond.git/blob - scm/beam.scm
patch::: 1.5.42.jcn2
[lilypond.git] / scm / beam.scm
1 ;;;;
2 ;;;; beam.scm -- Beam scheme stuff
3 ;;;;
4 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; 
6 ;;;; (c) 2000--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 ;;;;
8
9 ;;
10 ;; width in staff space.
11 ;;
12 (define (default-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)))
17
18 ;; There are several ways to calculate the direction of a beam
19 ;;
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
23 ;;
24 ;; [Ross] states that the majority of the notes dictates the
25 ;; direction (and not the mean of "center distance")
26 ;;
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.
31
32 (define (dir-compare up down)
33   (sign (- up down)))
34
35 ;; arguments are in the form (up . down)
36 (define (beam-dir-majority count total)
37   (dir-compare (car count) (cdr count)))
38
39 (beam-dir-majority '(0 . 0) '(0 . 0))
40
41 (define (beam-dir-mean count total)
42   (dir-compare (car total) (cdr total)))
43
44 (define (beam-dir-median count total)
45   (if (and (> (car count) 0)
46            (> (cdr count) 0))
47       (dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count)))
48       (dir-compare (car count) (cdr count))))
49