From ab00c336d75e108d99e1598aaf9bf5f8109f3e67 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 25 Oct 2006 13:14:28 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 22 +++++ scm/define-context-properties.scm | 1 + scm/define-grob-properties.scm | 1 + scm/define-grobs.scm | 3 +- scm/fret-diagrams.scm | 11 ++- scm/output-lib.scm | 11 ++- scm/translation-functions.scm | 134 ++++++++++++++++++++---------- 7 files changed, 135 insertions(+), 48 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f0a443adf..5924fa2698 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,27 @@ +2006-10-25 Jan Nieuwenhuizen + + * scm/define-grobs.scm (all-grob-descriptions): FretBoard: use + fret-diagram-interface (WAS: fret-board-interface). Fixes build. + +2006-10-23 Jan Nieuwenhuizen + + * flower/file-name.cc (dos_to_posix): Help std::string.copy with + trailing zero. + + * GNUmakefile.in ($(tree-share-prefix)/mf-link-tree link-mf-tree): + Remove bashism in delete. + 2006-10-25 Han-Wen Nienhuys + * scm/define-grobs.scm (all-grob-descriptions): set finger-code. + + * scm/translation-functions.scm (determine-frets-mf): flatten let* + + * scm/define-context-properties.scm + (all-user-translation-properties): add maximumFretStretch property. + + * scm/translation-functions.scm (tunings): read and use maximumFretStretch. + * lily/source-file.cc (get_counts): use multibyte variable. * scm/translation-functions.scm (determine-frets-mf): new diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index b0c85c24ae..51f3c95b6f 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -312,6 +312,7 @@ markup. Called with 2 arguments, event and context.") (midiMaximumVolume ,number? "Analogous to @code{midiMinimumVolume}.") (minimumFret ,number? "The tablature auto string-selecting mechanism selects the highest string with a fret at least @code{minimumFret}") + (maximumFretStretch ,number? "Don't allocate frets further than this from specified frets.") (minimumPageTurnLength ,ly:moment? "Minimum length of a rest for a page turn to be allowed") (minimumRepeatLengthForPageTurn ,ly:moment? "Minimum length of a repeated section for a page turn to be allowed within that section") diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index c084ea855d..a9f3c994d2 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -390,6 +390,7 @@ object.") (size ,number? "Size of object, relative to standard size.") (slope ,number? "The slope of this object.") (slur-padding ,number? "Extra distance between slur and script.") + (string-fret-finger-combinations ,list? "List consisting of (string-number fret-number finger-number) entries." ) (space-alist ,list? "A table that specifies distances between prefatory items, like clef and time-signature. The format is an alist of spacing tuples: @code{(@var{break-align-symbol} @var{type} diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 1b640cbde0..ea47bee0f0 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -649,8 +649,9 @@ item-interface)))))) (FretBoard . ((stencil . ,fret-board::calc-stencil) + (finger-code . below-string) (meta . ((class . Item) - (interfaces . (fret-board-interface + (interfaces . (fret-diagram-interface font-interface )))) )) diff --git a/scm/fret-diagrams.scm b/scm/fret-diagrams.scm index 1558e3433d..2792ef7956 100644 --- a/scm/fret-diagrams.scm +++ b/scm/fret-diagrams.scm @@ -21,7 +21,8 @@ ((eq? my-code 'place-fret) (set! dot-list (cons* (cdr my-item) dot-list)))) (parse-item (cdr mylist))))) - ; calculate fret-range + + ;; calculate fret-range (let ((maxfret 0) (minfret 99)) (let updatemax ((fret-list dot-list)) (if (null? fret-list) @@ -40,7 +41,9 @@ (acons 'barre-list barre-list (acons 'dot-list dot-list (acons 'xo-list xo-list '())))))) - + + + (define (subtract-base-fret base-fret dot-list) "Subtract @var{base-fret} from every fret in @var{dot-list}" (if (null? dot-list) @@ -133,6 +136,7 @@ Line thickness is given by @var{th}, fret & string spacing by (define (draw-dots layout props string-count fret-range size finger-code dot-position dot-radius dot-thickness dot-list) "Make dots for fret diagram." + (let* ((scale-dot-radius (* size dot-radius)) (scale-dot-thick (* size dot-thickness)) (dot-color (chain-assoc-get 'dot-color props 'black)) @@ -326,6 +330,9 @@ changed by setting the value of the variable @var{dot-color}. If the variable @var{finger-code}. There is no limit to the number of fret indications per string. + + + @end table " (make-fret-diagram layout props marking-list)) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 07784a687a..3528dcb989 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -473,15 +473,22 @@ centered, X==1 is at the right, X == -1 is at the left." (for-each (lambda (sf) (let* ((string (car sf)) - (fret (cdr sf))) + (fret (cadr sf)) + (finger (caddr sf))) (vector-set! desc (1- string) (if (= 0 fret) (list 'open string) - (list 'place-fret string fret))) + (if finger + (list 'place-fret string fret finger) + (list 'place-fret string fret)) + + + )) )) string-frets) + (vector->list desc))) (define-public (fret-board::calc-stencil grob) diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index ff01c07582..0eab4fe5de 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -149,18 +149,20 @@ ((tunings (ly:context-property context 'stringTunings)) (minimum-fret (ensure-number (ly:context-property context 'minimumFret) 0)) + (max-stretch (ensure-number + (ly:context-property context 'maximumFretStretch) 4)) (string-frets (determine-frets-mf notes string-numbers - minimum-fret + minimum-fret max-stretch tunings))) (set! (ly:grob-property grob 'string-count) (length tunings)) - (set! (ly:grob-property grob 'string-frets) string-frets) + (set! (ly:grob-property grob 'string-fret-finger-combinations) string-frets) )) (define-public (determine-frets-mf notes string-numbers - minimum-fret + minimum-fret max-stretch tunings) (define (calc-fret pitch string tuning) @@ -172,8 +174,23 @@ (define (note-pitch= (calc-fret pitch string tunings) - minimum-fret)))) - (string-frets '()) - (set-fret (lambda (note string) - (set! string-frets - (acons string - (calc-fret (ly:event-property note 'pitch) - string tunings) - string-frets)) - (del-string string) - )) + (define (del-string string) + (if (number? string) + (set! free-strings + (delete string free-strings)))) + (define specified-frets '()) + (define free-strings '()) + + (define (close-enough fret) + (reduce + (lambda (x y) + (and x y)) + #t + (map (lambda (specced-fret) + (> max-stretch (abs (- fret specced-fret)))) + specified-frets) + )) + + (define (string-qualifies string pitch) + (let* + ((fret (calc-fret pitch string tunings))) + + (and (>= fret minimum-fret) + (close-enough fret)) + + )) + + (define string-fret-fingering-tuples '()) + (define (set-fret note string) + (set! string-fret-fingering-tuples + (cons (list string + (calc-fret (ly:event-property note 'pitch) + string tunings) + (note-finger note)) + string-fret-fingering-tuples)) + (del-string string)) - ) - - (for-each (lambda (note) - (del-string (note-ev-string note))) - notes) - - - (for-each - (lambda (note) - (if (note-ev-string note) - (set-fret note (note-ev-string note)) - (let* - ((string (find (lambda (string) (string-qualifies string - (note-pitch note))) - (reverse free-strings)))) + ;;; body. - (set-fret note string)))) - (sort notes note-pitch