X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=ly%2Fpredefined-fretboards-init.ly;h=71000148b6708d4770c60beac2e1a35bcf7df470;hb=26a079ca2393d053315ef8dbef626c897dc9645a;hp=f205b63269ce9c9be08d476e4f58ba6f95b87273;hpb=bc95f4434f760d41191341ab4508b2064eb19025;p=lilypond.git diff --git a/ly/predefined-fretboards-init.ly b/ly/predefined-fretboards-init.ly index f205b63269..71000148b6 100644 --- a/ly/predefined-fretboards-init.ly +++ b/ly/predefined-fretboards-init.ly @@ -1,6 +1,6 @@ %%%% This file is part of LilyPond, the GNU music typesetter. %%%% -%%%% Copyright (C) 2008--2010 Carl D. Sorensen +%%%% Copyright (C) 2008--2012 Carl D. Sorensen %%%% %%%% LilyPond is free software: you can redistribute it and/or modify %%%% it under the terms of the GNU General Public License as published by @@ -15,7 +15,7 @@ %%%% You should have received a copy of the GNU General Public License %%%% along with LilyPond. If not, see . -\version "2.12.0" +\version "2.16.0" % chord-shape-table is a hash-table of chord shapes % in the form of diagram-descriptions that can be @@ -33,7 +33,7 @@ addChordShape = #(define-music-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 @var{(cons key-symbol tuning)}.") +hash with the key @code{(cons @var{key-symbol} @var{tuning})}.") (hash-set! chord-shape-table (cons key-symbol tuning) shape-definition) @@ -42,21 +42,38 @@ hash with the key @var{(cons key-symbol tuning)}.") #(define (chord-shape shape-code tuning) (get-chord-shape shape-code tuning chord-shape-table)) +% scheme function for copying/creating fretboard tables + +#(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 diagram-definition) - (ly:music? pair? string-or-pair?) +#(define-music-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 + (let* ((pitches (event-chord-pitches (car (extract-named-music chord 'EventChord)))) (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)) - (make-music 'SequentialMusic 'void #t)) + (hash-set! fretboard-table + hash-key + verbose-definition) + (make-music 'SequentialMusic 'void #t)))