- //SCM localsig = get_property ("localKeySignature");
- SCM accidentals = get_property ("autoAccidentals");
- SCM cautionaries = get_property ("autoCautionaries");
- SCM barnum = get_property ("currentBarNumber");
- SCM smp = get_property("measurePosition");
- Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
- if(mp.main_part_<Rational(0) && gh_number_p(barnum)) barnum = scm_int2num(gh_scm2int(barnum)-1);
- bool extra_natural_b = get_property ("extraNatural") == SCM_BOOL_T;
- for (int i = 0; i < accidentals_.size (); i++)
- {
- if (accidentals_[i].done_ )
- continue;
- accidentals_[i].done_ = true;
- Grob * support = accidentals_[i].head_;
- Music * note = accidentals_[i].melodic_;
- Translator_group * origin = accidentals_[i].origin_;
-
- Pitch * pitch = unsmob_pitch (note->get_mus_property ("pitch"));
- int num = number_accidentals (note, pitch, origin, accidentals, barnum);
- int num_caut = number_accidentals (note, pitch, origin, cautionaries, barnum);
- bool cautionary = to_boolean (note->get_mus_property ("cautionary"));
-
- if (abs (num_caut) > abs (num))
- {
- num = num_caut;
- cautionary = true;
- }
-
- if(num==0 && to_boolean (note->get_mus_property ("force-accidental")))
- num=1;
-
- bool different = num < 0;
- num = abs (num);
-
- /* see if there's a tie that "changes" the accidental */
- /* works because if there's a tie, the note to the left
- is of the same pitch as the actual note */
-
- Grob *tie_break_reminder = 0;
- bool tie_changes = false;
- for (int j = 0; j < ties_.size (); j++)
- if (support == Tie::head (ties_[j], RIGHT))
- {
- tie_changes = different;
-
- /* Enable accidentals for broken tie
-
- We only want an accidental on a broken tie,
- if the tie changes the accidental.
-
- Maybe check property noTieBreakForceAccidental? */
- if (different)
- tie_break_reminder = ties_[j];
- break;
- }
-
- if (num)
- {
- Grob * a = new Item (get_property ("Accidental"));
- a->set_parent (support, Y_AXIS);
-
- if (!accidental_placement_)
- {
- accidental_placement_ = new Item (get_property ("AccidentalPlacement"));
- announce_grob (accidental_placement_, a->self_scm());
- }
-
- Accidental_placement::add_accidental (accidental_placement_, a);
- announce_grob (a, SCM_EOL);
-
-
- SCM accs = gh_cons (scm_int2num (pitch->get_alteration ()), SCM_EOL);
- if (num == 2 && extra_natural_b)
- accs = gh_cons (scm_int2num (0), accs);
-
- /* TODO:
-
- add cautionary option in accidental.
- */
-
- if (cautionary)
- {
- a->set_grob_property ("cautionary", SCM_BOOL_T);
- }
-
- if (tie_break_reminder)
- {
- // TODO.
- a->set_grob_property ("tie", tie_break_reminder->self_scm());
- }
-
-
- support->set_grob_property ("accidental-grob", a->self_scm ());
-
- a->set_grob_property ("accidentals", accs);
- accidentals_[i].accidental_ = a;
- /*
- We add the accidentals to the support of the arpeggio, so it is put left of the
- accidentals.
-
- */
- for (int i = 0; i < left_objects_.size (); i++)
- Side_position_interface::add_support (left_objects_[i], a);
- for (int i = 0; i < right_objects_.size (); i++)
- Side_position_interface::add_support (a, right_objects_[i]);
- }
-
-
- /*
- We should not record the accidental if it is the first
- note and it is tied from the previous measure.
-
- Checking whether it is tied also works mostly, but will it
- always do the correct thing?
- */
-
-
- int n = pitch->get_notename ();
- int o = pitch->get_octave ();
- int a = pitch->get_alteration ();
- SCM on_s = gh_cons (scm_int2num (o), scm_int2num (n));
-
- /*
- TODO: Speed this up!
-
- Perhaps only check translators mentioned in the auto-accidentals?
- -rz
-
- TODO: profile this.
-
- I'd be surprised if the impact of this would be
- measurable. Anyway, it seems localsig doesn't change
- every time-step, but a set_property() is done every
- time. We could save on that, probably.
-
- --hwn.
-
-
- */
-
- while (origin)
- {
- SCM localsig = origin->get_property ("localKeySignature");
- if (tie_changes)
- {
- /*
- Remember an alteration that is different both from
- that of the tied note and of the key signature.
- */
- localsig = ly_assoc_front_x
- (localsig, on_s, gh_cons (SCM_BOOL_T, barnum));
- }
- else
- {
- /*
- not really really correct if there are more than one
- noteheads with the same notename.
- */
- localsig = ly_assoc_front_x
- (localsig, on_s, gh_cons (scm_int2num (a), barnum));
- }
- origin->set_property ("localKeySignature", localsig);
- origin = origin->daddy_trans_;
- }
- }
+ if (to_boolean (get_property ("extraNatural")))
+ a->set_property ("restore-first", SCM_BOOL_T);
+ }
+
+ entry->accidental_ = a;
+}
+
+Grob *
+Accidental_engraver::make_standard_accidental (Stream_event * /* note */,
+ Grob *note_head,
+ Engraver *trans,
+ bool cautionary)
+{
+ /*
+ We construct the accidentals at the originating Voice
+ level, so that we get the property settings for
+ Accidental from the respective Voice.
+ */
+ Grob *a = 0;
+ if (cautionary)
+ a = trans->make_item ("AccidentalCautionary", note_head->self_scm ());
+ else
+ a = trans->make_item ("Accidental", note_head->self_scm ());
+
+ /*
+ We add the accidentals to the support of the arpeggio,
+ so it is put left of the accidentals.
+ */
+ for (vsize i = 0; i < left_objects_.size (); i++)
+ {
+ if (ly_is_equal (left_objects_[i]->get_property ("side-axis"), scm_from_int (X_AXIS)))
+ Side_position_interface::add_support (left_objects_[i], a);