1 ;;;; fret-diagrams.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004--2006 Carl D. Sorensen <c_sorensen@byu.edu>
7 (define (fret-parse-marking-list marking-list fret-count)
8 (let* ((fret-range (list 1 fret-count))
13 (let parse-item ((mylist marking-list))
14 (if (not (null? mylist))
15 (let* ((my-item (car mylist)) (my-code (car my-item)))
17 ((or (eq? my-code 'open)(eq? my-code 'mute))
18 (set! xo-list (cons* my-item xo-list)))
20 (set! barre-list (cons* (cdr my-item) barre-list)))
21 ((eq? my-code 'place-fret)
22 (set! dot-list (cons* (cdr my-item) dot-list))))
23 (parse-item (cdr mylist)))))
25 ;; calculate fret-range
26 (let ((maxfret 0) (minfret 99))
27 (let updatemax ((fret-list dot-list))
30 (let ((fretval (second (car fret-list))))
31 (if (> fretval maxfret) (set! maxfret fretval))
32 (if (< fretval minfret) (set! minfret fretval))
33 (updatemax (cdr fret-list)))))
34 (if (> maxfret fret-count)
35 (set! fret-range (list minfret
36 (let ((upfret (- (+ minfret fret-count) 1)))
37 (if (> maxfret upfret) maxfret upfret)))))
38 ; subtract fret from dots
39 (set! dot-list (subtract-base-fret (- (car fret-range) 1) dot-list)))
40 (acons 'fret-range fret-range
41 (acons 'barre-list barre-list
42 (acons 'dot-list dot-list
43 (acons 'xo-list xo-list '()))))))
47 (define (subtract-base-fret base-fret dot-list)
48 "Subtract @var{base-fret} from every fret in @var{dot-list}"
51 (let ((this-list (car dot-list)))
52 (cons* (list (car this-list) (- (second this-list) base-fret) (if (null? (cddr this-list))
55 (subtract-base-fret base-fret (cdr dot-list))))))
57 (define (sans-serif-stencil layout props mag text)
58 "create a stencil in sans-serif font based on @var{layout} and @var{props}
59 with magnification @varr{mag} of the string @var{text}."
60 (let* ((my-props (prepend-alist-chain 'font-size (stepmag mag)
61 (prepend-alist-chain 'font-family 'sans props))))
62 (interpret-markup layout my-props text)))
65 (define (draw-strings string-count fret-range th size)
66 "Draw the strings (vertical lines) for a fret diagram with
67 @var{string-count} strings and frets as indicated in @var{fret-range}.
68 Line thickness is given by @var{th}, fret & string spacing by
70 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
71 (sl (* (+ fret-count 1) size))
73 (half-thickness (* sth 0.5))
75 (string-stencil (ly:make-stencil (list 'draw-line sth 0 0 0 sl)
76 (cons (- half-thickness) half-thickness)
77 (cons (- half-thickness) (+ sl half-thickness)))))
78 (if (= string-count 1)
80 (ly:stencil-combine-at-edge
81 (draw-strings (- string-count 1) fret-range th size) X RIGHT
85 (define (draw-fret-lines fret-count string-count th size)
86 "Draw @var{fret-count} frets (horizontal lines) for a fret diagram
87 with @var{string-count} strings. Line thickness is given by @var{th},
88 fret & string spacing by @var{size}. "
89 (let* ((fret-length (* (- string-count 1) size))
91 (half-thickness (* sth 0.5))
93 (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
95 (cons (- size half-thickness) (+ size half-thickness)))))
98 (ly:stencil-combine-at-edge fret-line Y UP
99 (draw-fret-lines (- fret-count 1) string-count th size)
102 (define (draw-thick-top-fret props string-count th size)
103 "Draw a thick top fret for a fret diagram whose base fret is not 1."
104 (let* ((sth (* th size))
105 ; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
106 (top-fret-thick (* sth 3.0))
107 ; (top-half-thick (* top-fret-thick 0.5))
108 (half-thick (* sth 0.5))
110 (x2 (+ half-thick (* size (- string-count 1))))
112 (y2 (+ top-fret-thick half-thick))
113 (x-extent (cons (- x1) x2))
114 (y-extent (cons 0 y2)))
115 (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
119 (define (draw-frets layout props fret-range string-count th size)
120 "Draw the frets (horizontal lines) for a fret diagram with
121 @var{string-count} strings and frets as indicated in @var{fret-range}.
122 Line thickness is given by @var{th}, fret & string spacing by
124 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
125 (fret-length (* (- string-count 1) size))
126 (half-thickness (* th 0.5))
127 (base-fret (car fret-range)))
128 (ly:stencil-combine-at-edge
129 (draw-fret-lines fret-count string-count th size) Y UP
131 (draw-thick-top-fret props string-count th size)
132 (draw-fret-lines 1 string-count th size))
136 (define (draw-dots layout props string-count fret-range size finger-code
137 dot-position dot-radius dot-thickness dot-list)
138 "Make dots for fret diagram."
140 (let* ((scale-dot-radius (* size dot-radius))
141 (scale-dot-thick (* size dot-thickness))
142 (dot-color (chain-assoc-get 'dot-color props 'black))
143 ; (finger-xoffset (chain-assoc-get 'finger-xoffset props -0.25))
144 ; (finger-yoffset (chain-assoc-get 'finger-yoffset props (- size)))
145 (finger-xoffset -0.25)
146 (finger-yoffset (- (* size 0.5)))
147 ; (dot-label-font-mag (* scale-dot-radius (chain-assoc-get 'dot-label-font-mag props 1.0)))
148 (dot-label-font-mag scale-dot-radius)
149 ; (string-label-font-mag (* size (chain-assoc-get 'label-font-mag props 0.7)))
150 (string-label-font-mag (* size 0.6))
151 (fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
152 (mypair (car dot-list))
153 (restlist (cdr dot-list))
154 (xpos (* size (- string-count (car mypair))))
155 ;TODO -- figure out what 4 is and get rid of it
157 (ypos (* size (+ 4 (- fret-count (cadr mypair) dot-position ))))
158 (extent (cons (- scale-dot-radius) scale-dot-radius))
159 (finger (caddr mypair))
160 (finger (if (number? finger) (number->string finger) finger))
161 (dotstencil (if (eq? dot-color 'white)
163 (make-circle-stencil scale-dot-radius scale-dot-thick #t)
166 (- scale-dot-radius (* 0.5 scale-dot-thick)) 0 #t)
168 (make-circle-stencil scale-dot-radius scale-dot-thick #t)))
169 (positioned-dot (begin
170 ;(display dotstencil)
171 (ly:stencil-translate-axis
172 (ly:stencil-translate-axis dotstencil xpos X)
176 (if (or (eq? finger '())(eq? finger-code 'none))
178 (if (eq? finger-code 'in-dot)
179 (let* ((finger-label (centered-stencil
180 (sans-serif-stencil layout props
181 dot-label-font-mag finger))))
182 (ly:stencil-translate-axis
183 (ly:stencil-translate-axis
186 (if (eq? dot-color 'white)
188 (ly:stencil-in-color finger-label 1 1 1)))
191 (if (eq? finger-code 'below-string)
194 (ly:stencil-translate-axis
195 (ly:stencil-translate-axis
196 (centered-stencil (sans-serif-stencil layout props
197 string-label-font-mag finger))
199 (* size finger-yoffset) Y))
205 (draw-dots layout props string-count fret-range size finger-code
206 dot-position dot-radius dot-thickness restlist)
207 labeled-dot-stencil))))
209 (define (draw-xo layout props string-count fret-range size xo-list)
210 "Put open and mute string indications on diagram, as contained in @var{xo-list}."
211 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
212 ; (xo-font-mag (* size (chain-assoc-get 'xo-font-magnification props 0.5)))
213 (xo-font-mag (* size 0.5))
214 ; (xo-horizontal-offset (* size (chain-assoc-get 'xo-horizontal-offset props -0.35)))
215 (xo-horizontal-offset (* size -0.35))
216 (mypair (car xo-list))
217 (restlist (cdr xo-list))
218 (glyph-string (if (eq? (car mypair) 'mute) "X" "O"))
219 (xpos (+ (* (- string-count (cadr mypair)) size) xo-horizontal-offset ))
220 (glyph-stencil (ly:stencil-translate-axis
221 (sans-serif-stencil layout props (* size xo-font-mag) glyph-string) xpos X)))
225 (draw-xo layout props string-count fret-range size restlist)
228 (define (make-bezier-sandwich-list left right bottom height thickness)
229 " Make the argument list for a horizontal bezier sandwich from
230 @var{left} to @var{right} with a bottom at @var{bottom}, a height of
231 @var{height}, and a thickness of @var{thickness}."
232 (let* ((width (+ (- right left) 1))
233 (x1 (+ (* width thickness) left))
234 (x2 (- right (* width thickness)))
235 (bottom-control-point-height (+ bottom (- height thickness)))
236 (top-control-point-height (+ bottom height)))
237 ; order of points is: left cp low, right cp low, right end low, left end low
238 ; right cp high, left cp high, left end high, right end high.
239 (list (cons x1 bottom-control-point-height) (cons x2 bottom-control-point-height) (cons right bottom) (cons left bottom)
240 (cons x2 top-control-point-height) (cons x1 top-control-point-height) (cons left bottom) (cons right bottom))))
242 (define (draw-barre layout props string-count fret-range size finger-code dot-position dot-radius barre-list)
243 "Create barre indications for a fret diagram"
244 (if (not (null? barre-list))
245 (let* ((string1 (caar barre-list))
246 (string2 (cadar barre-list))
247 (fret (caddar barre-list))
248 (barre-type (chain-assoc-get 'barre-type props 'curved))
249 (scale-dot-radius (* size dot-radius))
250 (barre-vertical-offset (chain-assoc-get 'barre-vertical-offset props 0.5))
251 ;; 2 is 1 for empty fret at bottom of figure + 1 for interval (top-fret - fret + 1) -- not an arbitrary constant
252 (dot-center-y (* size
253 (- (+ 2 (- (cadr fret-range) fret)) dot-position)))
254 (bottom (+ dot-center-y (* barre-vertical-offset scale-dot-radius)))
255 (left (* size (- string-count string1)))
256 (right (* size (- string-count string2)))
257 ;; (bezier-thick (chain-assoc-get 'bezier-thickness props 0.1))
259 ;; (bezier-height (chain-assoc-get 'bezier-height props 0.5))
261 (bezier-list (make-bezier-sandwich-list left right bottom (* size bezier-height) (* size bezier-thick)))
262 (barre-stencil (if (eq? barre-type 'straight)
263 (ly:make-stencil (list 'draw-line (* size dot-radius) left dot-center-y right dot-center-y)
265 (cons (- dot-center-y scale-dot-radius) (+ dot-center-y scale-dot-radius)))
266 (ly:make-stencil (list 'bezier-sandwich `(quote ,bezier-list) (* size bezier-thick))
268 (cons bottom (+ bottom (* size bezier-height)))))))
269 (if (not (null? (cdr barre-list)))
270 (ly:stencil-add barre-stencil
271 (draw-barre layout props string-count fret-range size finger-code
272 dot-position dot-radius (cdr barre-list)))
275 (define (stepmag mag)
276 "Calculate the font step necessary to get a desired magnification"
277 (* 6 (/ (log mag) (log 2))))
279 (define (label-fret layout props string-count fret-range size)
280 "Label the base fret on a fret diagram"
281 (let* ((base-fret (car fret-range))
282 ; (label-font-mag (chain-assoc-get 'label-font-mag props 0.7))
284 ; (label-vertical-offset (chain-assoc-get 'fret-label-vertical-offset props -0.2))
285 (label-vertical-offset -0.2)
286 (number-type (chain-assoc-get 'number-type props 'roman-lower))
287 (fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
290 ((equal? number-type 'roman-lower) (format #f "~(~:@r~)" base-fret))
291 ((equal? number-type 'roman-upper) (format #f "~:@r" base-fret))
292 ((equal? 'arabic number-type) (format #f "~d" base-fret))
293 (else (format #f "~(~:@r~)" base-fret)))))
294 (ly:stencil-translate-axis
295 (sans-serif-stencil layout props (* size label-font-mag) label-text)
296 (* size (+ fret-count label-vertical-offset)) Y)))
298 (define-builtin-markup-command (fret-diagram-verbose layout props marking-list)
300 "Make a fret diagram containing the symbols indicated in @var{marking-list}.
305 \\markup \\fret-diagram-verbose
306 #'((mute 6) (mute 5) (open 4)
307 (place-fret 3 2) (place-fret 2 3) (place-fret 1 2))
311 produces a standard D@tie{}chord diagram without fingering indications.
313 Possible elements in @var{marking-list}:
316 @item (mute @var{string-number})
317 Place a small @q{x} at the top of string @var{string-number}.
319 @item (open @var{string-number})
320 Place a small @q{o} at the top of string @var{string-number}.
322 @item (barre @var{start-string} @var{end-string} @var{fret-number})
323 Place a barre indicator (much like a tie) from string @var{start-string}
324 to string @var{end-string} at fret @var{fret-number}.
326 @item (place-fret @var{string-number} @var{fret-number} @var{finger-value})
327 Place a fret playing indication on string @var{string-number} at fret
328 @var{fret-number} with an optional fingering label @var{finger-value}.
329 By default, the fret playing indicator is a solid dot. This can be
330 changed by setting the value of the variable @var{dot-color}. If the
331 @var{finger} part of the @code{place-fret} element is present,
332 @var{finger-value} will be displayed according to the setting of the
333 variable @var{finger-code}. There is no limit to the number of fret
334 indications per string.
336 (make-fret-diagram layout props marking-list))
338 (define (make-fret-diagram layout props marking-list)
339 " Make a fret diagram markup"
341 ; note: here we get items from props that are needed in this routine, or that are needed in more than one
342 ; of the procedures called from this routine. If they're only used in one of the sub-procedure, they're
343 ; obtained in that procedure
345 (size (chain-assoc-get 'size props 1.0)) ; needed for everything
346 ;TODO -- get string-count directly from length of stringTunings; requires FretDiagram engraver, which is not yet available
347 ;TODO -- adjust padding for fret label? it appears to be too close to dots
348 (string-count (chain-assoc-get 'string-count props 6)) ; needed for everything
349 (fret-count (chain-assoc-get 'fret-count props 4)) ; needed for everything
350 (finger-code (chain-assoc-get 'finger-code props 'none)) ; needed for both draw-dots and draw-barre
351 (default-dot-radius (if (eq? finger-code 'in-dot) 0.425 0.25)) ; bigger dots if labeled
352 (default-dot-position (if (eq? finger-code 'in-dot) (- 0.95 default-dot-radius) 0.6)) ; move up to make room for bigger if labeled
353 (dot-radius (chain-assoc-get 'dot-radius props default-dot-radius)) ; needed for both draw-dots and draw-barre
354 (dot-position (chain-assoc-get 'dot-position props default-dot-position)) ; needed for both draw-dots and draw-barre
355 (th (* (ly:output-def-lookup layout 'line-thickness)
356 (chain-assoc-get 'thickness props 0.5))) ; needed for both draw-frets and draw-strings
358 (alignment (chain-assoc-get 'align-dir props -0.4)) ; needed only here
359 ; (xo-padding (* th (chain-assoc-get 'padding props 2))) ; needed only here
360 (label-space (* 0.25 size))
361 (xo-padding (* th size 5))
362 (label-dir (chain-assoc-get 'label-dir props RIGHT))
363 (parameters (fret-parse-marking-list marking-list fret-count))
364 (dot-list (cdr (assoc 'dot-list parameters)))
365 (xo-list (cdr (assoc 'xo-list parameters)))
366 (fret-range (cdr (assoc 'fret-range parameters)))
367 (barre-list (cdr (assoc 'barre-list parameters)))
368 (fret-diagram-stencil (ly:stencil-add
369 (draw-strings string-count fret-range th size)
370 (draw-frets layout props fret-range string-count th size))))
371 (if (not (null? barre-list))
372 (set! fret-diagram-stencil (ly:stencil-add
373 (draw-barre layout props string-count fret-range size finger-code
374 dot-position dot-radius barre-list)
375 fret-diagram-stencil)))
376 (if (not (null? dot-list))
377 (set! fret-diagram-stencil (ly:stencil-add
379 (draw-dots layout props string-count fret-range size finger-code
380 dot-position dot-radius th dot-list))))
381 (if (not (null? xo-list))
382 (set! fret-diagram-stencil (ly:stencil-combine-at-edge
383 fret-diagram-stencil Y UP
384 (draw-xo layout props string-count fret-range size xo-list) xo-padding)))
385 (if (> (car fret-range) 1)
386 (set! fret-diagram-stencil
387 (ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
388 (label-fret layout props string-count fret-range size) label-space)))
389 (ly:stencil-aligned-to fret-diagram-stencil X alignment)
392 (define-builtin-markup-command (fret-diagram layout props definition-string)
394 "Make a (guitar) fret diagram. For example, say
397 \\markup \\fret-diagram #\"s:0.75;6-x;5-x;4-o;3-2;2-3;1-2;\"
401 for fret spacing 3/4 of staff space, D@tie{}chord diagram.
403 Syntax rules for @var{definition-string}:
408 Diagram items are separated by semicolons.
415 @code{s:}@var{number} -- Set the fret spacing of the diagram (in staff
420 @code{t:}@var{number} -- Set the line thickness (in staff spaces).
424 @code{h:}@var{number} -- Set the height of the diagram in frets.
428 @code{w:}@var{number} -- Set the width of the diagram in strings.
432 @code{f:}@var{number} -- Set fingering label type
433 (0@tie{}= none, 1@tie{}= in circle on string, 2@tie{}= below string).
437 @code{d:}@var{number} -- Set radius of dot, in terms of fret spacing.
441 @code{p:}@var{number} -- Set the position of the dot in the fret space.
442 0.5 is centered; 1@tie{}is on lower fret bar, 0@tie{}is on upper fret bar.
446 @code{c:}@var{string1}@code{-}@var{string2}@code{-}@var{fret} -- Include a
447 barre mark from @var{string1} to @var{string2} on @var{fret}.
450 @var{string}@code{-}@var{fret} -- Place a dot on @var{string} at @var{fret}.
451 If @var{fret} is @samp{o}, @var{string} is identified as open.
452 If @var{fret} is @samp{x}, @var{string} is identified as muted.
455 @var{string}@code{-}@var{fret}@code{-}@var{fingering} -- Place a dot on
456 @var{string} at @var{fret}, and label with @var{fingering} as defined
457 by the @code{f:} code.
461 Note: There is no limit to the number of fret indications per string.
463 (let ((definition-list (fret-parse-definition-string props definition-string)))
464 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
466 (define (fret-parse-definition-string props definition-string)
467 "parse a fret diagram string and return a pair containing:
468 props, modified as necessary by the definition-string
469 a fret-indication list with the appropriate values"
470 (let* ((fret-count 4)
472 (fret-range (list 1 fret-count))
478 (items (string-split definition-string #\;)))
479 (let parse-item ((myitems items))
480 (if (not (null? (cdr myitems)))
481 (let ((test-string (car myitems)))
482 (case (car (string->list (substring test-string 0 1)))
483 ((#\s) (let ((size (get-numeric-from-key test-string)))
484 (set! new-props (acons 'size size new-props))))
485 ((#\f) (let* ((finger-code (get-numeric-from-key test-string))
486 (finger-id (case finger-code
489 ((2) 'below-string))))
491 (acons 'finger-code finger-id new-props))))
492 ((#\c) (set! output-list (cons-fret (cons 'barre (numerify (string-split (substring test-string 2) #\-)))
494 ((#\h) (let ((fret-count (get-numeric-from-key test-string)))
495 (set! new-props (acons 'fret-count fret-count new-props))))
496 ((#\w) (let ((string-count (get-numeric-from-key test-string)))
497 (set! new-props (acons 'string-count string-count new-props))))
498 ((#\d) (let ((dot-size (get-numeric-from-key test-string)))
499 (set! new-props (acons 'dot-radius dot-size new-props))))
500 ((#\p) (let ((dot-position (get-numeric-from-key test-string)))
501 (set! new-props (acons 'dot-position dot-position new-props))))
503 (let ((this-list (string-split test-string #\-)))
504 (if (string->number (cadr this-list))
505 (set! output-list (cons-fret (cons 'place-fret (numerify this-list)) output-list))
506 (if (equal? (cadr this-list) "x" )
507 (set! output-list (cons-fret (list 'mute (string->number (car this-list))) output-list))
508 (set! output-list (cons-fret (list 'open (string->number (car this-list))) output-list)))))))
509 (parse-item (cdr myitems)))))
510 (if (eq? new-props '())
511 `(,props . ,output-list)
512 `(,(cons new-props props) . ,output-list))))
514 (define (cons-fret new-value old-list)
515 " Put together a fret-list in the format desired by parse-string "
516 (if (eq? old-list '())
518 (cons* new-value old-list)))
520 (define (get-numeric-from-key keystring)
521 "Get the numeric value from a key of the form k:val"
522 (string->number (substring keystring 2 (string-length keystring))))
524 (define (numerify mylist)
525 "Convert string values to numeric or character"
528 (let ((numeric-value (string->number (car mylist))))
530 (cons* numeric-value (numerify (cdr mylist)))
531 (cons* (car (string->list (car mylist))) (numerify (cdr mylist)))))))
533 (define-builtin-markup-command (fret-diagram-terse layout props definition-string)
535 "Make a fret diagram markup using terse string-based syntax.
540 \\markup \\fret-diagram-terse #\"x;x;o;2;3;2;\"
544 for a D@tie{}chord diagram.
546 Syntax rules for @var{definition-string}:
551 Strings are terminated by semicolons; the number of semicolons
552 is the number of strings in the diagram.
555 Mute strings are indicated by @samp{x}.
558 Open strings are indicated by @samp{o}.
561 A number indicates a fret indication at that fret.
564 If there are multiple fret indicators desired on a string, they
565 should be separated by spaces.
568 Fingerings are given by following the fret number with a @code{-},
569 followed by the finger indicator, e.g. @samp{3-2} for playing the third
570 fret with the second finger.
573 Where a barre indicator is desired, follow the fret (or fingering) symbol
574 with @code{-(} to start a barre and @code{-)} to end the barre.
577 ;TODO -- change syntax to fret\string-finger
578 (let ((definition-list (fret-parse-terse-definition-string props definition-string)))
579 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
581 (define (fret-parse-terse-definition-string props definition-string)
582 "parse a fret diagram string that uses terse syntax; return a pair containing:
583 props, modified to include the string-count determined by the definition-string
584 a fret-indication list with the appropriate values"
585 ;TODO -- change syntax to fret\string-finger
586 (let* ((barre-start-list '())
589 (items (string-split definition-string #\;))
590 (string-count (- (length items) 1)))
591 (let parse-item ((myitems items))
592 (if (not (null? (cdr myitems)))
593 (let* ((test-string (car myitems))
594 (current-string (- (length myitems) 1))
595 (indicators (string-split test-string #\ )))
596 (let parse-indicators ((myindicators indicators))
597 (if (not (eq? '() myindicators))
598 (let* ((this-list (string-split (car myindicators) #\-))
599 (max-element-index (- (length this-list) 1))
600 (last-element (car (list-tail this-list max-element-index)))
601 (fret (if (string->number (car this-list)) (string->number (car this-list)) (car this-list))))
602 (if (equal? last-element "(")
604 (set! barre-start-list (cons-fret (list current-string fret) barre-start-list))
605 (set! this-list (list-head this-list max-element-index))))
606 (if (equal? last-element ")")
607 (let* ((this-barre (get-sub-list fret barre-start-list))
608 (insert-index (- (length this-barre) 1)))
609 (set! output-list (cons-fret (cons* 'barre (car this-barre) current-string (cdr this-barre))
611 (set! this-list (list-head this-list max-element-index))))
613 (set! output-list (cons-fret (cons* 'place-fret current-string (drop-paren (numerify this-list))) output-list))
614 (if (equal? (car this-list) "x" )
615 (set! output-list (cons-fret (list 'mute current-string) output-list))
616 (set! output-list (cons-fret (list 'open current-string) output-list))))
617 (parse-indicators (cdr myindicators)))))
618 (parse-item (cdr myitems)))))
619 (set! new-props (acons 'string-count string-count new-props))
621 `(,(cons new-props props) . ,output-list)))
623 (define (drop-paren item-list)
624 " drop a final parentheses from a fret indication list resulting from a terse string specification of barre."
625 (if (> (length item-list) 0)
626 (let* ((max-index (- (length item-list) 1))
627 (last-element (car (list-tail item-list max-index))))
628 (if (or (equal? last-element ")") (equal? last-element "("))
629 (list-head item-list max-index)
633 (define (get-sub-list value master-list)
634 " Get a sub-list whose cadr is equal to @var{value} from @var{master-list}"
635 (if (eq? master-list '())
637 (let ((sublist (car master-list)))
638 (if (equal? (cadr sublist) value)
640 (get-sub-list value (cdr master-list))))))