]> git.donarmstrong.com Git - lilypond.git/blob - ly/predefined-fretboards-init.ly
convert-ly run: update some tricky files.
[lilypond.git] / ly / predefined-fretboards-init.ly
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 \version "2.13.36"
19
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.
28
29 % music function for adding a chord shape to
30 % chord-shape-table
31
32 addChordShape =
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)
39                shape-definition)
40    (make-music 'SequentialMusic 'void #t))
41
42 #(define (chord-shape shape-code tuning)
43    (get-chord-shape shape-code tuning chord-shape-table))
44
45 % music function for adding a predefined diagram to
46 % fretboard-table
47
48 storePredefinedDiagram =
49 #(define-music-function (parser location
50     fretboard-table chord tuning diagram-definition)
51    (hash-table? ly:music? pair? string-or-pair?)
52   (_i "Add predefined fret diagram defined by @var{diagram-definition}
53   for the chord pitches @var{chord} and the stringTuning @var{tuning}.")
54   (let* ((pitches (event-chord-pitches
55                     (car (extract-named-music chord 'EventChord))))
56          (hash-key (cons tuning pitches))
57          (verbose-definition (if (string? diagram-definition)
58                                  (parse-terse-string diagram-definition)
59                                  diagram-definition)))
60   (hash-set! fretboard-table
61              hash-key
62              verbose-definition)
63   (make-music 'SequentialMusic 'void #t)))