]> git.donarmstrong.com Git - lilypond.git/blob - ly/predefined-fretboards-init.ly
Run grand-replace for 2009.
[lilypond.git] / ly / predefined-fretboards-init.ly
1 %%%% predefined-fretboard-init.ly
2 %%%%
3 %%%% source file of the GNU LilyPond music typesetter
4 %%%%
5 %%%% (c) 2008--2009 Carl D. Sorensen <c_sorensen@byu.edu>
6
7 \version "2.12.0"
8
9 % chord-shape-table is a hash-table of chord shapes
10 % in the form of diagram-descriptions that can be
11 % fret-diagram-verbose markup-llsts or
12 % fret-diagram-terse strings.
13 % The hash keys are pairs of scheme symbols and
14 % string tunings.  For convenience, the symbols in
15 % this file are LilyPond chordmode chord descriptions,
16 % but that is unnecessary.
17
18 % music function for adding a chord shape to
19 % chord-shape-table
20
21 addChordShape =
22 #(define-music-function (parser location key-symbol tuning shape-definition)
23    (symbol? pair? string-or-pair?)
24    "Add chord shape @code{shape-definition} to the @code{chord-shape-table}
25 hash with the key @code{(cons key-symbol tuning)}."
26    (hash-set! chord-shape-table
27                (cons key-symbol tuning)
28                shape-definition)
29    (make-music 'SequentialMusic 'void #t))
30
31 #(define (chord-shape shape-code tuning)
32    (get-chord-shape shape-code tuning chord-shape-table))
33
34 % music function for adding a predefined diagram to
35 % fretboard-table
36
37 storePredefinedDiagram =
38 #(define-music-function (parser location chord tuning diagram-definition)
39   (ly:music? pair? string-or-pair?)
40   "Add predefined fret diagram defined by @code{diagram-definition}
41 for the chord pitches @code{chord} and
42 the stringTuning @code{tuning}."
43   (let* ((pitches (event-chord-pitches 
44                     (car (extract-named-music chord 'EventChord))))
45          (hash-key (cons tuning pitches))
46          (verbose-definition (if (string? diagram-definition)
47                                  (parse-terse-string diagram-definition)
48                                  diagram-definition)))
49   (hash-set! fretboard-table 
50              hash-key 
51              verbose-definition))
52   (make-music 'SequentialMusic 'void #t))
53