]> git.donarmstrong.com Git - lilypond.git/blob - scm/predefined-fretboards.scm
5140ae6e91093e0a7f8a92ba94a76b7bcba8330e
[lilypond.git] / scm / predefined-fretboards.scm
1 ;;;; This file is part of LilyPond, the GNU music typesetter.
2 ;;;;
3 ;;;; Copyright (C) 2008--2012 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 @code{fret-diagram-terse} definition string @var{terse-definition}
21 and 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 @var{shape-code} and
26 @var{tuning} in the hash-table @var{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 @var{fret-offset} to each fret indication in
35 @var{diagram-definition} and return the resulting verbose
36 @code{fret-diagram-definition}."
37   (let ((verbose-definition
38          (if (string? diagram-definition)
39              (parse-terse-string diagram-definition)
40              diagram-definition)))
41     (map (lambda(item)
42            (let ((code (car item)))
43              (cond
44               ((eq? code 'barre)
45                (list-set! item 3
46                           (+ fret-offset (list-ref item 3)))
47                item)
48               ((eq? code 'capo)
49                (list-set! item 1
50                           (+ fret-offset (list-ref item 1)))
51                item)
52               ((eq? code 'place-fret)
53                (list-set! item 2
54                           (+ fret-offset (list-ref item 2)))
55                item)
56               (else item))))
57          verbose-definition)))