Am 14.02.2012 21:31, schrieb David Kastrup:
Marc Hohl<[email protected]> writes:
[...]
Symbols 'allow and 'forbid are not a typical interface. You would
rather use a boolean here.
Yes, you are right, I changed it accordingly.
Um, does
allowOpenStrings = ##t
sound better than
handleOpenStrings = ##t
Sure. Capo/bottleneck do not play into this?
No.
I don't think we have any
options with a default of ##t though, so it might make more sense to
have ignoreOpenStrings (better suggestions?).
I like it! New patch attached.
Regards,
Marc
>From d13710e3f8d0d303030ffc6eb655bb8498cbd574 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 | 2 ++
scm/translation-functions.scm | 11 +++++++++--
4 files changed, 32 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..8808615
--- /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.ignoreOpenStrings = ##t
+ < g, d >1
+ }
+}
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 6335ab6..56ec872 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -46,6 +46,7 @@
predefinedDiagramTable = #default-fret-table
handleNegativeFrets = #'recalculate
+ ignoreOpenStrings = ##f
}
\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
+ ignoreOpenStrings = ##f
}
\context {
diff --git a/scm/define-context-properties.scm
b/scm/define-context-properties.scm
index 4307985..cd117e6 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -295,6 +295,8 @@ string selector for tablature notation.")
(ignoreFiguredBassRest ,boolean? "Don't swallow rest events.")
(ignoreMelismata ,boolean? "Ignore melismata for this
@rinternals{Lyrics} line.")
+ (ignoreOpenStrings ,boolean? "Ignore open strings within the
+automatic fret calculator.")
(implicitBassFigures ,list? "A list of bass figures that are not
printed as numbers, but only as extender lines.")
(implicitTimeSignatureVisibility ,vector? "break visibility for
diff --git a/scm/translation-functions.scm b/scm/translation-functions.scm
index d373da0..efb6608 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 ignore-open-strings (ly:context-property context
+ 'ignoreOpenStrings
+ #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 ignore-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 ignore-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