- (lambda (pitch-entry string-fret-finger)
- (let* ((string (list-ref string-fret-finger 0))
- (finger (if (= (length string-fret-finger) 3)
- (list-ref string-fret-finger 2)
- '()))
- (pitch (car pitch-entry))
- (digit (if (null? finger)
- #f
- finger)))
- (if (or (not (null? string))
- (eqv? digit 0))
- (if (eqv? digit 0)
- ;; here we handle fingers of 0 -- open strings
- (let ((fit-string
- (find (lambda (string)
- (open-string string pitch))
- free-strings)))
- (if fit-string
- (set-fret! pitch-entry fit-string #f)
- (ly:warning (_ "No open string for pitch ~a")
- pitch)))
- ;; here we handle assigned strings
- (let ((this-fret
- (calc-fret pitch string tuning))
- (handle-negative
- (ly:context-property context
- 'handleNegativeFrets
- 'recalculate)))
- (cond ((or (and (>= this-fret 0) (integer? this-fret))
- (eq? handle-negative 'include))
- (set-fret! pitch-entry string finger))
- ((eq? handle-negative 'recalculate)
- (begin
- (ly:warning
- (_ "Requested string for pitch requires negative fret: string ~a pitch ~a")
- string
- pitch)
- (ly:warning (_ "Ignoring string request and recalculating."))
- (list-set! string-fret-fingers
- (cdr pitch-entry)
- (if (null? finger)
- (list '() #f)
- (list '() #f finger)))))
- ((eq? handle-negative 'ignore)
- (begin
- (ly:warning
- (_ "Requested string for pitch requires negative fret: string ~a pitch ~a")
- string
- pitch)
- (ly:warning (_ "Ignoring note in tablature."))
- (kill-note! string-fret-fingers
- (cdr pitch-entry))))))))))
- pitch-alist string-fret-fingers)
- ;; handle notes without strings assigned -- sorted by pitch, so
- ;; we need to use the alist to have the note number available
- (for-each
- (lambda (pitch-entry)
- (let* ((string-fret-finger (list-ref string-fret-fingers
- (cdr pitch-entry)))
- (string (list-ref string-fret-finger 0))
- (finger (if (= (length string-fret-finger) 3)
- (list-ref string-fret-finger 2)
- '()))
- (pitch (car pitch-entry))
- (fit-string
- (find (lambda (string)
- (string-qualifies string pitch))
- free-strings)))
- (if (not (list-ref string-fret-finger 1))
- (if fit-string
- (set-fret! pitch-entry fit-string finger)
- (begin
- (ly:warning (_ "No string for pitch ~a (given frets ~a)")
- pitch
- specified-frets)
- (kill-note! string-fret-fingers
- (cdr pitch-entry)))))))
- (sort pitch-alist (lambda (pitch-entry-a pitch-entry-b)
- (ly:pitch<? (car pitch-entry-b)
- (car pitch-entry-a)))))
- string-fret-fingers)) ;; end of determine-frets-and-strings
+ (lambda (pitch-entry string-fret-finger)
+ (let* ((string (list-ref string-fret-finger 0))
+ (finger (if (= (length string-fret-finger) 3)
+ (list-ref string-fret-finger 2)
+ '()))
+ (pitch (car pitch-entry))
+ (digit (if (null? finger)
+ #f
+ finger)))
+ (if (or (not (null? string))
+ (eqv? digit 0))
+ (if (eqv? digit 0)
+ ;; here we handle fingers of 0 -- open strings
+ (let ((fit-string
+ (find (lambda (string)
+ (open-string string pitch))
+ free-strings)))
+ (if fit-string
+ (set-fret! pitch-entry fit-string #f)
+ (ly:warning (_ "No open string for pitch ~a")
+ pitch)))
+ ;; here we handle assigned strings
+ (let ((this-fret
+ (calc-fret pitch string tuning))
+ (handle-negative
+ (ly:context-property context
+ 'handleNegativeFrets
+ 'recalculate)))
+ (cond ((or (and (>= this-fret 0) (integer? this-fret))
+ (eq? handle-negative 'include))
+ (set-fret! pitch-entry string finger))
+ ((eq? handle-negative 'recalculate)
+ (begin
+ (ly:warning
+ (_ "Requested string for pitch requires negative fret: string ~a pitch ~a")
+ string
+ pitch)
+ (ly:warning (_ "Ignoring string request and recalculating."))
+ (list-set! string-fret-fingers
+ (cdr pitch-entry)
+ (if (null? finger)
+ (list '() #f)
+ (list '() #f finger)))))
+ ((eq? handle-negative 'ignore)
+ (begin
+ (ly:warning
+ (_ "Requested string for pitch requires negative fret: string ~a pitch ~a")
+ string
+ pitch)
+ (ly:warning (_ "Ignoring note in tablature."))
+ (kill-note! string-fret-fingers
+ (cdr pitch-entry))))))))))
+ pitch-alist string-fret-fingers)
+ ;; handle notes without strings assigned -- sorted by pitch, so
+ ;; we need to use the alist to have the note number available
+ (for-each
+ (lambda (pitch-entry)
+ (let* ((string-fret-finger (list-ref string-fret-fingers
+ (cdr pitch-entry)))
+ (string (list-ref string-fret-finger 0))
+ (finger (if (= (length string-fret-finger) 3)
+ (list-ref string-fret-finger 2)
+ '()))
+ (pitch (car pitch-entry))
+ (fit-string
+ (find (lambda (string)
+ (string-qualifies string pitch))
+ free-strings)))
+ (if (not (list-ref string-fret-finger 1))
+ (if fit-string
+ (set-fret! pitch-entry fit-string finger)
+ (begin
+ (ly:event-warning
+ (list-ref notes (cdr pitch-entry))
+ (_ "No string for pitch ~a (given frets ~a)")
+ pitch
+ specified-frets)
+ (kill-note! string-fret-fingers
+ (cdr pitch-entry)))))))
+ (sort pitch-alist (lambda (pitch-entry-a pitch-entry-b)
+ (ly:pitch<? (car pitch-entry-b)
+ (car pitch-entry-a)))))
+ string-fret-fingers)) ;; end of determine-frets-and-strings