LEFT | RIGHT |
1 ;;;; auto-beam.scm -- Auto-beam-engraver settings | 1 ;;;; auto-beam.scm -- Auto-beam-engraver settings |
2 ;;;; | 2 ;;;; |
3 ;;;; source file of the GNU LilyPond music typesetter | 3 ;;;; source file of the GNU LilyPond music typesetter |
4 ;;;; | 4 ;;;; |
5 ;;;; (c) 2000--2009 Jan Nieuwenhuizen <janneke@gnu.org> | 5 ;;;; (c) 2000--2009 Jan Nieuwenhuizen <janneke@gnu.org> |
6 | 6 |
7 ;; Determine end moment for auto beaming (or begin moment, but mostly | 7 ;; Determine end moment for auto beaming (or begin moment, but mostly |
8 ;; 0== anywhere). We only consider the current time signature. | 8 ;; 0== anywhere). We only consider the current time signature. |
9 ;; In order of decreasing priority: | 9 ;; In order of decreasing priority: |
10 ;; | 10 ;; |
(...skipping 17 matching lines...) Expand all Loading... |
28 (let ((value (ly:context-property context name))) | 28 (let ((value (ly:context-property context name))) |
29 (if (not (null? value)) value default))) | 29 (if (not (null? value)) value default))) |
30 | 30 |
31 (define (ending-moments group-list start-beat beat-length) | 31 (define (ending-moments group-list start-beat beat-length) |
32 (if (null? group-list) | 32 (if (null? group-list) |
33 '() | 33 '() |
34 (let ((new-start (+ start-beat (car group-list)))) | 34 (let ((new-start (+ start-beat (car group-list)))) |
35 (cons (ly:moment-mul (ly:make-moment new-start 1) beat-length) | 35 (cons (ly:moment-mul (ly:make-moment new-start 1) beat-length) |
36 (ending-moments (cdr group-list) new-start beat-length))))) | 36 (ending-moments (cdr group-list) new-start beat-length))))) |
37 | 37 |
38 (define (get-grouping-rules settings time-signature function) | |
39 (let ((grouping-rules (assoc-get | |
40 (list time-signature function) | |
41 settings | |
42 '()))) | |
43 grouping-rules)) | |
44 | |
45 ;; Start of actual auto-beam test routine | 38 ;; Start of actual auto-beam test routine |
46 ;; | 39 ;; |
47 ;; | 40 ;; |
48 ;; Don't start auto beams on grace notes | 41 ;; Don't start auto beams on grace notes |
49 (if (and (!= (ly:moment-grace-numerator (ly:context-now context)) 0) | 42 (if (and (!= (ly:moment-grace-numerator (ly:context-now context)) 0) |
50 (= dir START)) | 43 (= dir START)) |
51 #f | 44 #f |
52 (if (= dir START) | 45 (if (= dir START) |
53 ;; start anywhere is currently implemented | 46 ;; start anywhere is currently implemented |
54 #t | 47 #t |
55 (let* ((beat-length (get 'beatLength (ly:make-moment 1 4))) | 48 (let* ((beat-length (get 'beatLength (ly:make-moment 1 4))) |
56 (measure-length (get 'measureLength (ly:make-moment 1 1))) | 49 (measure-length (get 'measureLength (ly:make-moment 1 1))) |
57 (time-signature-fraction | 50 (time-signature-fraction |
58 (get 'timeSignatureFraction '(4 . 4))) | 51 (get 'timeSignatureFraction '(4 . 4))) |
59 (measure-pos (get 'measurePosition ZERO-MOMENT)) | 52 (measure-pos (get 'measurePosition ZERO-MOMENT)) |
60 (settings (get 'beamSettings '())) | 53 (settings (get 'beamSettings '())) |
61 (function (if (= dir START) 'begin 'end)) | 54 (function (if (= dir START) 'begin 'end)) |
62 (type (cons (ly:moment-main-numerator test-beam) | 55 (type (cons (ly:moment-main-numerator test-beam) |
63 (ly:moment-main-denominator test-beam))) | 56 (ly:moment-main-denominator test-beam))) |
64 (pos (if (>= (ly:moment-main-numerator measure-pos) 0) | 57 (pos (if (>= (ly:moment-main-numerator measure-pos) 0) |
65 measure-pos | 58 measure-pos |
66 (ly:moment-add measure-length measure-pos))) | 59 (ly:moment-add measure-length measure-pos))) |
67 (grouping-rules | 60 (type-grouping (ly:beam-grouping |
68 (get-grouping-rules settings | 61 settings |
69 time-signature-fraction | 62 time-signature-fraction |
70 function)) | 63 function |
71 (type-grouping (assoc-get type | 64 type)) |
72 grouping-rules | 65 (default-grouping (ly:beam-grouping |
73 '())) | 66 settings |
74 (default-grouping (assoc-get '* | 67 time-signature-fraction |
75 grouping-rules | 68 function |
76 '())) | 69 '*)) |
77 (beat-grouping (if (null? type-grouping) | 70 (beat-grouping (if (null? type-grouping) |
78 default-grouping | 71 default-grouping |
79 type-grouping)) | 72 type-grouping)) |
80 (grouping-moment (if (null? type-grouping) | 73 (grouping-moment (if (null? type-grouping) |
81 beat-length | 74 beat-length |
82 test-beam)) | 75 test-beam)) |
83 (grouping-moments (ending-moments | 76 (grouping-moments (ending-moments |
84 beat-grouping 0 grouping-moment))) | 77 beat-grouping 0 grouping-moment))) |
85 (if (null? beat-grouping) | 78 (if (null? beat-grouping) |
86 ;; no rule applies, so end at beatLength | 79 ;; no rule applies, so end at beatLength |
87 (= (ly:moment-main-denominator | 80 (= (ly:moment-main-denominator |
88 (ly:moment-div pos beat-length)) 1) | 81 (ly:moment-div pos beat-length)) 1) |
89 ;; otherwise, end at beginning of measure or | 82 ;; otherwise, end at beginning of measure or |
90 ;; at specified moment | 83 ;; at specified moment |
91 (or | 84 (or |
92 ;; start/end at beginning of measure | 85 ;; start/end at beginning of measure |
93 (= (ly:moment-main-numerator pos) 0) | 86 (= (ly:moment-main-numerator pos) 0) |
94 ;; end if measure-pos matches a specified ending moment | 87 ;; end if measure-pos matches a specified ending moment |
95 (member measure-pos grouping-moments))))))) | 88 (member measure-pos grouping-moments))))))) |
LEFT | RIGHT |