From: Marc Hohl Date: Mon, 12 Mar 2012 07:24:12 +0000 (+0100) Subject: Issue 2348: Handling of open strings in tablature X-Git-Tag: release/2.15.34-1~21 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=e31a76e94f59d00968ddfe95a92138b5df799a8e;p=lilypond.git Issue 2348: Handling of open strings in tablature This patch creates a switch called restrainOpenStrings. When set to #f (default), LilyPond considers using open strings even if the normal fingering calculation would consider them "out of reach". Setting restrainOpenStrings to #t makes open strings non-special for the fret calculation routine. --- diff --git a/input/regression/tablature-open-string-handling.ly b/input/regression/tablature-open-string-handling.ly new file mode 100644 index 0000000000..721c0b22fc --- /dev/null +++ b/input/regression/tablature-open-string-handling.ly @@ -0,0 +1,18 @@ +\version "2.15.33" + +\header { + + texidoc = " + Open strings are part of a chord in tablature, even when @code{minimumFret} is set. + This can be changed via @code{restrainOpenStrings}." + +} + +\score { + \new TabStaff { + \set TabStaff.minimumFret = #3 + < g, d >1 + \set TabStaff.restrainOpenStrings = ##t + < g, d >1 + } +} diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index ad4aefa58f..c80209c373 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -46,6 +46,7 @@ predefinedDiagramTable = #default-fret-table handleNegativeFrets = #'recalculate + restrainOpenStrings = ##f } \context { @@ -892,6 +893,8 @@ contexts and handles the line spacing, the tablature clef etc. properly." clefPosition = #0 %% Change string if note results in negative fret number handleNegativeFrets = #'recalculate + %% Allow open strings even if minimumFret is set + restrainOpenStrings = ##f } \context { diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index e0da636c51..ff29b144c9 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -441,6 +441,8 @@ is set.") (restCompletionBusy ,boolean? "Signal whether a completion-rest is active.") (restNumberThreshold ,number? "If a multimeasure rest has more measures than this, a number is printed.") + (restrainOpenStrings ,boolean? "Exclude open strings from the +automatic fret calculator.") (searchForVoice ,boolean? "Signal whether a search should be made of all contexts in the context hierarchy for a voice to provide rhythms diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm index cc94b67acf..a535497962 100644 --- a/scm/translation-functions.scm +++ b/scm/translation-functions.scm @@ -276,6 +276,10 @@ dot placement entries." along with @var{minimum-fret}, @var{maximum-stretch}, and @var{tuning}. Returns a list of @code{(string fret finger) lists." + + (define restrain-open-strings (ly:context-property context + 'restrainOpenStrings + #f)) (define specified-frets '()) (define free-strings (iota (length tuning) 1)) @@ -326,7 +330,8 @@ if no string-number is present." #t (map (lambda (specced-fret) (or (eq? 0 specced-fret) - (eq? 0 fret) + (and (not restrain-open-strings) + (eq? 0 fret)) (>= maximum-stretch (abs (- fret specced-fret))))) specified-frets)))) @@ -334,7 +339,9 @@ if no string-number is present." "Can @var{pitch} be played on @var{string}, given already placed notes?" (let* ((fret (calc-fret pitch string tuning))) - (and (or (eq? fret 0) (>= fret minimum-fret)) + (and (or (and (not restrain-open-strings) + (eq? fret 0)) + (>= fret minimum-fret)) (close-enough fret)))) (define (open-string string pitch)