Am 14.02.2012 09:58, schrieb Marc Hohl:
Hello all,

while typesetting a piece for two guitars, I stumbled across
the influence of the commit mentioned above.

Before that,

something like

\set minimumFret = #2
dis'8 ( e' dis ) h fis2

worked smoothly out of the box, now I have to tell
lilypond explicitly which string to use when I want to
avoid open strings.

\set minimumFret = #2
dis'8 ( e\2 dis ) h\3 fis2 |

I dont want to make lilypond input even more complicated,
but what about a separate switch, something like

\tabOpenStringsOn \tabOpenStringsOff ?

These commands control whether open strings
are taken into account or not.

Perhaps I have some time to create a patch myself
within the next week or so.
The rehearsal this evening was canceled, so here you are.

Regards,

Marc

Regards,
Marc

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


>From 9bba10b24dfe716dd4ce7cb88d0c20945130e49f 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                  |    4 ++++
 scm/translation-functions.scm                      |   11 +++++++++--
 4 files changed, 34 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..459b89c
--- /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 = #'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
 }
 
 \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 = #'allow
 }
 
 \context {
diff --git a/scm/define-context-properties.scm 
b/scm/define-context-properties.scm
index 4307985..c1bf712 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -282,6 +282,10 @@ 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 ,symbol? "How the automatic fret calculator
+should handle open strings. Values include @code{'allow}, to use open
+strings even in situations where @code{minimumFret} is set, or @code{'forbid}
+for cases where open strings should not be taken into account.")
      (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..7b8a741 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 handle-open-strings (ly:context-property context
+                                                    'handleOpenStrings
+                                                    'allow))
     (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 (eq? handle-open-strings 'allow)
+                          (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 (eq? handle-open-strings 'allow)
+                      (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