1 %%%% This file is part of LilyPond, the GNU music typesetter.
3 %%%% Copyright (C) 2008--2011 Carl D. Sorensen <c_sorensen@byu.edu>
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.
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.
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/>.
20 % chord-shape-table is a hash-table of chord shapes
21 % in the form of diagram-descriptions that can be
22 % fret-diagram-verbose markup-llsts or
23 % fret-diagram-terse strings.
24 % The hash keys are pairs of scheme symbols and
25 % string tunings. For convenience, the symbols in
26 % this file are LilyPond chordmode chord descriptions,
27 % but that is unnecessary.
29 % music function for adding a chord shape to
33 #(define-music-function
(parser location key-symbol tuning shape-definition
)
34 (symbol? pair? string-or-pair?
)
35 (_i
"Add chord shape @var{shape-definition} to the @var{chord-shape-table}
36 hash with the key @var{(cons key-symbol tuning)}.")
37 (hash-set
! chord-shape-table
38 (cons key-symbol tuning
)
40 (make-music
'SequentialMusic
'void
#t
))
42 #(define
(chord-shape shape-code tuning
)
43 (get-chord-shape shape-code tuning chord-shape-table
))
45 % scheme function for copying/creating fretboard tables
47 #(define
(make-fretboard-table
. rest
)
48 "Create a new fretboard table. @code{rest} is an optional table name.
49 If present, the new fretboard table starts as a copy of the fretboard
53 (let
((source-table
(car rest
)))
55 (lambda
(key value tab
)
56 (hash-set
! tab key value
)
61 % music function for adding a predefined diagram to
64 storePredefinedDiagram
=
65 #(define-music-function
66 (parser location fretboard-table chord tuning diagram-definition
)
67 (hash-table? ly
:music? pair? string-or-pair?
)
68 (_i
"Add predefined fret diagram defined by @var{diagram-definition}
69 for the chord pitches @var{chord} and the stringTuning @var{tuning}.")
70 (let
* ((pitches
(event-chord-pitches
71 (car
(extract-named-music chord
'EventChord
))))
72 (hash-key
(cons tuning pitches
))
73 (verbose-definition
(if
(string? diagram-definition
)
74 (parse-terse-string diagram-definition
)
76 (hash-set
! fretboard-table
79 (make-music
'SequentialMusic
'void
#t
)))