]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/predefined-fretboards-init.ly
Run grand replace for 2015.
[lilypond.git] / ly / predefined-fretboards-init.ly
index e999c93a4d38a0792e8156c23b91dbb97ddfa298..6a96f047e68536b6ffd0d32a0a014f44eacfe1da 100644 (file)
@@ -1,53 +1,77 @@
-%%%% predefined-fretboard-init.ly
+%%%% This file is part of LilyPond, the GNU music typesetter.
 %%%%
-%%%% source file of the GNU LilyPond music typesetter
+%%%% Copyright (C) 2008--2015 Carl D. Sorensen <c_sorensen@byu.edu>
 %%%%
-%%%% (c) 2008 Carl D. Sorensen <c_sorensen@byu.edu>
-
-\version "2.11.56"
+%%%% LilyPond is free software: you can redistribute it and/or modify
+%%%% it under the terms of the GNU General Public License as published by
+%%%% the Free Software Foundation, either version 3 of the License, or
+%%%% (at your option) any later version.
+%%%%
+%%%% LilyPond is distributed in the hope that it will be useful,
+%%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+%%%% GNU General Public License for more details.
+%%%%
+%%%% You should have received a copy of the GNU General Public License
+%%%% along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
 
-%%%%% define storage structures
+\version "2.16.0"
 
-% base-chord-shapes is an alist of chord shapes
-% in the form of fret-diagram-terse strings with
-% scheme symbols as keys.  For convenience, the
-% symbols are LilyPond chordmode chord descriptions,
+% chord-shape-table is a hash-table of chord shapes
+% in the form of diagram-descriptions that can be
+% fret-diagram-verbose markup-llsts or
+% fret-diagram-terse strings.
+% The hash keys are pairs of scheme symbols and
+% string tunings.  For convenience, the symbols in
+% this file are LilyPond chordmode chord descriptions,
 % but that is unnecessary.
 
-#(define base-chord-shapes '())
-
-
 % music function for adding a chord shape to
-% base-chord-shapes
+% chord-shape-table
 
 addChordShape =
-#(define-music-function (parser location key-symbol shape-string)
-   (symbol? string?)
-   "Add chord shape @code{shape-string} to the @code{base-chord-shapes}
-alist with the key @code{key-symbol}."
-   (set! base-chord-shapes 
-           (acons key-symbol shape-string base-chord-shapes))
-   (make-music 'SequentialMusic 'void #t))
+#(define-void-function (parser location key-symbol tuning shape-definition)
+   (symbol? pair? string-or-pair?)
+   (_i "Add chord shape @var{shape-definition} to the @var{chord-shape-table}
+hash with the key @code{(cons @var{key-symbol} @var{tuning})}.")
+   (hash-set! chord-shape-table
+               (cons key-symbol tuning)
+               shape-definition))
+
+#(define (chord-shape shape-code tuning)
+   (get-chord-shape shape-code tuning chord-shape-table))
 
-% for convenience, to eliminate storage list in .ly references
+% scheme function for copying/creating fretboard tables
 
-#(define (chord-shape shape-code)
-   (get-chord-shape shape-code base-chord-shapes))
+#(define (make-fretboard-table . rest)
+  "Create a new fretboard table.  @code{rest} is an optional table name.
+If present, the new fretboard table starts as a copy of the fretboard
+table @code{rest}."
+  (if (null? rest)
+      (make-hash-table 101)
+      (let ((source-table (car rest)))
+        (hash-fold
+          (lambda (key value tab)
+            (hash-set! tab key value)
+            tab)
+          (make-hash-table 101)
+          source-table))))
 
 % music function for adding a predefined diagram to
 % fretboard-table
 
 storePredefinedDiagram =
-#(define-music-function (parser location chord tuning terse-definition)
-  (ly:music? list? string?)
-  "Add predefined fret diagram defined by fret-diagram-terse definition
-string @code{terse-definition} for the chord pitches @code{chord} and
-the stringTuning @code{tuning}."
-  (let* ((pitches (event-chord-pitches 
+#(define-void-function
+   (parser location fretboard-table chord tuning diagram-definition)
+   (hash-table? ly:music? pair? string-or-pair?)
+  (_i "Add predefined fret diagram defined by @var{diagram-definition}
+  for the chord pitches @var{chord} and the stringTuning @var{tuning}.")
+  (let* ((pitches (event-chord-pitches
                     (car (extract-named-music chord 'EventChord))))
-         (hash-key (cons tuning pitches)))
-  (hash-set! fretboard-table 
-             hash-key 
-             (parse-terse-string terse-definition)))
-  (make-music 'SequentialMusic 'void #t))
-
+         (hash-key (cons tuning pitches))
+         (verbose-definition (if (string? diagram-definition)
+                                 (parse-terse-string diagram-definition)
+                                 diagram-definition)))
+  (hash-set! fretboard-table
+             hash-key
+             verbose-definition)))