2008/6/30 Han-Wen Nienhuys <[EMAIL PROTECTED]>: > you need to issue the bt command, which will print the call interface. > Something is doing a > > NULL->set_property(..) > > which is obviously wrong
Cheers for the hint; I did a backtrace as suggested, and it turned out to be Accidental_engraver::process_acknowledged () attempting to set the `forced' property. Attached is a revised patch with regression tests. Is it OK to push? Regards, Neil
From ef93420c490624c61e604e360cd0684472f73404 Mon Sep 17 00:00:00 2001 From: Neil Puttock <[EMAIL PROTECTED]> Date: Fri, 4 Jul 2008 23:32:09 +0100 Subject: [PATCH] Fix 524 pitched trill losing accidental. - check localKeySignature more thoroughly when deciding whether to print an accidental. This includes checks for alteration and measure number. - print accidental if forced. - move get_bar_number () from accidental-engraver.cc to context.cc so that pitched-trill-engraver.cc can also use it. - check secondary note events for `forced-accidental' property and pass to engraver via trill-span-event if set. - prevent accidental-engraver.cc setting `forced' property on non-existent accidentals. - add regression tests for forced-accidental and consecutive pitched trills. --- .../trill-spanner-pitched-consecutive.ly | 28 +++++++++++++++ input/regression/trill-spanner-pitched-forced.ly | 16 +++++++++ lily/accidental-engraver.cc | 36 ++++++-------------- lily/context.cc | 14 ++++++++ lily/include/context.hh | 1 + lily/pitched-trill-engraver.cc | 15 ++++++++- ly/music-functions-init.ly | 30 +++++++++------- 7 files changed, 101 insertions(+), 39 deletions(-) create mode 100644 input/regression/trill-spanner-pitched-consecutive.ly create mode 100644 input/regression/trill-spanner-pitched-forced.ly diff --git a/input/regression/trill-spanner-pitched-consecutive.ly b/input/regression/trill-spanner-pitched-consecutive.ly new file mode 100644 index 0000000..33fcf81 --- /dev/null +++ b/input/regression/trill-spanner-pitched-consecutive.ly @@ -0,0 +1,28 @@ +\version "2.11.51" + +\header { + texidoc = "Pitched trills on consecutive notes with the same +name and octave should not lose accidentals; in the following +example, accidentals should be visible for all trill-pitches. +" +} + +\relative c' { + \pitchedTrill + f4\startTrillSpan ges f\stopTrillSpan + + \pitchedTrill + f4\startTrillSpan g gis\stopTrillSpan ~ + + \pitchedTrill + gis4\startTrillSpan ges f\stopTrillSpan + + \pitchedTrill + g4\startTrillSpan gis f\stopTrillSpan + + \pitchedTrill + f4\startTrillSpan gisis f\stopTrillSpan + + \pitchedTrill + f4\startTrillSpan geses f\stopTrillSpan +} diff --git a/input/regression/trill-spanner-pitched-forced.ly b/input/regression/trill-spanner-pitched-forced.ly new file mode 100644 index 0000000..e888bbc --- /dev/null +++ b/input/regression/trill-spanner-pitched-forced.ly @@ -0,0 +1,16 @@ +\version "2.11.51" + +\header { + texidoc = "Pitched trill accidentals can be forced." +} + +\relative c' { + \pitchedTrill + c4\startTrillSpan es f\stopTrillSpan + \pitchedTrill + c4\startTrillSpan es f\stopTrillSpan + \pitchedTrill + c4\startTrillSpan es f\stopTrillSpan + \pitchedTrill + c4\startTrillSpan-"forced" es! f\stopTrillSpan +} diff --git a/lily/accidental-engraver.cc b/lily/accidental-engraver.cc index ce9a670..211cbe4 100644 --- a/lily/accidental-engraver.cc +++ b/lily/accidental-engraver.cc @@ -51,7 +51,6 @@ Accidental_entry::Accidental_entry () class Accidental_engraver : public Engraver { - int get_bar_number (); void update_local_key_signature (SCM new_signature); void create_accidental (Accidental_entry *entry, bool, bool); Grob *make_standard_accidental (Stream_event *note, Grob *note_head, Engraver *trans, bool); @@ -297,21 +296,6 @@ check_pitch_against_rules (Pitch const &pitch, Context *origin, return result; } -int -Accidental_engraver::get_bar_number () -{ - 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--; - - return bn; -} - void Accidental_engraver::process_acknowledged () { @@ -319,7 +303,7 @@ Accidental_engraver::process_acknowledged () { SCM accidental_rules = get_property ("autoAccidentals"); SCM cautionary_rules = get_property ("autoCautionaries"); - int barnum = get_bar_number (); + int barnum = measure_number (context()); for (vsize i = 0; i < accidentals_.size (); i++) { @@ -354,12 +338,14 @@ Accidental_engraver::process_acknowledged () /* Cannot look for ties: it's not guaranteed that they reach us before the notes. */ - if (acc.need_acc - && !note->in_event_class ("trill-span-event")) - create_accidental (&accidentals_[i], acc.need_restore, cautionary); + if (!note->in_event_class ("trill-span-event")) + { + if (acc.need_acc) + create_accidental (&accidentals_[i], acc.need_restore, cautionary); - if (forced || cautionary) - accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); + if (forced || cautionary) + accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T); + } } } } @@ -474,12 +460,12 @@ Accidental_engraver::stop_translation_timestep () } for (vsize i = accidentals_.size (); i--;) - { - int barnum = get_bar_number (); - + { Stream_event *note = accidentals_[i].melodic_; Context *origin = accidentals_[i].origin_; + int barnum = measure_number (origin); + Pitch *pitch = unsmob_pitch (note->get_property ("pitch")); if (!pitch) continue; diff --git a/lily/context.cc b/lily/context.cc index ba3809e..2f23024 100644 --- a/lily/context.cc +++ b/lily/context.cc @@ -709,6 +709,20 @@ measure_position (Context const *context) return m; } +int +measure_number (Context const *context) +{ + SCM barnum = context->get_property ("internalBarNumber"); + SCM smp = context->get_property ("measurePosition"); + + int bn = robust_scm2int (barnum, 0); + Moment mp = robust_scm2moment (smp, Moment (0)); + if (mp.main_part_ < Rational (0)) + bn--; + + return bn; +} + void set_context_property_on_children (Context *trans, SCM sym, SCM val) diff --git a/lily/include/context.hh b/lily/include/context.hh index 33e8f8c..f0cd67c 100644 --- a/lily/include/context.hh +++ b/lily/include/context.hh @@ -140,6 +140,7 @@ DECLARE_UNSMOB (Context, context); Moment measure_position (Context const *context); Rational measure_length (Context const *context); +int measure_number (Context const *context); void set_context_property_on_children (Context *trans, SCM sym, SCM val); /* Shorthand for creating and broadcasting stream events. */ diff --git a/lily/pitched-trill-engraver.cc b/lily/pitched-trill-engraver.cc index 3104b48..39cb899 100644 --- a/lily/pitched-trill-engraver.cc +++ b/lily/pitched-trill-engraver.cc @@ -80,9 +80,22 @@ Pitched_trill_engraver::make_trill (Stream_event *ev) SCM key = scm_cons (scm_from_int (p->get_octave ()), scm_from_int (p->get_notename ())); + int bn = measure_number (context()); + 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); + = (handle == SCM_BOOL_F) || p->get_alteration () == Rational (0) + || (ev->get_property ("force-accidental") == SCM_BOOL_T); if (trill_head_) { diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 2e2a154..f978e36 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -471,20 +471,24 @@ pitchedTrill = (ly:music-property ev-chord 'elements)))) (sec-note-events (get-notes secondary-note)) (trill-events (filter (lambda (m) (music-has-type m 'trill-span-event)) - (ly:music-property main-note 'elements))) - - (trill-pitch - (if (pair? sec-note-events) - (ly:music-property (car sec-note-events) 'pitch) - ))) - - (if (ly:pitch? trill-pitch) - (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch)) - trill-events) - (begin - (ly:warning (_ "Second argument of \\pitchedTrill should be single note: ")) - (display sec-note-events))) + (ly:music-property main-note 'elements)))) + (if (pair? sec-note-events) + (begin + (let* + ((trill-pitch (ly:music-property (car sec-note-events) 'pitch)) + (forced (ly:music-property (car sec-note-events ) 'force-accidental))) + + (if (ly:pitch? trill-pitch) + (for-each (lambda (m) (ly:music-set-property! m 'pitch trill-pitch)) + trill-events) + (begin + (ly:warning (_ "Second argument of \\pitchedTrill should be single note: ")) + (display sec-note-events))) + + (if (eq? forced #t) + (for-each (lambda (m) (ly:music-set-property! m 'force-accidental forced)) + trill-events))))) main-note)) -- 1.5.4.3
<<attachment: test.broken.png>>
<<attachment: test.fixed.png>>
_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel