From a9fa9784c0b21fe7de2738befc0a3bcc5f89ee4f Mon Sep 17 00:00:00 2001 From: Thomas Morley Date: Tue, 9 Feb 2016 10:21:00 +0100 Subject: [PATCH] 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. --- Documentation/changes.tely | 22 ++++++++ Documentation/notation/fretted-strings.itely | 54 +++++++++++++++++++ .../tablature-additional-bass-strings.ly | 38 +++++++++++++ scm/define-context-properties.scm | 3 ++ scm/translation-functions.scm | 53 +++++++++++++----- 5 files changed, 157 insertions(+), 13 deletions(-) create mode 100644 input/regression/tablature-additional-bass-strings.ly diff --git a/Documentation/changes.tely b/Documentation/changes.tely index ce41e0aefa..93e1976ef9 100644 --- a/Documentation/changes.tely +++ b/Documentation/changes.tely @@ -61,6 +61,28 @@ which scares away people. @end ignore +@item +Additional bass strings (for lute tablature) are supported. +@lilypond[quote,verbatim] +m = { f'4 d' a f d a, g, fis, e, d, c, \bar "|." } + +\score { + \new TabStaff \m + \layout { + \context { + \Score + tablatureFormat = #fret-letter-tablature-format + } + \context { + \TabStaff + stringTunings = \stringTuning + additionalBassStrings = \stringTuning + fretLabels = #'("a" "b" "r" "d" "e" "f" "g" "h" "i" "k") + } + } +} +@end lilypond + @item The markup-list-command @code{\table} is now available. Each column may be aligned differently. diff --git a/Documentation/notation/fretted-strings.itely b/Documentation/notation/fretted-strings.itely index eb111e3ce8..c7c18bacb6 100644 --- a/Documentation/notation/fretted-strings.itely +++ b/Documentation/notation/fretted-strings.itely @@ -27,6 +27,7 @@ to fretted string instruments. * Common notation for fretted strings:: * Guitar:: * Banjo:: +* Lute:: @end menu @node Common notation for fretted strings @@ -2010,3 +2011,56 @@ Installed Files: Snippets: @rlsr{Fretted strings}. + + +@node Lute +@subsection Lute + +@menu +* Lute tablatures:: +@end menu + +@node Lute tablatures +@unnumberedsubsubsec Lute tablatures + +@cindex lute tablatures +@cindex tablature, lute + +LilyPond supports tablature for lute. + +To get additional bass strings use @code{additionalBassStrings}, where the +pitches of those strings are set. They will be printed below lowest line as: +a, /a, //a, ///a, 4, 5 etc. + +@code{fret-letter-tablature-format} for @code{tablatureFormat} should be used, +probably @code{fretLabels} for further customizing. + +@lilypond[quote,ragged-right,verbatim] +m = { f'4 d' a f d a, g, fis, e, d, c, \bar "|." } + +\score { + << + \new Staff { \clef bass \cadenzaOn \m } + \new TabStaff \m + >> + \layout { + \context { + \Score + tablatureFormat = #fret-letter-tablature-format + } + \context { + \TabStaff + stringTunings = \stringTuning + additionalBassStrings = \stringTuning + fretLabels = #'("a" "b" "r" "d" "e" "f" "g" "h" "i" "k") + } + } +} +@end lilypond + +@cindex lute tunings +@cindex tunings, lute + +@knownissues +Using @code{FretBoards} with @code{additionalBassStrings} is not supported and +will yield unsatisfying results. diff --git a/input/regression/tablature-additional-bass-strings.ly b/input/regression/tablature-additional-bass-strings.ly new file mode 100644 index 0000000000..a094f9af41 --- /dev/null +++ b/input/regression/tablature-additional-bass-strings.ly @@ -0,0 +1,38 @@ +\version "2.19.37" + +\header +{ + texidoc = "Additional bass strings (for baroque lute, etc.) are supported in + TabStaff. They are printed below lowest line as: a, /a, //a, ///a, 4, 5 etc. + @code{additionalBassStrings} needs to be set accordingly." +} + +m = { e' b g d a, e, d, c, b,,\9 a,, g,, } +mus = { \m \bar "||" \transpose c cis \m \bar "|." } + +\score { + << + \new Staff { \clef bass \cadenzaOn \mus } + %% FretBoards with `additionalBassStrings' return weird output + %% A warning is thrown if uncommented + %\new FretBoards \mus + \new TabStaff { \mus } + >> + \layout { + \context { + \Score + tablatureFormat = #fret-letter-tablature-format + } + \context { + \FretBoards + stringTunings = \stringTuning + additionalBassStrings = \stringTuning + } + \context { + \TabStaff + stringTunings = \stringTuning + additionalBassStrings = \stringTuning + fretLabels = #'("a" "b" "r" "d" "e" "f" "g" "h" "i" "k") + } + } +} 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))) -- 2.39.2