From a3b0a92f5430ca6af832016bb33497ff90495142 Mon Sep 17 00:00:00 2001 From: Neil Puttock 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