Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(268)

Side by Side Diff: scm/tablature.scm

Issue 2191042: Tablature: proper support for tie/slur- and tie/glissando-constellations (Closed)
Patch Set: Created 14 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« scm/define-grobs.scm ('K') | « scm/define-grobs.scm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 ;;;; This file is part of LilyPond, the GNU music typesetter. 1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;; 2 ;;;;
3 ;;;; Copyright (C) 2009--2010 Marc Hohl <marc@hohlart.de> 3 ;;;; Copyright (C) 2009--2010 Marc Hohl <marc@hohlart.de>
4 ;;;; 4 ;;;;
5 ;;;; LilyPond is free software: you can redistribute it and/or modify 5 ;;;; LilyPond is free software: you can redistribute it and/or modify
6 ;;;; it under the terms of the GNU General Public License as published by 6 ;;;; it under the terms of the GNU General Public License as published by
7 ;;;; the Free Software Foundation, either version 3 of the License, or 7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version. 8 ;;;; (at your option) any later version.
9 ;;;; 9 ;;;;
10 ;;;; LilyPond is distributed in the hope that it will be useful, 10 ;;;; LilyPond is distributed in the hope that it will be useful,
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ;; get the font-size from victim (=TabNoteHead) to handle 168 ;; get the font-size from victim (=TabNoteHead) to handle
169 ;; grace notes properly 169 ;; grace notes properly
170 (ly:grob-set-property! grob 'font-size 170 (ly:grob-set-property! grob 'font-size
171 (ly:grob-property victim 'font-size)) 171 (ly:grob-property victim 'font-size))
172 (ly:grob-set-property! grob 'padding 0) 172 (ly:grob-set-property! grob 'padding 0)
173 ;; apply whiteout to each element of the list 173 ;; apply whiteout to each element of the list
174 (map stencil-whiteout 174 (map stencil-whiteout
175 (parentheses-item::calc-parenthesis-stencils grob))) 175 (parentheses-item::calc-parenthesis-stencils grob)))
176 (parentheses-item::calc-parenthesis-stencils grob)))) 176 (parentheses-item::calc-parenthesis-stencils grob))))
177 177
178 ;; helper functions for making tab note heads (in)visible
179 (define (hide-tab-note-head grob)
Neil Puttock 2010/09/16 21:14:19 This is a bit of a misnomer, since it indirectly m
180 (ly:grob-set-property! grob 'transparent #t)
181 (ly:grob-set-property! grob 'whiteout #f)
Neil Puttock 2010/09/16 21:14:19 can remove this
182 (ly:grob-set-nested-property! grob '(details tied-to) #t))
Neil Puttock 2010/09/16 21:14:19 This doesn't belong in 'details since it's set bey
183
184 (define (show-tab-note-head grob)
185 (ly:grob-set-property! grob 'transparent #f)
186 (ly:grob-set-property! grob 'whiteout #t)
Neil Puttock 2010/09/16 21:14:19 can remove this
187 (ly:grob-set-property! grob 'stencil
188 (lambda (grob)
189 (parenthesize-tab-note-head grob))))
190
178 ;; the handler for ties in tablature; according to TabNoteHead #'details, 191 ;; the handler for ties in tablature; according to TabNoteHead #'details,
179 ;; the 'tied to' note is handled differently after a line break 192 ;; the 'tied to' note is handled differently after a line break
180 (define-public (tie::handle-tab-note-head grob) 193 (define-public (tie::handle-tab-note-head grob)
181 (let* ((original (ly:grob-original grob)) 194 (let* ((original (ly:grob-original grob))
182 (tied-tab-note-head (ly:spanner-bound grob RIGHT)) 195 (tied-tab-note-head (ly:spanner-bound grob RIGHT))
183 (siblings (if (ly:grob? original) 196 (siblings (if (ly:grob? original)
184 (ly:spanner-broken-into original) '()))) 197 (ly:spanner-broken-into original) '())))
185 198
186 (if (and (>= (length siblings) 2) 199 (if (and (>= (length siblings) 2)
187 (eq? (car (last-pair siblings)) grob)) 200 (eq? (car (last-pair siblings)) grob))
188 ;; tie is split -> get TabNoteHead #'details 201 ;; tie is split -> get TabNoteHead #'details
189 (let* ((details (ly:grob-property tied-tab-note-head 'details)) 202 (let* ((details (ly:grob-property tied-tab-note-head 'details))
190 (tied-properties (assoc-get 'tied-properties details '())) 203 (tied-properties (assoc-get 'tied-properties details '()))
191 (tab-note-head-parenthesized (assoc-get 'parenthesize tied-proper ties #t)) 204 (tab-note-head-parenthesized (assoc-get 'parenthesize tied-proper ties #t))
192 ;; we need the begin-of-line entry in the 'break-visibility vecto r 205 ;; we need the begin-of-line entry in the 'break-visibility vecto r
193 (tab-note-head-visible 206 (tab-note-head-visible
194 (vector-ref (assoc-get 'break-visibility 207 (vector-ref (assoc-get 'break-visibility
195 tied-properties #(#f #f #t)) 2))) 208 tied-properties #(#f #f #t)) 2)))
196 209
197 (if tab-note-head-visible 210 (if tab-note-head-visible
198 ;; tab note head is visible 211 ;; tab note head is visible
199 (if tab-note-head-parenthesized 212 (if tab-note-head-parenthesized
200 (ly:grob-set-property! tied-tab-note-head 'stencil 213 (ly:grob-set-property! tied-tab-note-head 'stencil
201 (lambda (grob) 214 (lambda (grob)
202 (parenthesize-tab-note-head grob)))) 215 (parenthesize-tab-note-head grob))))
203 ;; tab note head is invisible 216 ;; tab note head is invisible
204 » (begin 217 » (hide-tab-note-head tied-tab-note-head)))
205 » (ly:grob-set-property! tied-tab-note-head 'transparent #t)
206 » (ly:grob-set-property! tied-tab-note-head 'whiteout #f))))
207 218
208 ;; tie is not split -> make fret number invisible 219 ;; tie is not split -> make fret number invisible
209 (begin 220 (hide-tab-note-head tied-tab-note-head))))
210 (ly:grob-set-property! tied-tab-note-head 'transparent #t) 221
211 (ly:grob-set-property! tied-tab-note-head 'whiteout #f))))) 222
212 223
213 ;; repeat ties occur within alternatives in a repeat construct; 224 ;; repeat ties occur within alternatives in a repeat construct;
214 ;; TabNoteHead #'details handles the appearance in this case 225 ;; TabNoteHead #'details handles the appearance in this case
215 (define-public (repeat-tie::handle-tab-note-head grob) 226 (define-public (repeat-tie::handle-tab-note-head grob)
216 (let* ((tied-tab-note-head (ly:grob-object grob 'note-head)) 227 (let* ((tied-tab-note-head (ly:grob-object grob 'note-head))
217 (details (ly:grob-property tied-tab-note-head 'details)) 228 (details (ly:grob-property tied-tab-note-head 'details))
218 (repeat-tied-properties (assoc-get 'repeat-tied-properties details '()) ) 229 (repeat-tied-properties (assoc-get 'repeat-tied-properties details '()) )
219 (tab-note-head-visible (assoc-get 'note-head-visible repeat-tied-proper ties #t)) 230 (tab-note-head-visible (assoc-get 'note-head-visible repeat-tied-proper ties #t))
220 (tab-note-head-parenthesized (assoc-get 'parenthesize repeat-tied-prope rties #t))) 231 (tab-note-head-parenthesized (assoc-get 'parenthesize repeat-tied-prope rties #t)))
221 232
222 (if tab-note-head-visible 233 (if tab-note-head-visible
223 ;; tab note head is visible 234 ;; tab note head is visible
224 (if tab-note-head-parenthesized 235 (if tab-note-head-parenthesized
225 (ly:grob-set-property! tied-tab-note-head 'stencil 236 (ly:grob-set-property! tied-tab-note-head 'stencil
226 (lambda (grob) 237 (lambda (grob)
227 (parenthesize-tab-note-head grob)))) 238 (parenthesize-tab-note-head grob))))
228 ;; tab note head is invisible 239 ;; tab note head is invisible
229 » (begin 240 » (hide-tab-note-head tied-tab-note-head))))
230 (ly:grob-set-property! tied-tab-note-head 'transparent #t)
231 (ly:grob-set-property! tied-tab-note-head 'whiteout #f)))))
232 241
233 ;; the slurs should not be too far apart from the corresponding fret number, so 242 ;; the slurs should not be too far apart from the corresponding fret number, so
234 ;; we move the slur towards the TabNoteHeads: 243 ;; we move the slur towards the TabNoteHeads; moreover, if the left fret number is
244 ;; "tied-to", we'll set it in parentheses:
235 (define-public (slur::draw-tab-slur grob) 245 (define-public (slur::draw-tab-slur grob)
236 ;; TODO: use a less "brute-force" method to decrease 246 ;; TODO: use a less "brute-force" method to decrease
237 ;; the distance between the slur ends and the fret numbers 247 ;; the distance between the slur ends and the fret numbers
238 (let* ((staff-space (ly:staff-symbol-staff-space grob)) 248 (let* ((original (ly:grob-original grob))
249 (left-bound (ly:spanner-bound original LEFT))
250 (left-tab-note-head (ly:grob-property left-bound 'cause))
251 (details (ly:grob-property left-tab-note-head 'details))
252 (tied-to (assoc-get 'tied-to details #f))
253 (staff-space (ly:staff-symbol-staff-space grob))
239 (control-points (ly:grob-property grob 'control-points)) 254 (control-points (ly:grob-property grob 'control-points))
240 (new-control-points (map 255 (new-control-points (map
241 (lambda (p) 256 (lambda (p)
242 (cons (car p) 257 (cons (car p)
243 (- (cdr p) 258 (- (cdr p)
244 (* staff-space 259 (* staff-space
245 (ly:grob-property grob 'direction) 260 (ly:grob-property grob 'direction)
246 0.35)))) 261 0.35))))
247 control-points))) 262 control-points)))
248 263
249 (ly:grob-set-property! grob 'control-points new-control-points) 264 (ly:grob-set-property! grob 'control-points new-control-points)
265 (if tied-to (show-tab-note-head left-tab-note-head))
250 (ly:slur::print grob))) 266 (ly:slur::print grob)))
251 267
268 ;; The glissando routine works similarly to the slur routine; if the
269 ;; fret number is "tied to", it should become visible again.
270 (define-public (glissando::draw-tab-glissando grob)
271 (let* ((original (ly:grob-original grob))
272 (left-tab-note-head (ly:spanner-bound original LEFT))
273 (details (ly:grob-property left-tab-note-head 'details))
274 (tied-to (assoc-get 'tied-to details #f))
275 (control-points (ly:grob-property grob 'control-points)))
Neil Puttock 2010/09/16 21:14:19 remove
276
277 (if tied-to
Neil Puttock 2010/09/16 21:14:19 (and tied-to (show-tab-note-head left-tab-not
278 (begin
279 (show-tab-note-head left-tab-note-head)
280 ;; increase left padding to avoid collision between
281 ;; closing parenthesis and glissando line
282 (ly:grob-set-nested-property! grob '(bound-details left padding) 0.75) ))
Neil Puttock 2010/09/16 21:14:19 this won't happen for tied notes after a break unl
283 (ly:line-spanner::print grob)))
284
252 ;; for \tabFullNotation, the stem tremolo beams are too big in comparison to 285 ;; for \tabFullNotation, the stem tremolo beams are too big in comparison to
253 ;; normal staves; this wrapper function scales accordingly: 286 ;; normal staves; this wrapper function scales accordingly:
254 (define-public (stem-tremolo::calc-tab-width grob) 287 (define-public (stem-tremolo::calc-tab-width grob)
255 (let ((width (ly:stem-tremolo::calc-width grob)) 288 (let ((width (ly:stem-tremolo::calc-width grob))
256 (staff-space (ly:staff-symbol-staff-space grob))) 289 (staff-space (ly:staff-symbol-staff-space grob)))
257 (/ width staff-space))) 290 (/ width staff-space)))
OLDNEW
« scm/define-grobs.scm ('K') | « scm/define-grobs.scm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b