1 ;;;; fret-diagrams.scm --
3 ;;;; source file of the GNU LilyPond music typesetter
5 ;;;; (c) 2004 Carl D. Sorensen <c_sorensen@byu.edu>
9 (define (fret-parse-marking-list marking-list fret-count)
10 (let* ((fret-range (list 1 fret-count))
15 (let parse-item ((mylist marking-list))
16 (if (not (null? mylist))
17 (let* ((my-item (car mylist)) (my-code (car my-item)))
19 ((or (eq? my-code 'open)(eq? my-code 'mute))
20 (set! xo-list (cons* my-item xo-list)))
22 (set! barre-list (cons* (cdr my-item) barre-list)))
23 ((eq? my-code 'place-fret)
24 (set! dot-list (cons* (cdr my-item) dot-list))))
25 (parse-item (cdr mylist)))))
26 ; calculate fret-range
27 (let ((maxfret 0) (minfret 99))
28 (let updatemax ((fret-list dot-list))
31 (let ((fretval (second (car fret-list))))
32 (if (> fretval maxfret) (set! maxfret fretval))
33 (if (< fretval minfret) (set! minfret fretval))
34 (updatemax (cdr fret-list)))))
35 (if (> maxfret fret-count)
36 (set! fret-range (list minfret
37 (let ((upfret (- (+ minfret fret-count) 1)))
38 (if (> maxfret upfret) maxfret upfret)))))
39 ; subtract fret from dots
40 (set! dot-list (subtract-base-fret (- (car fret-range) 1) dot-list)))
41 (acons 'fret-range fret-range
42 (acons 'barre-list barre-list
43 (acons 'dot-list dot-list
44 (acons 'xo-list xo-list '()))))))
46 (define (subtract-base-fret base-fret dot-list)
47 "Subtract @var{base-fret} from every fret in @var{dot-list}"
50 (let ((this-list (car dot-list)))
51 (cons* (list (car this-list) (- (second this-list) base-fret) (if (null? (cddr this-list))
54 (subtract-base-fret base-fret (cdr dot-list))))))
56 (define (sans-serif-stencil layout props mag text)
57 "create a stencil in sans-serif font based on @var{layout} and @var{props}
58 with magnification @varr{mag} of the string @var{text}."
59 (let* ((my-props (prepend-alist-chain 'font-size (stepmag mag)
60 (prepend-alist-chain 'font-family 'sans props))))
61 (interpret-markup layout my-props text)))
63 (define (sans-serif-stencil-white layout props mag text)
64 "create a stencil with white text in sans-serif font based on @var{layout} and @var{props}
65 with magnification @varr{mag} of the string @var{text}."
66 (let* ((text-stencil (sans-serif-stencil layout props mag text))
67 (x-extent (ly:stencil-extent text-stencil X))
68 (y-extent (ly:stencil-extent text-stencil Y))
69 (c `(white-text ,(* 2 mag) ,text))) ;urg -- workaround for using ps font
70 (ly:make-stencil c x-extent y-extent))) ;urg -- extent is not from ps font, but we hope it's close
73 (define (draw-strings string-count fret-range th size)
74 "Draw the strings (vertical lines) for a fret diagram with @var{string-count} strings and frets as indicated
75 in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
76 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
77 (sl (* (+ fret-count 1) size))
79 (half-thickness (* sth 0.5))
81 (string-stencil (ly:make-stencil (list 'draw-line sth 0 0 0 sl)
82 (cons (- half-thickness) half-thickness)
83 (cons (- half-thickness) (+ sl half-thickness)))))
84 (if (= string-count 1)
86 (ly:stencil-combine-at-edge
87 (draw-strings (- string-count 1) fret-range th size) X RIGHT
91 (define (draw-fret-lines fret-count string-count th size)
92 "Draw @var{fret-count} frets (horizontal lines) for a fret diagram with @var{string-count} strings.
93 Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
94 (let* ((fret-length (* (- string-count 1) size))
96 (half-thickness (* sth 0.5))
98 (fret-line (ly:make-stencil (list 'draw-line sth half-thickness size (- fret-length half-thickness) size)
100 (cons (- size half-thickness) (+ size half-thickness)))))
103 (ly:stencil-combine-at-edge fret-line Y UP
104 (draw-fret-lines (- fret-count 1) string-count th size)
107 (define (draw-thick-top-fret props string-count th size)
108 "Draw a thick top fret for a fret diagram whose base fret is not 1."
109 (let* ((sth (* th size))
110 ; (top-fret-thick (* sth (chain-assoc-get 'top-fret-thickness props 3.0)))
111 (top-fret-thick (* sth 3.0))
112 ; (top-half-thick (* top-fret-thick 0.5))
113 (half-thick (* sth 0.5))
115 (x2 (+ half-thick (* size (- string-count 1))))
117 (y2 (+ top-fret-thick half-thick))
118 (x-extent (cons (- x1) x2))
119 (y-extent (cons 0 y2)))
120 (ly:make-stencil (list 'round-filled-box x1 x2 y1 y2 sth)
124 (define (draw-frets layout props fret-range string-count th size)
125 "Draw the frets (horizontal lines) for a fret diagram with @var{string-count} strings and frets as indicated
126 in @var{fret-range}. Line thickness is given by @var{th}, fret & string spacing by @var{size}. "
127 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
128 (fret-length (* (- string-count 1) size))
129 (half-thickness (* th 0.5))
130 (base-fret (car fret-range)))
131 (ly:stencil-combine-at-edge
132 (draw-fret-lines fret-count string-count th size) Y UP
134 (draw-thick-top-fret props string-count th size)
135 (draw-fret-lines 1 string-count th size))
139 (define (centered-stencil stencil)
140 "Center stencil @var{stencil} in both the X and Y directions"
141 (let* ((output-stencil stencil))
142 ; (if (= (cadr (ly:version)) 3)
144 (ly:stencil-align-to! output-stencil Y 0)
145 (ly:stencil-align-to! output-stencil X 0)
147 ; (ly:stencil-align-to (ly:stencil-align-to text-stencil X 0) Y 0))))
149 (define (draw-dots layout props string-count fret-range size finger-code dot-position dot-radius dot-list)
150 "Make dots for fret diagram."
151 (let* ((scale-dot-radius (* size dot-radius))
152 (dot-color (chain-assoc-get 'dot-color props 'black))
153 ; (finger-xoffset (chain-assoc-get 'finger-xoffset props -0.25))
154 ; (finger-yoffset (chain-assoc-get 'finger-yoffset props (- size)))
155 (finger-xoffset -0.25)
156 (finger-yoffset (- size))
157 ; (dot-label-font-mag (* scale-dot-radius (chain-assoc-get 'dot-label-font-mag props 1.0)))
158 (dot-label-font-mag scale-dot-radius)
159 ; (string-label-font-mag (* size (chain-assoc-get 'label-font-mag props 0.7)))
160 (string-label-font-mag (* size 0.7))
161 (fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
162 (mypair (car dot-list))
163 (restlist (cdr dot-list))
164 (xpos (* size (- string-count (car mypair))))
165 ;TODO -- figure out what 4 is and get rid of it
167 (ypos (* size (+ 4 (- fret-count (cadr mypair) dot-position ))))
168 (extent (cons (- scale-dot-radius) scale-dot-radius))
169 (finger (caddr mypair))
170 (finger (if (number? finger) (number->string finger) finger))
171 (dotstencil (if (eq? dot-color 'white)
173 (ly:make-stencil (list 'white-dot 0 0 scale-dot-radius) extent extent))
174 (ly:make-stencil (list 'dot 0 0 scale-dot-radius ) extent extent)))
175 (positioned-dot (ly:stencil-translate-axis
176 (ly:stencil-translate-axis dotstencil xpos X)
179 (if (or (eq? finger '())(eq? finger-code 'none))
181 (if (eq? finger-code 'in-dot)
182 (let* ((dot-proc (if (eq? dot-color 'white) 'white-dot 'dot)))
184 (ly:stencil-translate-axis
185 (ly:stencil-translate-axis
186 (if (eq? dot-color 'white)
187 (centered-stencil (sans-serif-stencil layout props dot-label-font-mag finger))
188 (centered-stencil (sans-serif-stencil-white layout props
189 dot-label-font-mag finger)))
192 (ly:stencil-translate-axis
193 (ly:stencil-translate-axis
194 (ly:make-stencil (list dot-proc 0 0 scale-dot-radius) extent extent)
197 (if (eq? finger-code 'below-string)
200 (ly:stencil-translate-axis
201 (ly:stencil-translate-axis
202 (centered-stencil (sans-serif-stencil layout props
203 string-label-font-mag finger)) xpos X)
204 (* size finger-yoffset) Y))
210 (draw-dots layout props string-count fret-range size finger-code
211 dot-position dot-radius restlist)
212 labeled-dot-stencil))))
214 (define (draw-xo layout props string-count fret-range size xo-list)
215 "Put open and mute string indications on diagram, as contained in @var{xo-list}."
216 (let* ((fret-count (+ (- (cadr fret-range) (car fret-range) 1)))
217 ; (xo-font-mag (* size (chain-assoc-get 'xo-font-magnification props 0.5)))
218 (xo-font-mag (* size 0.5))
219 ; (xo-horizontal-offset (* size (chain-assoc-get 'xo-horizontal-offset props -0.35)))
220 (xo-horizontal-offset (* size -0.35))
221 (mypair (car xo-list))
222 (restlist (cdr xo-list))
223 (glyph-string (if (eq? (car mypair) 'mute) "X" "O"))
224 (xpos (+ (* (- string-count (cadr mypair)) size) xo-horizontal-offset ))
225 (glyph-stencil (ly:stencil-translate-axis
226 (sans-serif-stencil layout props (* size xo-font-mag) glyph-string) xpos X)))
230 (draw-xo layout props string-count fret-range size restlist)
233 (define (make-bezier-sandwich-list left right bottom height thickness)
234 " Make the argument list for a horizontal bezier sandwich from @var{left} to @var{right} with a bottom at @var{bottom},
235 a height of @var{height}, and a thickness of @var{thickness}."
236 (let* ((width (+ (- right left) 1))
237 (x1 (+ (* width thickness) left))
238 (x2 (- right (* width thickness)))
239 (bottom-control-point-height (+ bottom (- height thickness)))
240 (top-control-point-height (+ bottom height)))
241 ; order of points is: left cp low, right cp low, right end low, left end low
242 ; right cp high, left cp high, left end high, right end high.
243 (list (cons x1 bottom-control-point-height) (cons x2 bottom-control-point-height) (cons right bottom) (cons left bottom)
244 (cons x2 top-control-point-height) (cons x1 top-control-point-height) (cons left bottom) (cons right bottom))))
246 (define (draw-barre layout props string-count fret-range size finger-code dot-position dot-radius barre-list)
247 "Create barre indications for a fret diagram"
248 (if (not (null? barre-list))
249 (let* ((string1 (caar barre-list))
250 (string2 (cadar barre-list))
251 (fret (caddar barre-list))
252 (barre-type (chain-assoc-get 'barre-type props 'curved))
253 (scale-dot-radius (* size dot-radius))
254 (barre-vertical-offset (chain-assoc-get 'barre-vertical-offset props 0.5))
255 ; 2 is 1 for empty fret at bottom of figure + 1 for interval (top-fret - fret + 1) -- not an arbitrary constant
256 (dot-center-y (* size (- (+ 2 (- (cadr fret-range) fret))dot-position) ))
257 (bottom (+ dot-center-y (* barre-vertical-offset scale-dot-radius)))
258 (left (* size (- string-count string1)))
259 (right (* size (- string-count string2)))
260 ; (bezier-thick (chain-assoc-get 'bezier-thickness props 0.1))
262 ; (bezier-height (chain-assoc-get 'bezier-height props 0.5))
264 (bezier-list (make-bezier-sandwich-list left right bottom (* size bezier-height) (* size bezier-thick)))
265 (barre-stencil (if (eq? barre-type 'straight)
266 (ly:make-stencil (list 'draw-line (* size dot-radius) left dot-center-y right dot-center-y)
268 (cons (- dot-center-y scale-dot-radius) (+ dot-center-y scale-dot-radius)))
269 (ly:make-stencil (list 'bezier-sandwich `(quote ,bezier-list) (* size bezier-thick) )
271 (cons bottom (+ bottom (* size bezier-height)))))))
272 (if (not (null? (cdr barre-list)))
273 (ly:stencil-add barre-stencil
274 (draw-barre layout props string-count fret-range size finger-code
275 dot-position dot-radius (cdr barre-list)))
279 (define (stepmag mag)
280 "Calculate the font step necessary to get a desired magnification"
281 (* 6 (/ (log mag) (log 2))))
283 (define (label-fret layout props string-count fret-range size)
284 "Label the base fret on a fret diagram"
285 (let* ((base-fret (car fret-range))
286 ; (label-font-mag (chain-assoc-get 'label-font-mag props 0.7))
288 ; (label-vertical-offset (chain-assoc-get 'fret-label-vertical-offset props -0.2))
289 (label-vertical-offset -0.2)
290 (number-type (chain-assoc-get 'number-type props 'roman-lower))
291 (fret-count (+ (- (cadr fret-range) (car fret-range)) 1))
294 ((equal? number-type 'roman-lower) (format #f "~(~:@r~)" base-fret))
295 ((equal? number-type 'roman-upper) (format #f "~:@r" base-fret))
296 ((equal? 'arabic number-type) (format #f "~d" base-fret))
297 (else (format #f "~(~:@r~)" base-fret)))))
298 (ly:stencil-translate-axis
299 (sans-serif-stencil layout props (* size label-font-mag) label-text)
300 (* size (+ fret-count label-vertical-offset)) Y)))
302 (def-markup-command (fret-diagram-verbose layout props marking-list)
304 "Make a fret diagram containing the symbols indicated in @var{marking-list}
309 \\markup \\fret-diagram #'((mute 6) (mute 5) (open 4)
310 (place-fret 3 2) (place-fret 2 3) (place-fret 1 2))
313 will produce a standard D chord diagram without fingering indications.
315 Possible elements in @var{marking-list}:
317 @item (mute string-number)
318 Place a small 'x' at the top of string @var{string-number}
320 @item (open string-number)
321 Place a small 'o' at the top of string @var{string-number}
323 @item (barre start-string end-string fret-number)
324 Place a barre indicator (much like a tie) from string @var{start-string}to string @var{end-string} at fret @var{fret-number}
326 @item (place-fret string-number fret-number finger-value)
327 Place a fret playing indication on string @var{string-number} at fret @var{fret-number} with an optional
328 fingering label @var{finger-value}. By default, the fret playing indicator is a solid dot. This can be
329 changed by setting the value of the variable @var{dot-color}. If the @var{finger}
330 part of the place-fret element is present, @var{finger-value} will be displayed according to the setting of the variable
331 @var{finger-code}. There is no limit to the number of fret indications per string.
334 (make-fret-diagram layout props marking-list))
336 (define (make-fret-diagram layout props marking-list)
337 " Make a fret diagram markup"
339 ; note: here we get items from props that are needed in this routine, or that are needed in more than one
340 ; of the procedures called from this routine. If they're only used in one of the sub-procedure, they're
341 ; obtained in that procedure
343 (size (chain-assoc-get 'size props 1.0)) ; needed for everything
344 ;TODO -- get string-count directly from length of stringTunings; requires FretDiagram engraver, which is not yet available
345 ;TODO -- adjust padding for fret label? it appears to be too close to dots
346 (string-count (chain-assoc-get 'string-count props 6)) ; needed for everything
347 (fret-count (chain-assoc-get 'fret-count props 4)) ; needed for everything
348 (finger-code (chain-assoc-get 'finger-code props 'none)) ; needed for both draw-dots and draw-barre
349 (default-dot-radius (if (eq? finger-code 'in-dot) 0.425 0.25)) ; bigger dots if labeled
350 (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
351 (dot-radius (chain-assoc-get 'dot-radius props default-dot-radius)) ; needed for both draw-dots and draw-barre
352 (dot-position (chain-assoc-get 'dot-position props default-dot-position)) ; needed for both draw-dots and draw-barre
353 (th (* (ly:output-def-lookup layout 'linethickness)
354 (chain-assoc-get 'thickness props 0.5))) ; needed for both draw-frets and draw-strings
356 (alignment (chain-assoc-get 'align-dir props -0.4)) ; needed only here
357 ; (xo-padding (* th (chain-assoc-get 'padding props 2))) ; needed only here
359 (xo-padding (* th 2))
360 (label-dir (chain-assoc-get 'label-dir props RIGHT))
361 (parameters (fret-parse-marking-list marking-list fret-count))
362 (dot-list (cdr (assoc 'dot-list parameters)))
363 (xo-list (cdr (assoc 'xo-list parameters)))
364 (fret-range (cdr (assoc 'fret-range parameters)))
365 (barre-list (cdr (assoc 'barre-list parameters)))
366 (fret-diagram-stencil (ly:stencil-add
367 (draw-strings string-count fret-range th size)
368 (draw-frets layout props fret-range string-count th size))))
369 (if (not (null? barre-list))
370 (set! fret-diagram-stencil (ly:stencil-add
371 (draw-barre layout props string-count fret-range size finger-code
372 dot-position dot-radius barre-list)
373 fret-diagram-stencil)))
374 (if (not (null? dot-list))
375 (set! fret-diagram-stencil (ly:stencil-add
376 (draw-dots layout props string-count fret-range size finger-code
377 dot-position dot-radius dot-list)
378 fret-diagram-stencil)))
379 (if (not (null? xo-list))
380 (set! fret-diagram-stencil (ly:stencil-combine-at-edge
381 fret-diagram-stencil Y UP
382 (draw-xo layout props string-count fret-range size xo-list) xo-padding 0)))
383 (if (> (car fret-range) 1)
384 (set! fret-diagram-stencil
385 (ly:stencil-combine-at-edge fret-diagram-stencil X label-dir
386 (label-fret layout props string-count fret-range size) label-space 0)))
387 (ly:stencil-align-to! fret-diagram-stencil X alignment)
388 fret-diagram-stencil))
390 (def-markup-command (fret-diagram layout props definition-string)
396 \\markup \\fret-diagram #\"s:0.75;6-x;5-x;4-o;3-2;2-3;1-2;\"
399 for fret spacing 3/4 of staff space, D chord diagram
401 Syntax rules for @var{definition-string}:
405 Diagram items are separated by semicolons.
412 s:number -- set the fret spacing of the diagram (in staff spaces). Default 1
415 t:number -- set the line thickness (in staff spaces). Default 0.05
418 h:number -- set the height of the diagram in frets. Default 4
421 w:number -- set the width of the diagram in strings. Default 6
424 f:number -- set fingering label type (0 = none, 1 = in circle on string, 2 = below string) Default 0
427 d:number -- set radius of dot, in terms of fret spacing. Default 0.25
430 p:number -- set the position of the dot in the fret space. 0.5 is centered; 1 is on lower fret bar,
431 0 is on upper fret bar. Default 0.6
434 c:string1-string2-fret -- include a barre mark from string1 to string2 on fret
437 string-fret -- place a dot on string at fret. If fret is o, string is identified
438 as open. If fret is x, string is identified as muted.
441 string-fret-fingering -- place a dot on string at fret, and label with fingering as
447 Note: There is no limit to the number of fret indications per string.
451 (let ((definition-list (fret-parse-definition-string props definition-string)))
452 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
454 (define (fret-parse-definition-string props definition-string)
455 "parse a fret diagram string and return a pair containing:
456 props, modified as necessary by the definition-string
457 a fret-indication list with the appropriate values"
458 (let* ((fret-count 4)
460 (fret-range (list 1 fret-count))
466 (items (string-split definition-string #\;)))
467 (let parse-item ((myitems items))
468 (if (not (null? (cdr myitems)))
469 (let ((test-string (car myitems)))
470 (case (car (string->list (substring test-string 0 1)))
471 ((#\s) (let ((size (get-numeric-from-key test-string)))
472 (set! new-props (acons 'size size new-props))))
473 ((#\f) (let* ((finger-code (get-numeric-from-key test-string))
474 (finger-id (case finger-code
477 ((2) 'below-string))))
479 (acons 'finger-code finger-id new-props))))
480 ((#\c) (set! output-list (cons-fret (cons 'barre (numerify (string-split (substring test-string 2) #\-)))
482 ((#\h) (let ((fret-count (get-numeric-from-key test-string)))
483 (set! new-props (acons 'fret-count fret-count new-props))))
484 ((#\w) (let ((string-count (get-numeric-from-key test-string)))
485 (set! new-props (acons 'string-count string-count new-props))))
486 ((#\d) (let ((dot-size (get-numeric-from-key test-string)))
487 (set! new-props (acons 'dot-radius dot-size new-props))))
488 ((#\p) (let ((dot-position (get-numeric-from-key test-string)))
489 (set! new-props (acons 'dot-position dot-position new-props))))
491 (let ((this-list (string-split test-string #\-)))
492 (if (string->number (cadr this-list))
493 (set! output-list (cons-fret (cons 'place-fret (numerify this-list)) output-list))
494 (if (equal? (cadr this-list) "x" )
495 (set! output-list (cons-fret (list 'mute (string->number (car this-list))) output-list))
496 (set! output-list (cons-fret (list 'open (string->number (car this-list))) output-list)))))))
497 (parse-item (cdr myitems)))))
498 (if (eq? new-props '())
499 `(,props . ,output-list)
500 `(,(cons new-props props) . ,output-list))))
502 (define (cons-fret new-value old-list)
503 " Put together a fret-list in the format desired by parse-string "
504 (if (eq? old-list '())
506 (cons* new-value old-list)))
508 (define (get-numeric-from-key keystring)
509 "Get the numeric value from a key of the form k:val"
510 (string->number (substring keystring 2 (string-length keystring) )))
512 (define (numerify mylist)
513 "Convert string values to numeric or character"
516 (let ((numeric-value (string->number (car mylist))))
518 (cons* numeric-value (numerify (cdr mylist)))
519 (cons* (car (string->list (car mylist))) (numerify (cdr mylist)))))))
521 (def-markup-command (fret-diagram-terse layout props definition-string)
523 "Make a fret diagram markup using terse string-based syntax.
527 \\markup \\fret-diagram-terse #\"x;x;o;2;3;2;\"
529 for a D chord diagram.
531 Syntax rules for @var{definition-string}:
535 Strings are terminated by semicolons; the number of semicolons
536 is the number of strings in the diagram.
539 Mute strings are indicated by \"x\".
542 Open strings are indicated by \"o\".
545 A number indicates a fret indication at that fret.
548 If there are multiple fret indicators desired on a string, they
549 should be separated by spaces.
552 Fingerings are given by following the fret number with a \"-\",
553 followed by the finger indicator, e.g. 3-2 for playing the third
554 fret with the second finger.
557 Where a barre indicator is desired, follow the fret (or fingering) symbol
558 with \"-(\" to start a barre and \"-)\" to end the barre.
560 ;TODO -- change syntax to fret\string-finger
561 (let ((definition-list (fret-parse-terse-definition-string props definition-string)))
562 (make-fret-diagram layout (car definition-list) (cdr definition-list))))
564 (define (fret-parse-terse-definition-string props definition-string)
565 "parse a fret diagram string that uses terse syntax; return a pair containing:
566 props, modified to include the string-count determined by the definition-string
567 a fret-indication list with the appropriate values"
568 ;TODO -- change syntax to fret\string-finger
569 (let* ((barre-start-list '())
572 (items (string-split definition-string #\;))
573 (string-count (- (length items) 1)))
574 (let parse-item ((myitems items))
575 (if (not (null? (cdr myitems)))
576 (let* ((test-string (car myitems))
577 (current-string (- (length myitems) 1))
578 (indicators (string-split test-string #\ )))
579 (let parse-indicators ((myindicators indicators))
580 (if (not (eq? '() myindicators))
581 (let* ((this-list (string-split (car myindicators) #\-))
582 (max-element-index (- (length this-list) 1))
583 (last-element (car (list-tail this-list max-element-index)))
584 (fret (if (string->number (car this-list)) (string->number (car this-list)) (car this-list))))
585 (if (equal? last-element "(")
587 (set! barre-start-list (cons-fret (list current-string fret) barre-start-list))
588 (set! this-list (list-head this-list max-element-index))))
589 (if (equal? last-element ")")
590 (let* ((this-barre (get-sub-list fret barre-start-list))
591 (insert-index (- (length this-barre) 1)))
592 (set! output-list (cons-fret (cons* 'barre (car this-barre) current-string (cdr this-barre))
594 (set! this-list (list-head this-list max-element-index))))
596 (set! output-list (cons-fret (cons* 'place-fret current-string (drop-paren (numerify this-list))) output-list))
597 (if (equal? (car this-list) "x" )
598 (set! output-list (cons-fret (list 'mute current-string) output-list))
599 (set! output-list (cons-fret (list 'open current-string) output-list))))
600 (parse-indicators (cdr myindicators)))))
601 (parse-item (cdr myitems)))))
602 (set! new-props (acons 'string-count string-count new-props))
604 `(,(cons new-props props) . ,output-list)))
606 (define (drop-paren item-list)
607 " drop a final parentheses from a fret indication list resulting from a terse string specification of barre."
608 (if (> (length item-list) 0)
609 (let* ((max-index (- (length item-list) 1))
610 (last-element (car (list-tail item-list max-index))))
611 (if (or (equal? last-element ")") (equal? last-element "("))
612 (list-head item-list max-index)
616 (define (get-sub-list value master-list)
617 " Get a sub-list whose cadr is equal to @var{value} from @var{master-list}"
618 (if (eq? master-list '())
620 (let ((sublist (car master-list)))
621 (if (equal? (cadr sublist) value)
623 (get-sub-list value (cdr master-list))))))