1 ;;;; default-beam-settings.scm -- Default auto-beam and subdivide-beam settings
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2009 Carl Sorensen <c_sorensen@byu.edu>
7 ;;; specify default beaming rules
12 ;;; ((time-signature function) . (beam-type . grouping)) entries
16 ;;; time-signature = time signature fraction (pair of numbers, (4 .4) )
17 ;;; function = 'end or 'subdivide (possibly implement 'begin in the future)
18 ;;; beam-type = '* or (numerator . denominator); e.g. (1 . 16)
19 ;;; NOTE: numerator is kept in beam-type because of
20 ;;; tuplets, e.g. (2 . 24) = (2 . 3) * (1 . 8)
21 ;;; for eighth-note triplets.
22 ;;; grouping = a list of groups, in units of time signature denominator
23 ;;; (for default rules) or beam-type (for explicit rules)
26 (define-public default-beam-settings
29 ;; default: end beams on 1 2 note boundaries
30 ;; end beams with 32nd notes each 1 4 beat
33 ((1 . 32) . (8 8 8 8))))
35 ;; in 2 4, 2 8 and 2 16 time:
36 ;; default: end beams on beats
37 (((2 . 4) end) . ((* . (1 1))))
38 (((2 . 8) end) . ((* . (1 1))))
39 (((2 . 16) end) . ((* . (1 1))))
42 ;; default: end beams on beats
43 ;; end beams with 32nd notes each 1 4 beat
46 ((1 . 32) . (8 8 8 8 8 8))))
49 ;; default: end beams on beats
50 ;; group 1/8 note beams on measure
51 (((3 . 4) end) .((* . (3))
55 ((1 128) . (32 32 32))))
57 ;; in 3 8 and 3 16 time time:
58 ;; default: group on 3
59 (((3 . 8) end) . ((* . (3))))
60 (((3 . 16) end) . ((* . (3))))
63 ;; default: end beams on beats
64 ;; end beams with 16th notes each 1 4 beat
65 ;; end beams with 32nd notes each 1 8 beat
68 ((1 . 16) . (4 4 4 4 4 4 4 4))
74 ;; in 4 4 (common) time:
75 ;; default: end beams on beats
76 ;; use beatLength for all except 32nd notes:
77 ;; end beams with 32nd notes each 1 8 beat
84 ;; default: group on 1 4 notes
85 (((4 . 8) end) . ((* . (2 2))))
88 ;; default: group on beats
89 (((4 . 16) end) . ((* . (1 1 1 1))))
92 ;; default group at 3 4
93 ;; end beams with 16th or 32nd notes each 1 4 beat
96 ((1 . 16) . (4 4 4 4 4 4))
97 ((1 . 32) . (8 8 8 8 8 8))))
100 ;; default: group at 3 8
101 ;; end beams with 32nd notes each 1 8 beat
104 ((6 . 8) . (4 4 4 4 4 4))))
107 ;; default: group at 3 16
108 (((6 . 16) end) . ((* . (3 3))))
111 ;; default: group at 3 4
112 ;; end beams with 16th or 32nd notes each 1 4 beat
115 ((1 . 16) . (4 4 4 4 4 4 4 4 4))
116 ((1 . 32) . (8 8 8 8 8 8 8 8 8))))
119 ;; default: group at 3 8
120 ;; use beatGrouping for all except 32nd notes
121 ;; end beams with 32nd notes each 1 8 beat
124 ((1 . 32) . (4 4 4 4 4 4 4 4 4))))
127 ;; default: group at 3 8
128 (((9 . 16) end) . ((* . (3 3 3))))
131 ;; default: group at 3 4
132 ;; end beams with 16th or 32nd notes each 1 4 beat
135 ((1 . 16) . (4 4 4 4 4 4 4 4 4 4 4 4 4))
136 ((12 . 4) . (8 8 8 8 8 8 8 8 8 8 8 8 8))))
139 ;; default: group at 3 8
140 ;; end beams with 32nd notes each 1 8 beat
143 ((1 . 32) . (4 4 4 4 4 4 4 4 4 4 4 4 4))))
146 ;; default: group at 3 16
147 (((12 . 16) end) . ((* . (3 3 3 3))))
150 ;; default: group (3 2)
151 (((5 . 8) end) . ((* . (3 2))))
154 ;; default: group (3 3 2)
155 (((8 . 8) end) . ((* . (3 3 2))))
156 )) ; end of alist definition
158 ;;; Functions for overriding beam settings
161 (define (overridden-property-alist context property setting value)
162 "Return an alist containing the current @{context} value of
163 @code{property} overriden by @code{(setting . value)}. "
164 (cons (cons setting value) (ly:context-property context property)))
166 (define-public (override-property-setting context property setting value)
167 "Like the C++ code that executes \\override, but without type
169 (ly:context-set-property!
171 (overridden-property-alist context property setting value)))
173 (define (revert-property-setting context property setting)
174 "Like the C++ code that executes \revert, but without type
177 (define (revert-member alist entry new)
178 "Return ALIST, with ENTRY removed. ALIST is not modified, instead
179 a fresh copy of the list-head is made."
182 ((equal? (car alist) entry) (revert-member (cdr alist) entry new))
183 (else (revert-member (cdr alist) entry (cons (car alist) new)))))
185 (ly:context-set-property!
187 (revert-member (ly:context-property context property) setting '())))
189 (define-public (override-beam-setting
190 time-signature rule-type rule . rest)
191 "Override the beam settings for the context in @var{rest},
192 for @var{time-signature} and @var{rule-type}, with the
193 new rule alist @var{rule}. "
194 (define (make-setting c)
196 (overridden-property-alist
199 (list time-signature rule-type)
201 (ly:context-set-property! c 'beamSettings new-settings)))
203 (let ((music-to-export
205 (make-apply-context make-setting)
206 (if (and (pair? rest) (symbol? (car rest)))
209 (ly:export music-to-export)))
211 (define-public (score-override-beam-setting
212 time-signature rule-type rule)
213 (override-beam-setting
214 time-signature rule-type rule 'Score))
216 (define-public (revert-beam-setting
217 time-signature rule-type . rest)
222 (revert-property-setting
225 (list time-signature rule-type))))
226 (if (and (pair? rest) (symbol? (car rest)))