]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 2348: Handling of open strings in tablature
authorMarc Hohl <marc@hohlart.de>
Mon, 12 Mar 2012 07:24:12 +0000 (08:24 +0100)
committerDavid Kastrup <dak@gnu.org>
Mon, 12 Mar 2012 07:33:06 +0000 (08:33 +0100)
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.

input/regression/tablature-open-string-handling.ly [new file with mode: 0644]
ly/engraver-init.ly
scm/define-context-properties.scm
scm/translation-functions.scm

diff --git a/input/regression/tablature-open-string-handling.ly b/input/regression/tablature-open-string-handling.ly
new file mode 100644 (file)
index 0000000..721c0b2
--- /dev/null
@@ -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
+  }
+}
index ad4aefa58fec08b6d87974e7ed7fa01becab0211..c80209c373fe49186b33d606d5dc6588801ad23a 100644 (file)
@@ -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 {
index e0da636c5172e3a8905ae202aed8dfbefc5395c3..ff29b144c966e91d8179f310664b74f66f9904a8 100644 (file)
@@ -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
index cc94b67acfbeb2aae9c3364d577e937b4d89d5c5..a535497962c07b9ae8ca5d79d1faf3901d1b7e10 100644 (file)
@@ -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)