]> git.donarmstrong.com Git - lilypond.git/blob - scm/predefined-fretboards.scm
Merge commit 'origin' into includes
[lilypond.git] / scm / predefined-fretboards.scm
1 ;;;;  predefined-fretboards.scm
2 ;;;;
3 ;;;;  source file of the GNU LilyPOnd music typesetter
4 ;;;;
5 ;;;; (c) 2008 Carl D. Sorensen <c_sorensen@byu.edu>
6
7
8 (define-public (parse-terse-string terse-definition)
9 "Parse a fret-diagram-terse definition string @code{terse-definition} and
10 return a marking list, which can be used with a fretboard grob."
11    (cdr (fret-parse-terse-definition-string (list '()) terse-definition)))
12
13 (define-public (get-chord-shape shape-code tuning base-chord-shapes)
14 "Return the chord shape associated with @code{shape-code} and
15 @code{tuning} in the hash-table @code{base-chord-shapes}."
16   (let ((hash-handle (hash-get-handle base-chord-shapes
17                                        (cons shape-code tuning))))
18      (if hash-handle
19          (cdr hash-handle)
20          '())))
21
22 (define-public (offset-fret fret-offset diagram-definition)
23 "Add @code{fret-offset} to each fret indication in @code{diagram-definition}
24 and return the resulting verbose fret-diagram-definition."
25    (let ((verbose-definition 
26            (if (string? diagram-definition)
27                (parse-terse-string diagram-definition)
28                diagram-definition)))
29      (map (lambda(item) 
30             (let ((code (car item)))
31               (cond
32                 ((eq? code 'barre)
33                   (list-set! item 3
34                      (+ fret-offset (list-ref item 3)))
35                   item)
36                 ((eq? code 'capo)
37                   (list-set! item 1
38                      (+ fret-offset (list-ref item 1)))
39                   item)
40                 ((eq? code 'place-fret)
41                   (list-set! item 2
42                      (+ fret-offset (list-ref item 2)))
43                   item)
44                 (else item))))
45             verbose-definition)))
46