Am 14.02.2012 21:01, schrieb David Kastrup:
Marc Hohl<[email protected]>  writes:

Am 14.02.2012 09:58, schrieb Marc Hohl:
+    \set TabStaff.handleOpenStrings = #'forbid
+<  g, d>1
+  }
+}
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 6335ab6..11181d3 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -46,6 +46,7 @@

    predefinedDiagramTable = #default-fret-table
    handleNegativeFrets = #'recalculate
+  handleOpenStrings = #'allow
Symbols 'allow and 'forbid are not a typical interface.  You would
rather use a boolean here.
Yes, you are right, I changed it accordingly.
Would it make sense to specify a _list_ minimumFretExceptions that is
not checked against minimumFret?

Or is the only exception ever of interest the fret 0?
Speaking as a guitarist, I think that only 0 makes sense.
When I specify minimumFret = #7, I normally stay in this
range. In some situations open strings make sense, but
this should be switchable - to include a complete list of
minimumFretExceptions would be overkill.

Thanks for your suggestions!

Marc

>From f5db7861963a247d19195eda09395174f85931ef Mon Sep 17 00:00:00 2001
From: Marc Hohl <[email protected]>
Date: Tue, 14 Feb 2012 20:43:10 +0100
Subject: [PATCH] Handling of open strings in tablature

This patch creates a switch called handleOpenStrings which is set
to 'allow by default which allows the fret calculation routine to use
open strings even when minimumFret is set to a value > 0.

Setting handleOpenStrings to 'forbid excludes open strings and
forces the fret calculation routine to find a fretted position
even for pitches equal to an open string.
---
 input/regression/tablature-open-string-handling.ly |   18 ++++++++++++++++++
 ly/engraver-init.ly                                |    3 +++
 scm/define-context-properties.scm                  |    3 +++
 scm/translation-functions.scm                      |   11 +++++++++--
 4 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 input/regression/tablature-open-string-handling.ly

diff --git a/input/regression/tablature-open-string-handling.ly 
b/input/regression/tablature-open-string-handling.ly
new file mode 100644
index 0000000..a5536e3
--- /dev/null
+++ b/input/regression/tablature-open-string-handling.ly
@@ -0,0 +1,18 @@
+\version "2.15.31"
+
+\header {
+
+  texidoc = "
+  Open strings are part of a chord in tablature, even when @code{minimumFret} 
is set.
+  This can be changed via @code{handleOpenStrings}."
+  
+}  
+
+\score {
+  \new TabStaff {
+    \set TabStaff.minimumFret = #3
+    < g, d >1 
+    \set TabStaff.handleOpenStrings = ##f
+    < g, d >1 
+  }
+}
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 6335ab6..e0844dd 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -46,6 +46,7 @@
 
   predefinedDiagramTable = #default-fret-table
   handleNegativeFrets = #'recalculate
+  handleOpenStrings = ##t
 }
 
 \context {
@@ -889,6 +890,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
+  handleOpenStrings = ##t
 }
 
 \context {
diff --git a/scm/define-context-properties.scm 
b/scm/define-context-properties.scm
index 4307985..0856a98 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -282,6 +282,9 @@ should handle calculated negative frets.  Values include 
@code{'ignore},
 to leave them out of the diagram completely, @code{'include}, to include
 them as calculated, and @code{'recalculate}, to ignore the specified
 string and find a string where they will fit with a positive fret number.")
+     (handleOpenStrings ,boolean? "How the automatic fret calculator
+should handle open strings. When set to true lilypond uses open
+strings even in situations where @code{minimumFret} is set.")
      (harmonicAccidentals ,boolean? "If set, harmonic notes in chords
 get accidentals.")
      (harmonicDots ,boolean? "If set, harmonic notes in dotted chords get
diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm
index d373da0..11d31fb 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 allow-open-strings (ly:context-property context
+                                                   'handleOpenStrings
+                                                   #t))
     (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 allow-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 allow-open-strings
+                      (eq? fret 0))
+             (>= fret minimum-fret))
             (close-enough fret))))
 
     (define (open-string string pitch)
-- 
1.7.4.1

_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to