]> git.donarmstrong.com Git - lilypond.git/blob - scm/predefined-fretboards.scm
Run grand-replace for 2010.
[lilypond.git] / scm / predefined-fretboards.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2008--2010 Carl D. Sorensen <c_sorensen@byu.edu>
4 ;;;;
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
7 ;;;; the Free Software Foundation, either version 3 of the License, or
8 ;;;; (at your option) any later version.
9 ;;;;
10 ;;;; LilyPond is distributed in the hope that it will be useful,
11 ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ;;;; GNU General Public License for more details.
14 ;;;;
15 ;;;; You should have received a copy of the GNU General Public License
16 ;;;; along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
17
18
19 (define-public (parse-terse-string terse-definition)
20 "Parse a fret-diagram-terse definition string @code{terse-definition} and
21 return a marking list, which can be used with a fretboard grob."
22    (cdr (fret-parse-terse-definition-string (list '()) terse-definition)))
23
24 (define-public (get-chord-shape shape-code tuning base-chord-shapes)
25 "Return the chord shape associated with @code{shape-code} and
26 @code{tuning} in the hash-table @code{base-chord-shapes}."
27   (let ((hash-handle (hash-get-handle base-chord-shapes
28                                        (cons shape-code tuning))))
29      (if hash-handle
30          (cdr hash-handle)
31          '())))
32
33 (define-public (offset-fret fret-offset diagram-definition)
34 "Add @code{fret-offset} to each fret indication in @code{diagram-definition}
35 and return the resulting verbose fret-diagram-definition."
36    (let ((verbose-definition 
37            (if (string? diagram-definition)
38                (parse-terse-string diagram-definition)
39                diagram-definition)))
40      (map (lambda(item) 
41             (let ((code (car item)))
42               (cond
43                 ((eq? code 'barre)
44                   (list-set! item 3
45                      (+ fret-offset (list-ref item 3)))
46                   item)
47                 ((eq? code 'capo)
48                   (list-set! item 1
49                      (+ fret-offset (list-ref item 1)))
50                   item)
51                 ((eq? code 'place-fret)
52                   (list-set! item 2
53                      (+ fret-offset (list-ref item 2)))
54                   item)
55                 (else item))))
56             verbose-definition)))
57