Hi everybody,

Attached is the gist of a patch detailing a fix for Issue 524. Could
someone check it for me or suggest any improvements so I can push with
an updated regtest?

There are two things which I'm concerned about:

- it copies some code from accidental-engraver.cc to get the current
bar number, so I was wondering whether there might be a more efficient
way for both engravers to get this information (perhaps a Scheme proc
call?)

- make_trill should read force-accidental, so that forced accidentals
can be set using "!" instead of the workaround \once \set
localKeySignature = #'(). Whilst it's trivial to test for
force-accidental in the engraver, I'm stumped when it comes to
transferring the property as part of the trill-span-events in the
pitchedTrill music function.

As an aside, while working on this fix, I noticed that the description
for localKeySignature is ambiguous: it says that the property is reset
at a bar line. As far as I can tell, it only gets reset when there's a
new key signature.

Regards,
Neil
From a3b0a92f5430ca6af832016bb33497ff90495142 Mon Sep 17 00:00:00 2001
From: Neil Puttock <[EMAIL PROTECTED]>
Date: Wed, 11 Jun 2008 01:38:15 +0100
Subject: [PATCH] Fix 524 pitched trill losing accidental

---
 lily/pitched-trill-engraver.cc |   26 ++++++++++++++++++++++++++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc
index 3104b48..9fe02a9 100644
--- a/lily/pitched-trill-engraver.cc
+++ b/lily/pitched-trill-engraver.cc
@@ -80,7 +80,33 @@ Pitched_trill_engraver::make_trill (Stream_event *ev)
   SCM key = scm_cons (scm_from_int (p->get_octave ()),
 		      scm_from_int (p->get_notename ()));
 
+  /*
+    localKeySignature keeps track of notes from
+    previous measures unless reset by a new key signature or
+    overridden by the same pitch (ignoring the alteration)
+    in the current measure.  If the handle produces a match,
+    we must also consider the measure number and alteration
+    in deciding whether to print an accidental.
+  */
+  SCM barnum = get_property ("internalBarNumber");
+  SCM smp = get_property ("measurePosition");
+
+  int bn = robust_scm2int (barnum, 0);
+  Moment mp = robust_scm2moment (smp, Moment (0));
+  if (mp.main_part_ < Rational (0))
+    bn--;
+ 
   SCM handle = scm_assoc (key, keysig);
+  if (handle != SCM_BOOL_F)
+    {
+      bool same_bar = (bn == robust_scm2int (scm_cddr (handle), 0));
+      bool same_alt
+	= (p->get_alteration () == robust_scm2rational (scm_cadr (handle), 0));
+
+      if (!same_bar || (same_bar && !same_alt))
+	handle = SCM_BOOL_F;
+    }
+
   bool print_acc
     = (handle == SCM_BOOL_F) || p->get_alteration () == Rational (0);
 
-- 
1.5.4.3

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to