@end lilypond
Fingering indications and barres can be included in a
-fret-diagram-verbose markup string.
+fret-diagram-verbose markup string. Unique to the
+fret-diagram-verbose interface is a capo indication that
+can be placed on the fret diagram. The capo indication is
+a thick bar that covers all strings. The fret with the
+capo will be the lowest fret in the fret diagram.
@c \override is necessary to make fingering visible
@lilypond[quote, verbatim]
<<
\context ChordNames {
\chordmode {
- f1 g
+ f1 g c
}
}
\context Staff {
(open 2)
(place-fret 1 3 3)
)
- }
+ < c e g c' e'> ^\markup
+ \fret-diagram-verbose #'(
+ (capo 3)
+ (mute 6)
+ (place-fret 4 5 1)
+ (place-fret 3 5 2)
+ (place-fret 2 5 3)
+ )
+ }
>>
@end lilypond
@cindex adding custom fret diagrams
Fret diagrams can be added to the fret diagram table. To add a diagram,
-you must specify the chord for the diagram, the tuning to be used, and the
-fret-diagram-terse definition string for the diagram.
+you must specify the chord for the diagram, the tuning to be used, and
+a definition for the diagram. The diagram definition can be either a
+fret-diagram-terse definition string or a fret-diagram-verbose
+marking list.
@lilypond[verbatim, ragged-right, quote]
\include "predefined-guitar-fretboards.ly"
\storePredefinedDiagram \chordmode {c'}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'bes))
+ #(offset-fret 2 (chord-shape 'bes guitar-tuning))
mychords = \chordmode{
c1 c'
shapes. The chord shapes are fret diagrams that can be shifted along
the neck to different posistions to provide different chords. Chord
shapes can be added to the internal list and then used to define
-predefined fret diagrams.
+predefined fret diagrams. Like fret diagrams, chord shapes can be
+entered as either fret-diagram-terse strings or fret-diagram-verbose
+marking lists.
@lilypond[verbatim, ragged-right, quote]
\include "predefined-guitar-fretboards.ly"
% add a new chord shape
-\addChordShape #'powerf #"1-1;3-3;3-4;x;x;x;"
+\addChordShape #'powerf #guitar-tuning #"1-1;3-3;3-4;x;x;x;"
% add some new chords based on the power chord shape
\storePredefinedDiagram \chordmode {f'}
#guitar-tuning
- #(chord-shape 'powerf)
+ #(chord-shape 'powerf guitar-tuning)
\storePredefinedDiagram \chordmode {g'}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'powerf))
+ #(offset-fret 2 (chord-shape 'powerf guitar-tuning))
mychords = \chordmode{
f1 f' g g'
}
<<
- \chords {a2 a c c d}
+ \chords {a2 a c c c d}
\new Voice =mel {
\textLengthOn
(place-fret 2 5 4)
(place-fret 1 3 1)
(barre 5 1 3)) }}
- %% simple D chord
+
+
+ %% C major for guitar, with capo on third fret
+ % verbose style
+ c' ^\markup
+ \override #'(size . 1.1) { % 110% of default size
+ \override #'(fret-diagram-details . (
+ (dot-label-font-mag . 0.9)
+ (finger-code . in-dot)
+ (xo-font-magnification . 0.4)
+ (xo-padding . 0.3))) {
+ \fret-diagram-verbose #'((mute 6)
+ (capo 3)
+ (open 5)
+ (place-fret 4 5 1)
+ (place-fret 3 5 2)
+ (place-fret 2 5 3)
+ (open 1)) }}
+
+ %% simple D chord
d' ^\markup
\override #'(fret-diagram-details . (
% add a chord shape
-\version "2.11.56"
+\version "2.11.65"
-\addChordShape #'bes #"x;1-1-(;3-2;3-3;3-4;1-1-);"
+\addChordShape #'bes #guitar-tuning #"x;1-1-(;3-2;3-3;3-4;1-1-);"
% add chords
\storePredefinedDiagram \chordmode {bes}
#guitar-tuning
- #(chord-shape 'bes)
+ #(chord-shape 'bes guitar-tuning)
\storePredefinedDiagram \chordmode {c}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'bes))
+ #(offset-fret 2 (chord-shape 'bes guitar-tuning))
mychords = \chordmode {
bes
#(define fretboard-table (make-hash-table 100))
+#(define chord-shape-table (make-hash-table 100))
\include "scale-definitions-init.ly"
%%%%
%%%% (c) 2008 Carl D. Sorensen <c_sorensen@byu.edu>
-\version "2.11.56"
-
-%%%%% define storage structures
-
-% 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,
+\version "2.11.65"
+
+% 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))
+#(define-music-function (parser location key-symbol tuning shape-definition)
+ (symbol? pair? string-or-pair?)
+ "Add chord shape @code{shape-definition} to the @code{chord-shape-table}
+hash with the key @code{(cons key-symbol tuning)}."
+ (hash-set! chord-shape-table
+ (cons key-symbol tuning)
+ shape-definition)
(make-music 'SequentialMusic 'void #t))
-% for convenience, to eliminate storage list in .ly references
-
-#(define (chord-shape shape-code)
- (get-chord-shape shape-code base-chord-shapes))
+#(define (chord-shape shape-code tuning)
+ (get-chord-shape shape-code tuning chord-shape-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
+#(define-music-function (parser location chord tuning diagram-definition)
+ (ly:music? pair? string-or-pair?)
+ "Add predefined fret diagram defined by @code{diagram-definition}
+for the chord pitches @code{chord} and
the stringTuning @code{tuning}."
(let* ((pitches (event-chord-pitches
(car (extract-named-music chord 'EventChord))))
- (hash-key (cons tuning pitches)))
+ (hash-key (cons tuning pitches))
+ (verbose-definition (if (string? diagram-definition)
+ (parse-terse-string diagram-definition)
+ diagram-definition)))
(hash-set! fretboard-table
hash-key
- (parse-terse-string terse-definition)))
+ verbose-definition))
(make-music 'SequentialMusic 'void #t))
\version "2.11.56"
-\addChordShape #'f #"1-1-(;3-3;3-4;2-2;1-1;1-1-);"
-\addChordShape #'f:m #"1-1-(;3-3;3-4;1-1;1-1;1-1-);"
-\addChordShape #'f:7 #"1-1-(;3-3;1-1;2-2;1-1;1-1-);"
-\addChordShape #'f:m7 #"1-1-(;3-3;1-1;1-1;1-1;1-1-);"
-\addChordShape #'bes #"x;1-1-(;3-2;3-3;3-4;1-1-);"
-\addChordShape #'bes:m #"x;1-1-(;3-3;3-4;2-2;1-1-);"
-\addChordShape #'bes:m7 #"x;1-1-(;3-3;1-1;2-2;1-1-);"
-\addChordShape #'bes:7 #"x;1-1-(;3-2;1-1;3-3;1-1-);"
-\addChordShape #'bes:maj7 #"x;1-1;3-3;2-2;3-4;x;"
-\addChordShape #'c:dim #"x;x;1-1;2-3;1-2;2-4;"
-\addChordShape #'c:aug #"x;x;2-2;1-1-(;1-1-);4-4;"
-\addChordShape #'cis #"x;x;3-3;1-1-(;2-2;1-1-);"
-\addChordShape #'ees:dim #"x;x;1-1;2-3;1-2;2-4;"
-\addChordShape #'a:dim #"x;x;1-1;2-3;1-2;2-4;"
+\addChordShape #'f #guitar-tuning #"1-1-(;3-3;3-4;2-2;1-1;1-1-);"
+\addChordShape #'f:m #guitar-tuning #"1-1-(;3-3;3-4;1-1;1-1;1-1-);"
+\addChordShape #'f:7 #guitar-tuning #"1-1-(;3-3;1-1;2-2;1-1;1-1-);"
+\addChordShape #'f:m7 #guitar-tuning #"1-1-(;3-3;1-1;1-1;1-1;1-1-);"
+\addChordShape #'bes #guitar-tuning #"x;1-1-(;3-2;3-3;3-4;1-1-);"
+\addChordShape #'bes:m #guitar-tuning #"x;1-1-(;3-3;3-4;2-2;1-1-);"
+\addChordShape #'bes:m7 #guitar-tuning #"x;1-1-(;3-3;1-1;2-2;1-1-);"
+\addChordShape #'bes:7 #guitar-tuning #"x;1-1-(;3-2;1-1;3-3;1-1-);"
+\addChordShape #'bes:maj7 #guitar-tuning #"x;1-1;3-3;2-2;3-4;x;"
+\addChordShape #'c:dim #guitar-tuning #"x;x;1-1;2-3;1-2;2-4;"
+\addChordShape #'c:aug #guitar-tuning #"x;x;2-2;1-1-(;1-1-);4-4;"
+\addChordShape #'cis #guitar-tuning #"x;x;3-3;1-1-(;2-2;1-1-);"
+\addChordShape #'ees:dim #guitar-tuning #"x;x;1-1;2-3;1-2;2-4;"
+\addChordShape #'a:dim #guitar-tuning #"x;x;1-1;2-3;1-2;2-4;"
%%% Add predefined chords
#"x;3-3;2-2;o;1-1;o;"
\storePredefinedDiagram \chordmode {c:m}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'bes:m))
+ #(offset-fret 2 (chord-shape 'bes:m guitar-tuning))
\storePredefinedDiagram \chordmode {c:aug}
#guitar-tuning
- #(chord-shape 'c:aug)
+ #(chord-shape 'c:aug guitar-tuning)
\storePredefinedDiagram \chordmode {c:dim}
#guitar-tuning
- #(chord-shape 'c:dim)
+ #(chord-shape 'c:dim guitar-tuning)
\storePredefinedDiagram \chordmode {c:7}
#guitar-tuning
#"o;3-3;2-2;3-4;1-1;o;"
#"x;3-3;2-2;o;o;o;"
\storePredefinedDiagram \chordmode {c:m7}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'bes:m7))
+ #(offset-fret 2 (chord-shape 'bes:m7 guitar-tuning))
%%%% cis chords
%
\storePredefinedDiagram \chordmode {cis}
#guitar-tuning
- #(chord-shape 'cis)
+ #(chord-shape 'cis guitar-tuning)
\storePredefinedDiagram \chordmode {cis:m}
#guitar-tuning
#"x;x;2-2;1-1;2-3;o;"
#"x;4-4;3-3;2-1;2-2;x;"
\storePredefinedDiagram \chordmode {cis:dim}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'c:dim))
+ #(offset-fret 1 (chord-shape 'c:dim guitar-tuning))
\storePredefinedDiagram \chordmode {cis:7}
#guitar-tuning
#"x;x;3-2;4-3;2-1;4-4;"
#"x;4-4;3-3;2-1;2-2;x;"
\storePredefinedDiagram \chordmode {des:dim}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'c:dim))
+ #(offset-fret 1 (chord-shape 'c:dim guitar-tuning))
\storePredefinedDiagram \chordmode {des:7}
#guitar-tuning
#"x;x;3-2;4-3;2-1;4-4;"
%
\storePredefinedDiagram \chordmode {dis}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'cis))
+ #(offset-fret 2 (chord-shape 'cis guitar-tuning))
\storePredefinedDiagram \chordmode {dis:m}
#guitar-tuning
#"x;x;4-3;3-2;4-4;1-1;"
#"3-3;2-2;1-1;o;o;3-4"
\storePredefinedDiagram \chordmode {dis:dim}
#guitar-tuning
- #(chord-shape 'ees:dim)
+ #(chord-shape 'ees:dim guitar-tuning)
\storePredefinedDiagram \chordmode {dis:7}
#guitar-tuning
#"x;x;1-1;3-3;2-2;3-4;"
%
\storePredefinedDiagram \chordmode {ees}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'cis))
+ #(offset-fret 2 (chord-shape 'cis guitar-tuning))
\storePredefinedDiagram \chordmode {ees:m}
#guitar-tuning
#"x;x;4-3;3-2;4-4;1-1;"
#"3-3;2-2;1-1;o;o;3-4"
\storePredefinedDiagram \chordmode {ees:dim}
#guitar-tuning
- #(chord-shape 'ees:dim)
+ #(chord-shape 'ees:dim guitar-tuning)
\storePredefinedDiagram \chordmode {ees:7}
#guitar-tuning
#"x;x;1-1;3-3;2-2;3-4;"
#"o;3-3;2-2;1-1;x;x;"
\storePredefinedDiagram \chordmode {e:dim}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'ees:dim))
+ #(offset-fret 1 (chord-shape 'ees:dim guitar-tuning))
\storePredefinedDiagram \chordmode {e:7}
#guitar-tuning
#"o;2-2;o;1-1;o;o;"
%
\storePredefinedDiagram \chordmode {f}
#guitar-tuning
- #(chord-shape 'f)
+ #(chord-shape 'f guitar-tuning)
\storePredefinedDiagram \chordmode {f:m}
#guitar-tuning
- #(chord-shape 'f:m)
+ #(chord-shape 'f:m guitar-tuning)
\storePredefinedDiagram \chordmode {f:aug}
#guitar-tuning
#"x;x;1-1;4-3;4-4;3-2;"
#"x;x;o;1-1;o;1-2;"
\storePredefinedDiagram \chordmode {f:7}
#guitar-tuning
- #(chord-shape 'f:7)
+ #(chord-shape 'f:7 guitar-tuning)
\storePredefinedDiagram \chordmode {f:maj7}
#guitar-tuning
#"x;3-3;3-4;2-2;1-1;"
\storePredefinedDiagram \chordmode {f:m7}
#guitar-tuning
- #(chord-shape 'f:m7)
+ #(chord-shape 'f:m7 guitar-tuning)
%%%% fis chords
%
\storePredefinedDiagram \chordmode {fis}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f))
+ #(offset-fret 1 (chord-shape 'f guitar-tuning))
\storePredefinedDiagram \chordmode {fis:m}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:m))
+ #(offset-fret 1 (chord-shape 'f:m guitar-tuning))
\storePredefinedDiagram \chordmode {fis:aug}
#guitar-tuning
#"2-2;1-1;o;3-4-(;3-4-);2-3;"
#"x;x;1-1;2-3;1-2;2-4;"
\storePredefinedDiagram \chordmode {fis:7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:7))
+ #(offset-fret 1 (chord-shape 'f:7 guitar-tuning))
\storePredefinedDiagram \chordmode {fis:maj7}
#guitar-tuning
#"x;x;4-4;3-3;2-2;1-1;"
\storePredefinedDiagram \chordmode {fis:m7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:m7))
+ #(offset-fret 1 (chord-shape 'f:m7 guitar-tuning))
%%%% ges chords
%
\storePredefinedDiagram \chordmode {ges}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f))
+ #(offset-fret 1 (chord-shape 'f guitar-tuning))
\storePredefinedDiagram \chordmode {ges:m}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:m))
+ #(offset-fret 1 (chord-shape 'f:m guitar-tuning))
\storePredefinedDiagram \chordmode {ges:aug}
#guitar-tuning
#"2-2;1-1;o;3-4-(;3-4-);2-3;"
#"x;x;1-1;2-3;1-2;2-4;"
\storePredefinedDiagram \chordmode {ges:7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:7))
+ #(offset-fret 1 (chord-shape 'f:7 guitar-tuning))
\storePredefinedDiagram \chordmode {ges:maj7}
#guitar-tuning
#"x;x;4-4;3-3;2-2;1-1;"
\storePredefinedDiagram \chordmode {ges:m7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:m7))
+ #(offset-fret 1 (chord-shape 'f:m7 guitar-tuning))
%%%% g chords
%
#"3-2;2-1;o;o;o;3-3;"
\storePredefinedDiagram \chordmode {g:m}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'f:m))
+ #(offset-fret 2 (chord-shape 'f:m guitar-tuning))
\storePredefinedDiagram \chordmode {g:aug}
#guitar-tuning
#"x;x;5-1;8-3;8-4;7-2;"
#"x;x;5-4;4-3;3-2;2-1;"
\storePredefinedDiagram \chordmode {g:m7}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'f:m7))
+ #(offset-fret 2 (chord-shape 'f:m7 guitar-tuning))
%%%% gis chords
%
\storePredefinedDiagram \chordmode {gis}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f))
+ #(offset-fret 3 (chord-shape 'f guitar-tuning))
\storePredefinedDiagram \chordmode {gis:m}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:m))
+ #(offset-fret 3 (chord-shape 'f:m guitar-tuning))
\storePredefinedDiagram \chordmode {gis:aug}
#guitar-tuning
#"o;3-4;2-3;1-1;1-2;o;"
#"x;x;o;1-1;o;1-2;"
\storePredefinedDiagram \chordmode {gis:7}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:7))
+ #(offset-fret 3 (chord-shape 'f:7 guitar-tuning))
\storePredefinedDiagram \chordmode {gis:maj7}
#guitar-tuning
#"x;x;1-1-(;1-1;1-1-);3-3;"
\storePredefinedDiagram \chordmode {gis:m7}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:m7))
+ #(offset-fret 3 (chord-shape 'f:m7 guitar-tuning))
%%%% aes chords
%
\storePredefinedDiagram \chordmode {aes}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f))
+ #(offset-fret 3 (chord-shape 'f guitar-tuning))
\storePredefinedDiagram \chordmode {aes:m}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:m))
+ #(offset-fret 3 (chord-shape 'f:m guitar-tuning))
\storePredefinedDiagram \chordmode {aes:aug}
#guitar-tuning
#"o;3-4;2-3;1-1;1-2;o;"
#"x;x;o;1-1;o;1-2;"
\storePredefinedDiagram \chordmode {aes:7}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:7))
+ #(offset-fret 3 (chord-shape 'f:7 guitar-tuning))
\storePredefinedDiagram \chordmode {aes:maj7}
#guitar-tuning
#"x;x;1-1-(;1-1;1-1-);3-3;"
\storePredefinedDiagram \chordmode {aes:m7}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:m7))
+ #(offset-fret 3 (chord-shape 'f:m7 guitar-tuning))
%%%% a chords
%
#"x;o;3-4;2-2;2-3;1-1;"
\storePredefinedDiagram \chordmode {a:dim}
#guitar-tuning
- #(chord-shape 'a:dim)
+ #(chord-shape 'a:dim guitar-tuning)
\storePredefinedDiagram \chordmode {a:7}
#guitar-tuning
#"x;o;2-1;o;2-3;o;"
%
\storePredefinedDiagram \chordmode {ais}
#guitar-tuning
- #(chord-shape 'bes)
+ #(chord-shape 'bes guitar-tuning)
\storePredefinedDiagram \chordmode {ais:m}
#guitar-tuning
- #(chord-shape 'bes:m)
+ #(chord-shape 'bes:m guitar-tuning)
\storePredefinedDiagram \chordmode {ais:aug}
#guitar-tuning
#"2-2;1-1;o;3-4-(;3-4-);2-3;"
\storePredefinedDiagram \chordmode {ais:dim}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'a:dim))
+ #(offset-fret 1 (chord-shape 'a:dim guitar-tuning))
\storePredefinedDiagram \chordmode {ais:7}
#guitar-tuning
- #(chord-shape 'bes:7)
+ #(chord-shape 'bes:7 guitar-tuning)
\storePredefinedDiagram \chordmode {ais:maj7}
#guitar-tuning
#"x;1-1;3-3;2-2;3-4;x;"
\storePredefinedDiagram \chordmode {ais:m7}
#guitar-tuning
- #(chord-shape 'bes:m7)
+ #(chord-shape 'bes:m7 guitar-tuning)
%%%% bes chords
%
\storePredefinedDiagram \chordmode {bes}
#guitar-tuning
- #(chord-shape 'bes)
+ #(chord-shape 'bes guitar-tuning)
\storePredefinedDiagram \chordmode {bes:m}
#guitar-tuning
- #(chord-shape 'bes:m)
+ #(chord-shape 'bes:m guitar-tuning)
\storePredefinedDiagram \chordmode {bes:aug}
#guitar-tuning
#"2-2;1-1;o;3-4-(;3-4-);2-3;"
\storePredefinedDiagram \chordmode {bes:dim}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'a:dim))
+ #(offset-fret 1 (chord-shape 'a:dim guitar-tuning))
\storePredefinedDiagram \chordmode {bes:7}
#guitar-tuning
- #(chord-shape 'bes:7)
+ #(chord-shape 'bes:7 guitar-tuning)
\storePredefinedDiagram \chordmode {bes:maj7}
#guitar-tuning
#"x;1-1;3-3;2-2;3-4;x;"
\storePredefinedDiagram \chordmode {bes:m7}
#guitar-tuning
- #(chord-shape 'bes:m7)
+ #(chord-shape 'bes:m7 guitar-tuning)
%%%% b chords
%
\storePredefinedDiagram \chordmode {b}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'bes))
+ #(offset-fret 1 (chord-shape 'bes guitar-tuning))
\storePredefinedDiagram \chordmode {b:m}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'bes:m))
+ #(offset-fret 1 (chord-shape 'bes:m guitar-tuning))
\storePredefinedDiagram \chordmode {b:aug}
#guitar-tuning
#"x;3-2;2-1;o;o;x;"
#"x;x;o;1-1;o;1-2;"
\storePredefinedDiagram \chordmode {b:7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'bes:7))
+ #(offset-fret 1 (chord-shape 'bes:7 guitar-tuning))
\storePredefinedDiagram \chordmode {b:maj7}
#guitar-tuning
#"x;2-1;4-3;3-2;4-4;x;"
\storePredefinedDiagram \chordmode {b:m7}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'bes:m7))
+ #(offset-fret 1 (chord-shape 'bes:m7 guitar-tuning))
%
-\addChordShape #'c:9 #"x;3-2;2-1;3-3-(;3-3;3-3-);"
-\addChordShape #'f:9 #"1-1-(;3-3;1-1;2-2;1-1-);3-4;"
+\addChordShape #'c:9 #guitar-tuning #"x;3-2;2-1;3-3-(;3-3;3-3-);"
+\addChordShape #'f:9 #guitar-tuning #"1-1-(;3-3;1-1;2-2;1-1-);3-4;"
\storePredefinedDiagram \chordmode {c:9}
#guitar-tuning
- #(chord-shape 'c:9)
+ #(chord-shape 'c:9 guitar-tuning)
\storePredefinedDiagram \chordmode {cis:9}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'c:9))
+ #(offset-fret 1 (chord-shape 'c:9 guitar-tuning))
\storePredefinedDiagram \chordmode {des:9}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'c:9))
+ #(offset-fret 1 (chord-shape 'c:9 guitar-tuning))
\storePredefinedDiagram \chordmode {d:9}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'c:9))
+ #(offset-fret 2 (chord-shape 'c:9 guitar-tuning))
\storePredefinedDiagram \chordmode {dis:9}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'c:9))
+ #(offset-fret 3 (chord-shape 'c:9 guitar-tuning))
\storePredefinedDiagram \chordmode {ees:9}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'c:9))
+ #(offset-fret 3 (chord-shape 'c:9 guitar-tuning))
\storePredefinedDiagram \chordmode {e:9}
#guitar-tuning
#"o;2-2;o;1-1;o;2-3;"
\storePredefinedDiagram \chordmode {f:9}
#guitar-tuning
- #(chord-shape 'f:9)
+ #(chord-shape 'f:9 guitar-tuning)
\storePredefinedDiagram \chordmode {fis:9}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:9))
+ #(offset-fret 1 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {ges:9}
#guitar-tuning
- #(offset-fret 1 (chord-shape 'f:9))
+ #(offset-fret 1 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {g:9}
#guitar-tuning
- #(offset-fret 2 (chord-shape 'f:9))
+ #(offset-fret 2 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {gis:9}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:9))
+ #(offset-fret 3 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {aes:9}
#guitar-tuning
- #(offset-fret 3 (chord-shape 'f:9))
+ #(offset-fret 3 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {a:9}
#guitar-tuning
- #(offset-fret 4 (chord-shape 'f:9))
+ #(offset-fret 4 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {ais:9}
#guitar-tuning
- #(offset-fret 5 (chord-shape 'f:9))
+ #(offset-fret 5 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {bes:9}
#guitar-tuning
- #(offset-fret 5 (chord-shape 'f:9))
+ #(offset-fret 5 (chord-shape 'f:9 guitar-tuning))
\storePredefinedDiagram \chordmode {b:9}
#guitar-tuning
- #(offset-fret -1 (chord-shape 'c:9))
+ #(offset-fret -1 (chord-shape 'c:9 guitar-tuning))
str = re.sub ('InnerChoirStaff', 'ChoirStaff', str)
return str
+def conv(str):
+ if re.search(r'\\addChordShape', str):
+ stderr_write ("\n")
+ stderr_write (NOT_SMART % _("stringTuning must be added to \
+ addChordShape call.\n"))
+ stderr_write (UPDATE_MANUALLY)
+ raise FatalConversionError ()
+ if re.search(r'\\chord-shape', str):
+ stderr_write ("\n")
+ stderr_write (NOT_SMART % _("stringTuning must be added to \
+ chord-shape call.\n"))
+ stderr_write (UPDATE_MANUALLY)
+ raise FatalConversionError ()
+ return str
+
# Guidelines to write rules (please keep this at the end of this file)
#
# - keep at most one rule per version; if several conversions should be done,
(define-public (number-or-string? x)
(or (number? x) (string? x)))
+(define-public (string-or-pair? x)
+ (or (string? x) (pair? x)))
+
(define-public (scheme? x) #t)
Choices include @code{curved}, @code{straight}, and
@code{none}. Default @code{curved}.
@item
+@code{capo-thickness} -- Thickness of capo indicator, in
+multiples of fret-space. Default value 0.5.
+@item
@code{dot-color} -- Color of dots. Options include
@code{black} and @code{white}. Default @code{black}.
@item
(define (fret-parse-marking-list marking-list fret-count)
(let* ((fret-range (list 1 fret-count))
+ (capo-fret 0)
(barre-list '())
(dot-list '())
(xo-list '())
(set! xo-list (cons* my-item xo-list)))
((eq? my-code 'barre)
(set! barre-list (cons* (cdr my-item) barre-list)))
+ ((eq? my-code 'capo)
+ (set! capo-fret (cadr my-item)))
((eq? my-code 'place-fret)
(set! dot-list (cons* (cdr my-item) dot-list))))
(parse-item (cdr mylist)))))
;; calculate fret-range
- (let ((maxfret 0) (minfret 99))
+ (let ((maxfret 0)
+ (minfret (if (> capo-fret 0) capo-fret 99)))
(let updatemax ((fret-list dot-list))
(if (null? fret-list)
'()
(list minfret
(let ((upfret (- (+ minfret fret-count) 1)))
(if (> maxfret upfret) maxfret upfret)))))
+ (set! capo-fret (1+ (- capo-fret minfret)))
; subtract fret from dots
(set! dot-list (subtract-base-fret (- (car fret-range) 1) dot-list)))
(acons 'fret-range fret-range
(acons 'barre-list barre-list
(acons 'dot-list dot-list
- (acons 'xo-list xo-list '()))))))
+ (acons 'xo-list xo-list
+ (acons 'capo-fret capo-fret '())))))))
(define (subtract-base-fret base-fret dot-list)
"Subtract @var{base-fret} from every fret in @var{dot-list}"
(ly:make-stencil (list 'round-filled-box y1 y2 x1 x2 sth)
y-extent x-extent))))
+(define (draw-capo details string-count fret fret-count th size
+ dot-pos orientation)
+ "Draw a capo indicator across the full width of the fret-board
+ at fret capo-fret."
+ (let* ((sth (* th size))
+ (capo-thick
+ (* size (assoc-get 'capo-thickness details 0.5)))
+ (half-thick (* capo-thick 0.5))
+ (last-string-pos 0)
+ (first-string-pos (* size (- string-count 1)))
+ (fret-pos ( * size (if (eq? orientation 'normal)
+ (+ 2 (- fret-count fret dot-pos))
+ (1- (+ dot-pos fret))))))
+ (if (eq? orientation 'normal)
+ (make-line-stencil capo-thick
+ last-string-pos fret-pos first-string-pos fret-pos)
+ (make-line-stencil capo-thick
+ fret-pos last-string-pos fret-pos first-string-pos))))
+
+
(define (draw-frets fret-range string-count th size orientation)
"Draw the fret lines for a fret diagram with
@var{string-count} strings and frets as indicated in @var{fret-range}.
(* size (+ 1 label-vertical-offset)) X))))
(define-builtin-markup-command (fret-diagram-verbose layout props marking-list)
- (list?) ; argument type
+ (pair?) ; argument type (list, but use pair? for speed)
instrument-specific-markup ; markup type
((align-dir -0.4) ; properties and defaults
(size 1.0)
Place a barre indicator (much like a tie) from string @var{start-string}
to string @var{end-string} at fret @var{fret-number}.
+@item (capo @var{fret-number})
+Place a capo indicator (a large solid bar) across the entire fretboard
+at fret location @var{fret-number}. Also, set fret @var{fret-number}
+to be the lowest fret on the fret diagram.
+
@item (place-fret @var{string-number} @var{fret-number} @var{finger-value})
Place a fret playing indication on string @var{string-number} at fret
@var{fret-number} with an optional fingering label @var{finger-value}.
(label-space (* 0.25 size))
(label-dir (assoc-get 'label-dir details RIGHT))
(parameters (fret-parse-marking-list marking-list fret-count))
+ (capo-fret (assoc-get 'capo-fret parameters 0))
(dot-list (cdr (assoc 'dot-list parameters)))
(xo-list (cdr (assoc 'xo-list parameters)))
(fret-range (cdr (assoc 'fret-range parameters)))
(draw-xo layout props string-count fret-range
size xo-list orientation)
xo-padding))))
+ (if (> capo-fret 0)
+ (set! fret-diagram-stencil
+ (ly:stencil-add
+ fret-diagram-stencil
+ (draw-capo details string-count capo-fret fret-count
+ th size dot-position orientation))))
(if (> (car fret-range) 1)
(set! fret-diagram-stencil
(if (eq? orientation 'normal)
(define-public (parse-terse-string terse-definition)
"Parse a fret-diagram-terse definition string @code{terse-definition} and
-return a marking list, which can be used as with a fretboard grob."
+return a marking list, which can be used with a fretboard grob."
(cdr (fret-parse-terse-definition-string (list '()) terse-definition)))
-(define-public (get-chord-shape shape-code base-chord-shapes)
-"Return the chord shape associated with key @code{shape-code} in
-the alist @code{base-chord-shapes}."
- (assoc-get shape-code base-chord-shapes #f))
-
-(define-public (offset-fret fret-offset terse-string)
-"Add @code{fret-offset} to each fret indication in @code{terse-string}
-and return the resulting fret-diagram-terse definition string."
-
- (define (split-fretstring fret-string)
- (map (lambda (x) (split-item x))
- (string-split fret-string #\sp )))
-
- (define (split-item item-string)
- (string-split item-string #\- ))
-
- (define (split-terse-string terse-string)
- (let ((long-list
- (string-split terse-string #\;)))
- (map (lambda (x) (split-fretstring x))
- (list-head long-list (1- (length long-list))))))
-
- (define (join-terse-string terse-string-list)
- (string-join
- (map (lambda (x) (join-fretstring x)) terse-string-list)
- ";" 'suffix))
-
- (define (join-item item-list)
- (string-join item-list "-" ))
-
- (define (join-fretstring fretstring-list)
- (string-join
- (map (lambda (x) (join-item x)) fretstring-list)
- " " ))
-
- (define (add-item-fret-offset fret-offset item-list)
- (let ((fretval (string->number (car item-list))))
- (if fretval
- (cons (number->string (+ fretval fret-offset))
- (cdr item-list))
- item-list)))
-
- (define (add-fretstring-fret-offset fret-offset fretstring-list)
- (map (lambda (x) (add-item-fret-offset fret-offset x))
- fretstring-list))
-
- (define (add-terse-fret-offset fret-offset terse-string-list)
- (map (lambda (x) (add-fretstring-fret-offset fret-offset x))
- terse-string-list))
-
-;; body
- (join-terse-string
- (add-terse-fret-offset
- fret-offset
- (split-terse-string terse-string))))
+(define-public (get-chord-shape shape-code tuning base-chord-shapes)
+"Return the chord shape associated with @code{shape-code} and
+@code{tuning} in the hash-table @code{base-chord-shapes}."
+ (let ((hash-handle (hash-get-handle base-chord-shapes
+ (cons shape-code tuning))))
+ (if hash-handle
+ (cdr hash-handle)
+ '())))
+
+(define-public (offset-fret fret-offset diagram-definition)
+"Add @code{fret-offset} to each fret indication in @code{diagram-definition}
+and return the resulting verbose fret-diagram-definition."
+ (let ((verbose-definition
+ (if (string? diagram-definition)
+ (parse-terse-string diagram-definition)
+ diagram-definition)))
+ (map (lambda(item)
+ (let ((code (car item)))
+ (cond
+ ((eq? code 'barre)
+ (list-set! item 3
+ (+ fret-offset (list-ref item 3)))
+ item)
+ ((eq? code 'capo)
+ (list-set! item 1
+ (+ fret-offset (list-ref item 1)))
+ item)
+ ((eq? code 'place-fret)
+ (list-set! item 2
+ (+ fret-offset (list-ref item 2)))
+ item)
+ (else item))))
+ verbose-definition)))