2017-02-28 16:09 GMT+00:00 David Nalesnik <[email protected]>:
> Hi Andrew,
>
> On Mon, Feb 27, 2017 at 6:52 PM, Andrew Bernard
> <[email protected]> wrote:
>> Hi David,
>>
>> This is excellent and useful. Also works, of course, when using something
>> like \set Staff.ottavation = "8".
>>
>> Why not make this a snippet in LSR?
>>
>
> Sure, I will look it at some more, and submit.
>
> Ideally, I'd like to add something to the codebase.
>
> Best,
> David


Hi David,

I was working on a patch introducing ottavaText as a context-property.
Maybe we could coordinate or at least avoid doing work twice.

I'll attach what I've done so far.
It's not finished yet: I'd like to polish it and add entries in NR and
Changes, probably worth a regtest as well.

Cheers,
  Harm

P.S.
Did you notice
https://sourceforge.net/p/testlilyissues/issues/5064/#23bb
?
From dfa574353db72775a028f172da6f5c5009c5f69d Mon Sep 17 00:00:00 2001
From: Thomas Morley <[email protected]>
Date: Tue, 28 Feb 2017 18:48:27 +0000
Subject: [PATCH] Introduce context-property ottavaText

---
 ly/engraver-init.ly               |  7 +++++++
 scm/define-context-properties.scm |  2 ++
 scm/define-music-callbacks.scm    | 13 +++++++------
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index 693f9eb..41665df 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -768,6 +768,13 @@ automatically when an output definition (a @code{\\score} or
   topLevelAlignment = ##t
 
   timing = ##t
+
+  ottavaText =
+    #'((2 . "15ma")
+       (1 . "8va")
+       (0 . #f)
+       (-1 . "8vb")
+       (-2 . "15mb"))
 }
 
 
diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm
index 75f1807..dd362fe 100644
--- a/scm/define-context-properties.scm
+++ b/scm/define-context-properties.scm
@@ -494,6 +494,8 @@ any effect the note would have had on accidentals in other voices.")
 
      (ottavation ,markup? "If set, the text for an ottava spanner.
 Changing this creates a new text spanner.")
+     (ottavaText ,list? "An alist containing pairs of ottava-number and markup.
+Used to get the text for @code{OttavaBracket}.")
      (output ,ly:music-output? "The output produced by a score-level
 translator during music interpretation.")
 
diff --git a/scm/define-music-callbacks.scm b/scm/define-music-callbacks.scm
index 5cc1db1..d8150cb 100644
--- a/scm/define-music-callbacks.scm
+++ b/scm/define-music-callbacks.scm
@@ -77,12 +77,13 @@ to be used by the sequential-iterator"
     (list (context-spec-music
            (make-apply-context
             (lambda (context)
-              (let ((offset (* -7 octavation))
-                    (string (assoc-get octavation '((2 . "15ma")
-                                                    (1 . "8va")
-                                                    (0 . #f)
-                                                    (-1 . "8vb")
-                                                    (-2 . "15mb")))))
+              (let* ((offset (* -7 octavation))
+                     (ottava-label-list
+                       (ly:context-property context 'ottavaText))
+                     (string
+                       (if (pair? ottava-label-list)
+                           (assoc-get octavation ottava-label-list)
+                           #f)))
                 (set! (ly:context-property context 'middleCOffset) offset)
                 (set! (ly:context-property context 'ottavation) string)
                 (ly:set-middle-C! context))))
-- 
2.1.4

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

Reply via email to