@end lilypond
Different fret diagrams for the same chord name can be stored using different
-octaves of pitches.
+octaves of pitches. The different octave should be at least two octaves
+above or below the default octave, because the octaves above and below the
+default octave are used for transposing fretboards.
@lilypond[verbatim, ragged-right, quote]
\include "predefined-guitar-fretboards.ly"
-\storePredefinedDiagram \chordmode {c'}
+\storePredefinedDiagram \chordmode {c''}
#guitar-tuning
#(offset-fret 2 (chord-shape 'bes guitar-tuning))
mychords = \chordmode{
- c1 c'
+ c1 c''
}
<<
% add some new chords based on the power chord shape
-\storePredefinedDiagram \chordmode {f'}
+\storePredefinedDiagram \chordmode {f''}
#guitar-tuning
#(chord-shape 'powerf guitar-tuning)
-\storePredefinedDiagram \chordmode {g'}
+\storePredefinedDiagram \chordmode {g''}
#guitar-tuning
#(offset-fret 2 (chord-shape 'powerf guitar-tuning))
mychords = \chordmode{
- f1 f' g g'
+ f1 f'' g g''
}
<<
--- /dev/null
+\version "2.13.0"
+\header{
+
+ texidoc="
+Transposition by less than one octave up or down should not affect
+predefined fretboards.
+
+"
+}
+
+
+\include "predefined-guitar-fretboards.ly"
+
+myChords = \chordmode { c1 d }
+
+mySequence = {
+
+ \myChords
+ \transpose c c' {\myChords}
+ \transpose c c, { \myChords}
+}
+
+<<
+ \new ChordNames {\mySequence}
+ \new FretBoards {\mySequence}
+>>
+
(skip-as-needed x parser)
)))
+;;;;;;;;;;
+;;; general purpose music functions
+
+(define (shift-octave pitch octave-shift)
+ (_i "Add @var{octave-shift} to the octave of @var{pitch}.")
+ (ly:make-pitch
+ (+ (ly:pitch-octave pitch) octave-shift)
+ (ly:pitch-notename pitch)
+ (ly:pitch-alteration pitch)))
+
;;;;;;;;;;;;;;;;;
;; lyrics
))
string-frets)
(vector->list desc)))
+
+ (define (get-predefined-fretboard predefined-fret-table tuning pitches)
+; (_i "Search through @var{predefined-fret-table} looking for a predefined
+;fretboard with a key of @var{(tuning . pitches)}. The search will check
+;both up and down an octave in order to accomodate transposition of the
+;chords.")
+ (define (get-fretboard key)
+ (let ((hash-handle
+ (hash-get-handle predefined-fret-table key)))
+ (if hash-handle
+ (cdr hash-handle) ; return table entry
+ '())))
+
+ (let ((test-fretboard (get-fretboard (cons tuning pitches))))
+ (if (not (null? test-fretboard))
+ test-fretboard
+ (let ((test-fretboard
+ (get-fretboard
+ (cons tuning (map (lambda (x) (shift-octave x 1)) pitches)))))
+ (if (not (null? test-fretboard))
+ test-fretboard
+ (get-fretboard
+ (cons tuning (map (lambda (x) (shift-octave x -1)) pitches))))))))
;; body.
(let*
(acons 'string-count (length tunings) details)))
(set! (ly:grob-property grob 'dot-placement-list)
(if predefined-frets
- (let ((hash-handle
- (hash-get-handle
+ (let ((predefined-fretboard
+ (get-predefined-fretboard
predefined-frets
- (cons tunings pitches))))
- (if hash-handle
- (cdr hash-handle) ;found default diagram
+ tunings
+ pitches)))
+ (if (null? predefined-fretboard)
(string-frets->dot-placement
- string-frets my-string-count)))
+ string-frets my-string-count) ;no predefined diagram
+ predefined-fretboard)) ;found default diagram
(string-frets->dot-placement string-frets my-string-count)))))
(define-public (determine-frets-mf notes string-numbers