diff options
author | Thomas Morley <thomasmorley65@gmail.com> | 2016-02-09 10:21:00 +0100 |
---|---|---|
committer | Thomas Morley <thomasmorley65@gmail.com> | 2016-02-16 00:33:47 +0100 |
commit | a9fa9784c0b21fe7de2738befc0a3bcc5f89ee4f (patch) | |
tree | ac27020c367761adc339a90d9cb394f72c721374 /scm | |
parent | 0ab926218d76fa487f6935fd846796c902261e94 (diff) |
Issue 4768 Support additional bass strings in TabStaff
- new context-property: additionalBassStrings
- new regtest
- new entries in NR, Changes
Pitches on those additional bass strings will be printed as:
a, /a, //a, ///a, 4, 5 ...
as common for baroque lute, depending on settings for fretLabel and
additionalBassStrings.
Diffstat (limited to 'scm')
-rw-r--r-- | scm/define-context-properties.scm | 3 | ||||
-rw-r--r-- | scm/translation-functions.scm | 53 |
2 files changed, 43 insertions, 13 deletions
diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 3c9e159eb5..3ee68e5e6a 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -48,6 +48,9 @@ on the same note in different octaves may be horizontally staggered if in different voices.") (aDueText ,markup? "Text to print at a unisono passage.") + (additionalBassStrings ,list? "The additional tablature bass-strings, which +will not get a seprate line in TabStaff. It is a list of the pitches of each +string (starting with the lowest numbered one).") (additionalPitchPrefix ,string? "Text with which to prefix additional pitches within a chord name.") (alignAboveContext ,string? "Where to insert newly created context in diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index f9f532b0d0..22f8648c31 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -515,10 +515,18 @@ chords. Returns a placement-list." (cons tuning (map (lambda (x) (shift-octave x -1)) pitches)))))))) + ;; TODO: Does it make sense to have additional bass strings in a fret-diagram? + (if (and (not (null? rest)) + (not (null? (ly:context-property context 'additionalBassStrings)))) + (ly:warning "additional bass strings are not supported by FretBoards")) + ;; body of determine-frets (let* ((predefined-fret-table (ly:context-property context 'predefinedDiagramTable)) - (tunings (ly:context-property context 'stringTunings)) + (tunings + (append + (ly:context-property context 'stringTunings) + (ly:context-property context 'additionalBassStrings '()))) (string-count (length tunings)) (grob (if (null? rest) '() (car rest))) (pitches (map (lambda (x) (ly:event-property x 'pitch)) notes)) @@ -576,18 +584,33 @@ chords. Returns a placement-list." ;; The fret letter is taken from 'fretLabels if present (define-public (fret-letter-tablature-format context string-number fret-number) - (let ((labels (ly:context-property context 'fretLabels))) - (make-translate-scaled-markup '(0 . -0.5) - (cond - ((= 0 (length labels)) - (string (integer->char (+ fret-number (char->integer #\a))))) - ((and (<= 0 fret-number) (< fret-number (length labels))) - (list-ref labels fret-number)) - (else - (ly:warning (_ "No label for fret ~a (on string ~a); + (let* ((labels (ly:context-property context 'fretLabels)) + (string-tunings (ly:context-property context 'stringTunings)) + (string-count (length string-tunings)) + (letter + (cond + ((= 0 (length labels)) + (string (integer->char (+ fret-number (char->integer #\a))))) + ((and (<= 0 fret-number) (< fret-number (length labels))) + (list-ref labels fret-number)) + (else + (ly:warning + (_ "No label for fret ~a (on string ~a); only ~a fret labels provided") - fret-number string-number (length labels)) - "."))))) + fret-number string-number (length labels)) + "."))) + (add-bass-string-nr ;; starting at zero + (- string-number string-count 1))) + (make-translate-scaled-markup '(0 . -0.5) + ;; For additional bass strings, we add zero up to three "/"-signs before + ;; the letter, even more bass strings will get numbers, starting with "4". + ;; In the rare case such a string isn't played open, we put out, eg."4b" + (make-concat-markup + (if (> string-number (+ string-count 4)) + (list (number->string add-bass-string-nr) + (if (zero? fret-number) "" letter)) + (list (make-string (max 0 add-bass-string-nr) #\/) + letter)))))) ;; Display the fret number as a number (define-public (fret-number-tablature-format @@ -635,8 +658,12 @@ only ~a fret labels provided") (define-public (tablature-position-on-lines context string-number) (let* ((string-tunings (ly:context-property context 'stringTunings)) (string-count (length string-tunings)) + (string-nr + (if (> string-number (length string-tunings)) + (1+ (length string-tunings)) + string-number)) (string-one-topmost (ly:context-property context 'stringOneTopmost)) - (staff-line (- (* 2 string-number) string-count 1))) + (staff-line (- (* 2 string-nr) string-count 1))) (if string-one-topmost (- staff-line) staff-line))) |