- (if (null? details)
- (acons 'string-count (length tunings) '())
- (acons 'string-count (length tunings) details)))
- (set! (ly:grob-property grob 'dot-placement-list)
- (if predefined-frets
- (let ((predefined-fretboard
- (get-predefined-fretboard
- predefined-frets
- tunings
- pitches)))
- (if (null? predefined-fretboard)
- (string-frets->dot-placement
- 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
- minimum-fret max-stretch
- tunings)
+ (define (get-predefined-fretboard predefined-fret-table tuning pitches)
+ "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. Returns a placement-list."
+
+ (define (get-fretboard key)
+ (let ((hash-handle
+ (hash-get-handle predefined-fret-table key)))
+ (if hash-handle
+ (cdr hash-handle) ; return table entry
+ '())))
+
+ ;; body of get-predefined-fretboard
+ (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 of determine-frets
+ (let* ((predefined-fret-table
+ (ly:context-property context 'predefinedDiagramTable))
+ (tunings (ly:context-property context 'stringTunings))
+ (string-count (length tunings))
+ (grob (if (null? rest) '() (car rest)))
+ (pitches (map (lambda (x) (ly:event-property x 'pitch)) notes))
+ (predefined-fretboard
+ (if predefined-fret-table
+ (get-predefined-fretboard
+ predefined-fret-table
+ tunings
+ pitches)
+ '())))
+
+ (if (null? predefined-fretboard)
+ (let ((string-frets
+ (determine-frets-and-strings
+ notes
+ defined-strings
+ (ly:context-property context 'minimumFret 0)
+ (ly:context-property context 'maximumFretStretch 4)
+ tunings)))
+ (if (null? grob)
+ string-frets
+ (create-fretboard
+ context grob (string-frets->placement-list
+ string-frets string-count))))
+ (if (null? grob)
+ (placement-list->string-frets predefined-fretboard)
+ (create-fretboard context grob predefined-fretboard)))))
+
+
+(define (determine-frets-and-strings
+ notes defined-strings minimum-fret maximum-stretch tuning)