1 ;;;; fret-diagrams.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004 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)))))
24 ; calculate fret-range
25 (let ((maxfret 0) (minfret 99))
26 (let updatemax ((fret-list dot-list))
29 (let ((fretval (second (car fret-list))))
30 (if (> fretval maxfret) (set! maxfret fretval))
31 (if (< fretval minfret) (set! minfret fretval))
32 (updatemax (cdr fret-list)))))
33 (if (> maxfret fret-count)
34 (set! fret-range (list minfret
35 (let ((upfret (- (+ minfret fret-count) 1)))
36 (if (> maxfret upfret) maxfret upfret)))))
37 ; subtract fret from dots
38 (set! dot-list (subtract-base-fret (- (car fret-range) 1) dot-list)))
39 (acons 'fret-range fret-range
40 (acons 'barre-list barre-list
41 (acons 'dot-list dot-list
42 (acons 'xo-list xo-list '()))))))
44 (define (subtract-base-fret base-fret dot-list)
45 "Subtract @var{base-fret} from every fret in @var{dot-list}"
48 (let ((this-list (car dot-list)))
49 (cons* (list (car this-list) (- (second this-list) base-fret) (if (null? (cddr this-list))
52 (subtract-base-fret base-fret (cdr dot-list))))))
54 (define (sans-serif-stencil layout props mag text)
55 "create a stencil in sans-serif font based on @var{layout} and @var{props}
56 with magnification @varr{mag} of the string @var{text}."
57 (let* ((my-props (prepend-alist-chain 'font-size (stepmag mag)
58 (prepend-alist-chain 'font-family 'sans props))))
59 (interpret-markup layout my-props text)))
61 (define (sans-serif-stencil-white layout props mag text)
62 "create a stencil with white text in sans-serif font based on @var{layout} and @var{props}
63 with magnification @varr{mag} of the string @var{text}."
64 (let* ((text-stencil (sans-serif-stencil layout props mag text))
65 (x-extent (ly:stencil-extent text-stencil X))
66 (y-extent (ly:stencil-extent text-stencil Y))
67 (c `(white-text ,(* 2 mag) ,text))) ;urg -- workaround for using ps font
68 (ly:make-stencil c x-extent y-extent))) ;urg -- extent is not from ps font, but we hope it's close
71 (define (draw-strings string-count fret-range th size)
72 "Draw the strings (vertical lines) for a fret diagram with @var{string-count} strings and frets as indicated
73 in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
74 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
75 (sl (* (+ fret-count 1) size))
77 (half-thickness (* sth 0.5))
79 (string-stencil (ly:make-stencil (list 'draw-line sth 0 0 0 sl)
80 (cons (- half-thickness) half-thickness)
81 (cons (- half-thickness) (+ sl half-thickness)))))
82 (if (= string-count 1)
84 (ly:stencil-combine-at-edge
85 (draw-strings (- string-count 1) fret-range th size) X RIGHT
89 (define (draw-fret-lines fret-count string-count th size)
90 "Draw @var{fret-count} frets (horizontal lines) for a fret diagram with @var{string-count} strings.
91 Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
92 (let* ((fret-length (* (- string-count 1) size))
94 (half-thickness (* sth 0.5))
96 (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
98 (cons (- size half-thickness) (+ size half-thickness)))))
101 (ly:stencil-combine-at-edge fret-line Y UP
102 (draw-fret-lines (- fret-count 1) string-count th size)
105 (define (draw-thick-top-fret props string-count th size)
106 "Draw a thick top fret for a fret diagram whose base fret is not 1."
107 (let* ((sth (* th size))
108 ; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
109 (top-fret-thick (* sth 3.0))
110 ; (top-half-thick (* top-fret-thick 0.5))
111 (half-thick (* sth 0.5))
113 (x2 (+ half-thick (* size (- string-count 1))))
115 (y2 (+ top-fret-thick half-thick))
116 (x-extent (cons (- x1) x2))
117 (y-extent (cons 0 y2)))
118 (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
122 (define (draw-frets layout props fret-range string-count th size)
123 "Draw the frets (horizontal lines) for a fret diagram with @var{string-count} strings and frets as indicated
124 in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
125 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
126 (fret-length (* (- string-count 1) size))
127 (half-thickness (* th 0.5))
128 (base-fret (car fret-range)))
129 (ly:stencil-combine-at-edge
130 (draw-fret-lines fret-count string-count th size) Y UP
132 (draw-thick-top-fret props string-count th size)
133 (draw-fret-lines 1 string-count th size))
137 (define (centered-stencil stencil)
138 "Center stencil @var{stencil} in both the X and Y directions"
139 (let* ((output-stencil stencil))
140 ; (if (= (cadr (ly:version)) 3)
142 (ly:stencil-align-to! output-stencil Y 0)
143 (ly:stencil-align-to! output-stencil X 0)
145 ; (ly:stencil-align-to (ly:stencil-align-to text-stencil X 0) Y 0))))
147 (define (draw-dots layout props string-count fret-range size finger-code dot-position dot-radius dot-list)
148 "Make dots for fret diagram."
149 (let* ((scale-dot-radius (* size dot-radius))
150 (dot-color (chain-assoc-get 'dot-color props 'black))
151 ; (finger-xoffset (chain-assoc-get 'finger-xoffset props -0.25))
152 ; (finger-yoffset (chain-assoc-get 'finger-yoffset props (- size)))
153 (finger-xoffset -0.25)
154 (finger-yoffset (- size))
155 ; (dot-label-font-mag (* scale-dot-radius (chain-assoc-get 'dot-label-font-mag props 1.0)))
156 (dot-label-font-mag scale-dot-radius)
157 ; (string-label-font-mag (* size (chain-assoc-get 'label-font-mag props 0.7)))
158 (string-label-font-mag (* size 0.7))
159 (fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
160 (mypair (car dot-list))
161 (restlist (cdr dot-list))
162 (xpos (* size (- string-count (car mypair))))
163 ;TODO -- figure out what 4 is and get rid of it
165 (ypos (* size (+ 4 (- fret-count (cadr mypair) dot-position ))))
166 (extent (cons (- scale-dot-radius) scale-dot-radius))
167 (finger (caddr mypair))
168 (finger (if (number? finger) (number->string finger) finger))
169 (dotstencil (if (eq? dot-color 'white)
171 (ly:make-stencil (list 'white-dot 0 0 scale-dot-radius) extent extent))
172 (ly:make-stencil (list 'dot 0 0 scale-dot-radius ) extent extent)))
173 (positioned-dot (ly:stencil-translate-axis
174 (ly:stencil-translate-axis dotstencil xpos X)
177 (if (or (eq? finger '())(eq? finger-code 'none))
179 (if (eq? finger-code 'in-dot)
180 (let* ((dot-proc (if (eq? dot-color 'white) 'white-dot 'dot)))
182 (ly:stencil-translate-axis
183 (ly:stencil-translate-axis
184 (if (eq? dot-color 'white)
185 (centered-stencil (sans-serif-stencil layout props dot-label-font-mag finger))
186 (centered-stencil (sans-serif-stencil-white layout props
187 dot-label-font-mag finger)))
190 (ly:stencil-translate-axis
191 (ly:stencil-translate-axis
192 (ly:make-stencil (list dot-proc 0 0 scale-dot-radius) extent extent)
195 (if (eq? finger-code 'below-string)
198 (ly:stencil-translate-axis
199 (ly:stencil-translate-axis
200 (centered-stencil (sans-serif-stencil layout props
201 string-label-font-mag finger)) xpos X)
202 (* size finger-yoffset) Y))
208 (draw-dots layout props string-count fret-range size finger-code
209 dot-position dot-radius restlist)
210 labeled-dot-stencil))))
212 (define (draw-xo layout props string-count fret-range size xo-list)
213 "Put open and mute string indications on diagram, as contained in @var{xo-list}."
214 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
215 ; (xo-font-mag (* size (chain-assoc-get 'xo-font-magnification props 0.5)))
216 (xo-font-mag (* size 0.5))
217 ; (xo-horizontal-offset (* size (chain-assoc-get 'xo-horizontal-offset props -0.35)))
218 (xo-horizontal-offset (* size -0.35))
219 (mypair (car xo-list))
220 (restlist (cdr xo-list))
221 (glyph-string (if (eq? (car mypair) 'mute) "X" "O"))
222 (xpos (+ (* (- string-count (cadr mypair)) size) xo-horizontal-offset ))
223 (glyph-stencil (ly:stencil-translate-axis
224 (sans-serif-stencil layout props (* size xo-font-mag) glyph-string) xpos X)))
228 (draw-xo layout props string-count fret-range size restlist)
231 (define (make-bezier-sandwich-list left right bottom height thickness)
232 " Make the argument list for a horizontal bezier sandwich from @var{left} to @var{right} with a bottom at @var{bottom},
233 a height of @var{height}, and a thickness of @var{thickness}."
234 (let* ((width (+ (- right left) 1))
235 (x1 (+ (* width thickness) left))
236 (x2 (- right (* width thickness)))
237 (bottom-control-point-height (+ bottom (- height thickness)))
238 (top-control-point-height (+ bottom height)))
239 ; order of points is: left cp low, right cp low, right end low, left end low
240 ; right cp high, left cp high, left end high, right end high.
241 (list (cons x1 bottom-control-point-height) (cons x2 bottom-control-point-height) (cons right bottom) (cons left bottom)
242 (cons x2 top-control-point-height) (cons x1 top-control-point-height) (cons left bottom) (cons right bottom))))
244 (define (draw-barre layout props string-count fret-range size finger-code dot-position dot-radius barre-list)
245 "Create barre indications for a fret diagram"
246 (if (not (null? barre-list))
247 (let* ((string1 (caar barre-list))
248 (string2 (cadar barre-list))
249 (fret (caddar barre-list))
250 (barre-type (chain-assoc-get 'barre-type props 'curved))
251 (scale-dot-radius (* size dot-radius))
252 (barre-vertical-offset (chain-assoc-get 'barre-vertical-offset props 0.5))
253 ;; 2 is 1 for empty fret at bottom of figure + 1 for interval (top-fret - fret + 1) -- not an arbitrary constant
254 (dot-center-y (* size
255 (- (+ 2 (- (cadr fret-range) fret)) dot-position)))
256 (bottom (+ dot-center-y (* barre-vertical-offset scale-dot-radius)))
257 (left (* size (- string-count string1)))
258 (right (* size (- string-count string2)))
259 ;; (bezier-thick (chain-assoc-get 'bezier-thickness props 0.1))
261 ;; (bezier-height (chain-assoc-get 'bezier-height props 0.5))
263 (bezier-list (make-bezier-sandwich-list left right bottom (* size bezier-height) (* size bezier-thick)))
264 (barre-stencil (if (eq? barre-type 'straight)
265 (ly:make-stencil (list 'draw-line (* size dot-radius) left dot-center-y right dot-center-y)
267 (cons (- dot-center-y scale-dot-radius) (+ dot-center-y scale-dot-radius)))
268 (ly:make-stencil (list 'bezier-sandwich `(quote ,bezier-list) (* size bezier-thick))
270 (cons bottom (+ bottom (* size bezier-height)))))))
271 (if (not (null? (cdr barre-list)))
272 (ly:stencil-add barre-stencil
273 (draw-barre layout props string-count fret-range size finger-code
274 dot-position dot-radius (cdr barre-list)))
278 (define (stepmag mag)
279 "Calculate the font step necessary to get a desired magnification"
280 (* 6 (/ (log mag) (log 2))))
282 (define (label-fret layout props string-count fret-range size)
283 "Label the base fret on a fret diagram"
284 (let* ((base-fret (car fret-range))
285 ; (label-font-mag (chain-assoc-get 'label-font-mag props 0.7))
287 ; (label-vertical-offset (chain-assoc-get 'fret-label-vertical-offset props -0.2))
288 (label-vertical-offset -0.2)
289 (number-type (chain-assoc-get 'number-type props 'roman-lower))
290 (fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
293 ((equal? number-type 'roman-lower) (format #f "~(~:@r~)" base-fret))
294 ((equal? number-type 'roman-upper) (format #f "~:@r" base-fret))
295 ((equal? 'arabic number-type) (format #f "~d" base-fret))
296 (else (format #f "~(~:@r~)" base-fret)))))
297 (ly:stencil-translate-axis
298 (sans-serif-stencil layout props (* size label-font-mag) label-text)
299 (* size (+ fret-count label-vertical-offset)) Y)))
301 (def-markup-command (fret-diagram-verbose layout props marking-list)
303 "Make a fret diagram containing the symbols indicated in @var{marking-list}
308 \\markup \\fret-diagram #'((mute 6) (mute 5) (open 4)
309 (place-fret 3 2) (place-fret 2 3) (place-fret 1 2))
312 will produce a standard D chord diagram without fingering indications.
314 Possible elements in @var{marking-list}:
316 @item (mute string-number)
317 Place a small 'x' at the top of string @var{string-number}
319 @item (open string-number)
320 Place a small 'o' at the top of string @var{string-number}
322 @item (barre start-string end-string fret-number)
323 Place a barre indicator (much like a tie) from string @var{start-string}to string @var{end-string} at fret @var{fret-number}
325 @item (place-fret string-number fret-number finger-value)
326 Place a fret playing indication on string @var{string-number} at fret @var{fret-number} with an optional
327 fingering label @var{finger-value}. By default, the fret playing indicator is a solid dot. This can be
328 changed by setting the value of the variable @var{dot-color}. If the @var{finger}
329 part of the place-fret element is present, @var{finger-value} will be displayed according to the setting of the variable
330 @var{finger-code}. There is no limit to the number of fret indications per string.
333 (make-fret-diagram layout props marking-list))
335 (define (make-fret-diagram layout props marking-list)
336 " Make a fret diagram markup"
338 ; note: here we get items from props that are needed in this routine, or that are needed in more than one
339 ; of the procedures called from this routine. If they're only used in one of the sub-procedure, they're
340 ; obtained in that procedure
342 (size (chain-assoc-get 'size props 1.0)) ; needed for everything
343 ;TODO -- get string-count directly from length of stringTunings; requires FretDiagram engraver, which is not yet available
344 ;TODO -- adjust padding for fret label? it appears to be too close to dots
345 (string-count (chain-assoc-get 'string-count props 6)) ; needed for everything
346 (fret-count (chain-assoc-get 'fret-count props 4)) ; needed for everything
347 (finger-code (chain-assoc-get 'finger-code props 'none)) ; needed for both draw-dots and draw-barre
348 (default-dot-radius (if (eq? finger-code 'in-dot) 0.425 0.25)) ; bigger dots if labeled
349 (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
350 (dot-radius (chain-assoc-get 'dot-radius props default-dot-radius)) ; needed for both draw-dots and draw-barre
351 (dot-position (chain-assoc-get 'dot-position props default-dot-position)) ; needed for both draw-dots and draw-barre
352 (th (* (ly:output-def-lookup layout 'linethickness)
353 (chain-assoc-get 'thickness props 0.5))) ; needed for both draw-frets and draw-strings
355 (alignment (chain-assoc-get 'align-dir props -0.4)) ; needed only here
356 ; (xo-padding (* th (chain-assoc-get 'padding props 2))) ; needed only here
358 (xo-padding (* th 2))
359 (label-dir (chain-assoc-get 'label-dir props RIGHT))
360 (parameters (fret-parse-marking-list marking-list fret-count))
361 (dot-list (cdr (assoc 'dot-list parameters)))
362 (xo-list (cdr (assoc 'xo-list parameters)))
363 (fret-range (cdr (assoc 'fret-range parameters)))
364 (barre-list (cdr (assoc 'barre-list parameters)))
365 (fret-diagram-stencil (ly:stencil-add
366 (draw-strings string-count fret-range th size)
367 (draw-frets layout props fret-range string-count th size))))
368 (if (not (null? barre-list))
369 (set! fret-diagram-stencil (ly:stencil-add
370 (draw-barre layout props string-count fret-range size finger-code
371 dot-position dot-radius barre-list)
372 fret-diagram-stencil)))
373 (if (not (null? dot-list))
374 (set! fret-diagram-stencil (ly:stencil-add
375 (draw-dots layout props string-count fret-range size finger-code
376 dot-position dot-radius dot-list)
377 fret-diagram-stencil)))
378 (if (not (null? xo-list))
379 (set! fret-diagram-stencil (ly:stencil-combine-at-edge
380 fret-diagram-stencil Y UP
381 (draw-xo layout props string-count fret-range size xo-list) xo-padding 0)))
382 (if (> (car fret-range) 1)
383 (set! fret-diagram-stencil
384 (ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
385 (label-fret layout props string-count fret-range size) label-space 0)))
386 (ly:stencil-align-to! fret-diagram-stencil X alignment)
387 fret-diagram-stencil))
389 (def-markup-command (fret-diagram layout props definition-string)
395 \\markup \\fret-diagram #\"s:0.75;6-x;5-x;4-o;3-2;2-3;1-2;\"
398 for fret spacing 3/4 of staff space, D chord diagram
400 Syntax rules for @var{definition-string}:
404 Diagram items are separated by semicolons.
411 s:number -- set the fret spacing of the diagram (in staff spaces). Default 1
414 t:number -- set the line thickness (in staff spaces). Default 0.05
417 h:number -- set the height of the diagram in frets. Default 4
420 w:number -- set the width of the diagram in strings. Default 6
423 f:number -- set fingering label type (0 = none, 1 = in circle on string, 2 = below string) Default 0
426 d:number -- set radius of dot, in terms of fret spacing. Default 0.25
429 p:number -- set the position of the dot in the fret space. 0.5 is centered; 1 is on lower fret bar,
430 0 is on upper fret bar. Default 0.6
433 c:string1-string2-fret -- include a barre mark from string1 to string2 on fret
436 string-fret -- place a dot on string at fret. If fret is o, string is identified
437 as open. If fret is x, string is identified as muted.
440 string-fret-fingering -- place a dot on string at fret, and label with fingering as
446 Note: There is no limit to the number of fret indications per string.
450 (let ((definition-list (fret-parse-definition-string props definition-string)))
451 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
453 (define (fret-parse-definition-string props definition-string)
454 "parse a fret diagram string and return a pair containing:
455 props, modified as necessary by the definition-string
456 a fret-indication list with the appropriate values"
457 (let* ((fret-count 4)
459 (fret-range (list 1 fret-count))
465 (items (string-split definition-string #\;)))
466 (let parse-item ((myitems items))
467 (if (not (null? (cdr myitems)))
468 (let ((test-string (car myitems)))
469 (case (car (string->list (substring test-string 0 1)))
470 ((#\s) (let ((size (get-numeric-from-key test-string)))
471 (set! new-props (acons 'size size new-props))))
472 ((#\f) (let* ((finger-code (get-numeric-from-key test-string))
473 (finger-id (case finger-code
476 ((2) 'below-string))))
478 (acons 'finger-code finger-id new-props))))
479 ((#\c) (set! output-list (cons-fret (cons 'barre (numerify (string-split (substring test-string 2) #\-)))
481 ((#\h) (let ((fret-count (get-numeric-from-key test-string)))
482 (set! new-props (acons 'fret-count fret-count new-props))))
483 ((#\w) (let ((string-count (get-numeric-from-key test-string)))
484 (set! new-props (acons 'string-count string-count new-props))))
485 ((#\d) (let ((dot-size (get-numeric-from-key test-string)))
486 (set! new-props (acons 'dot-radius dot-size new-props))))
487 ((#\p) (let ((dot-position (get-numeric-from-key test-string)))
488 (set! new-props (acons 'dot-position dot-position new-props))))
490 (let ((this-list (string-split test-string #\-)))
491 (if (string->number (cadr this-list))
492 (set! output-list (cons-fret (cons 'place-fret (numerify this-list)) output-list))
493 (if (equal? (cadr this-list) "x" )
494 (set! output-list (cons-fret (list 'mute (string->number (car this-list))) output-list))
495 (set! output-list (cons-fret (list 'open (string->number (car this-list))) output-list)))))))
496 (parse-item (cdr myitems)))))
497 (if (eq? new-props '())
498 `(,props . ,output-list)
499 `(,(cons new-props props) . ,output-list))))
501 (define (cons-fret new-value old-list)
502 " Put together a fret-list in the format desired by parse-string "
503 (if (eq? old-list '())
505 (cons* new-value old-list)))
507 (define (get-numeric-from-key keystring)
508 "Get the numeric value from a key of the form k:val"
509 (string->number (substring keystring 2 (string-length keystring))))
511 (define (numerify mylist)
512 "Convert string values to numeric or character"
515 (let ((numeric-value (string->number (car mylist))))
517 (cons* numeric-value (numerify (cdr mylist)))
518 (cons* (car (string->list (car mylist))) (numerify (cdr mylist)))))))
520 (def-markup-command (fret-diagram-terse layout props definition-string)
522 "Make a fret diagram markup using terse string-based syntax.
526 \\markup \\fret-diagram-terse #\"x;x;o;2;3;2;\"
528 for a D chord diagram.
530 Syntax rules for @var{definition-string}:
534 Strings are terminated by semicolons; the number of semicolons
535 is the number of strings in the diagram.
538 Mute strings are indicated by \"x\".
541 Open strings are indicated by \"o\".
544 A number indicates a fret indication at that fret.
547 If there are multiple fret indicators desired on a string, they
548 should be separated by spaces.
551 Fingerings are given by following the fret number with a \"-\",
552 followed by the finger indicator, e.g. 3-2 for playing the third
553 fret with the second finger.
556 Where a barre indicator is desired, follow the fret (or fingering) symbol
557 with \"-(\" to start a barre and \"-)\" to end the barre.
559 ;TODO -- change syntax to fret\string-finger
560 (let ((definition-list (fret-parse-terse-definition-string props definition-string)))
561 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
563 (define (fret-parse-terse-definition-string props definition-string)
564 "parse a fret diagram string that uses terse syntax; return a pair containing:
565 props, modified to include the string-count determined by the definition-string
566 a fret-indication list with the appropriate values"
567 ;TODO -- change syntax to fret\string-finger
568 (let* ((barre-start-list '())
571 (items (string-split definition-string #\;))
572 (string-count (- (length items) 1)))
573 (let parse-item ((myitems items))
574 (if (not (null? (cdr myitems)))
575 (let* ((test-string (car myitems))
576 (current-string (- (length myitems) 1))
577 (indicators (string-split test-string #\ )))
578 (let parse-indicators ((myindicators indicators))
579 (if (not (eq? '() myindicators))
580 (let* ((this-list (string-split (car myindicators) #\-))
581 (max-element-index (- (length this-list) 1))
582 (last-element (car (list-tail this-list max-element-index)))
583 (fret (if (string->number (car this-list)) (string->number (car this-list)) (car this-list))))
584 (if (equal? last-element "(")
586 (set! barre-start-list (cons-fret (list current-string fret) barre-start-list))
587 (set! this-list (list-head this-list max-element-index))))
588 (if (equal? last-element ")")
589 (let* ((this-barre (get-sub-list fret barre-start-list))
590 (insert-index (- (length this-barre) 1)))
591 (set! output-list (cons-fret (cons* 'barre (car this-barre) current-string (cdr this-barre))
593 (set! this-list (list-head this-list max-element-index))))
595 (set! output-list (cons-fret (cons* 'place-fret current-string (drop-paren (numerify this-list))) output-list))
596 (if (equal? (car this-list) "x" )
597 (set! output-list (cons-fret (list 'mute current-string) output-list))
598 (set! output-list (cons-fret (list 'open current-string) output-list))))
599 (parse-indicators (cdr myindicators)))))
600 (parse-item (cdr myitems)))))
601 (set! new-props (acons 'string-count string-count new-props))
603 `(,(cons new-props props) . ,output-list)))
605 (define (drop-paren item-list)
606 " drop a final parentheses from a fret indication list resulting from a terse string specification of barre."
607 (if (> (length item-list) 0)
608 (let* ((max-index (- (length item-list) 1))
609 (last-element (car (list-tail item-list max-index))))
610 (if (or (equal? last-element ")") (equal? last-element "("))
611 (list-head item-list max-index)
615 (define (get-sub-list value master-list)
616 " Get a sub-list whose cadr is equal to @var{value} from @var{master-list}"
617 (if (eq? master-list '())
619 (let ((sublist (car master-list)))
620 (if (equal? (cadr sublist) value)
622 (get-sub-list value (cdr master-list))))))