]> git.donarmstrong.com Git - lilypond.git/blob - ly/predefined-fretboards-init.ly
Merge branch 'master' of ssh://jeancharlesm@git.sv.gnu.org/srv/git/lilypond
[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 Carl D. Sorensen <c_sorensen@byu.edu>
6
7 %%%%% define storage structures
8
9 % base-chord-shapes is an alist of chord shapes
10 % in the form of fret-diagram-terse strings with
11 % scheme symbols as keys.  For convenience, the
12 % symbols are LilyPond chordmode chord descriptions,
13 % but that is unnecessary.
14
15 #(define base-chord-shapes '())
16
17
18 % music function for adding a chord shape to
19 % base-chord-shapes
20
21 addChordShape =
22 #(define-music-function (parser location key-symbol shape-string)
23    (symbol? string?)
24    (set! base-chord-shapes 
25            (acons key-symbol shape-string base-chord-shapes))
26    (make-music 'SequentialMusic 'void #t))
27
28 % for convenience, to eliminate storage list in .ly references
29
30 #(define (chord-shape shape-code)
31    (get-chord-shape shape-code base-chord-shapes))
32
33 % music function for adding a predefined diagram to
34 % fretboard-table
35
36 storePredefinedDiagram =
37 #(define-music-function (parser location chord tuning terse-definition)
38   (ly:music? list? string?)
39   (let* ((pitches (event-chord-pitches 
40                     (car (extract-named-music chord 'EventChord))))
41          (hash-key (cons tuning pitches)))
42   (hash-set! fretboard-table 
43              hash-key 
44              (parse-terse-string terse-definition)))
45   (make-music 'SequentialMusic 'void #t))
46