- if (!key_item_p_)
- {
- key_item_p_ = new Item (get_property ("Accidentals"));
-
- SCM c0 = get_property ("centralCPosition");
- if (gh_number_p (c0))
- Staff_symbol_referencer::set_position (key_item_p_, gh_scm2int (c0));
-
- announce_grob (key_item_p_, SCM_EOL);
- }
-
-
- Local_key_item::add_pitch (key_item_p_, *unsmob_pitch (note_l->get_mus_property ("pitch")),
- cautionary,
- num == 2 && extra_natural_b,
- tie_break_reminder);
- Side_position_interface::add_support (key_item_p_, support_l);
-
- support_l->set_grob_property ("accidentals-grob", key_item_p_->self_scm ());
- }
-
-
- /*
- 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?
- */
-
- Pitch *pitch = unsmob_pitch (note_l->get_mus_property ("pitch"));
- int n = pitch->notename_i_;
- int o = pitch->octave_i_;
- int a = pitch->alteration_i_;
- SCM on_s = gh_cons (gh_int2scm (o), gh_int2scm (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.
-
-
- */
- Translator_group * trans_ = origin_l_arr_[i];
- while (trans_)
- {
- SCM localsig = trans_->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 (gh_int2scm (a), barnum));
- }
- trans_->set_property ("localKeySignature", localsig);
- trans_ = trans_->daddy_trans_l_;
+ /*
+ We construct the accidentals at the originating Voice
+ level, so that we get the property settings for
+ Accidental from the respective Voice.
+ */
+ Grob *a
+ = make_item_from_properties (accidentals_[i].origin_trans_,
+ ly_symbol2scm ("Accidental"),
+ note->self_scm (),
+ "Accidental");
+ a->set_parent (support, Y_AXIS);
+
+ if (!accidental_placement_)
+ accidental_placement_ = make_item ("AccidentalPlacement",
+ a->self_scm ());
+ Accidental_placement::add_accidental (accidental_placement_, a);
+ SCM accs = scm_cons (scm_int2num (pitch->get_alteration ()),
+ SCM_EOL);
+ if (num == 2 && extra_natural_b)
+ accs = scm_cons (scm_int2num (0), accs);
+
+ /* TODO: add cautionary option in accidental. */
+
+ if (cautionary)
+ a->set_property ("cautionary", SCM_BOOL_T);
+
+ support->set_property ("accidental-grob", a->self_scm ());
+
+ a->set_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]);