- SCM accidentals = get_property ("autoAccidentals");
- SCM cautionaries = get_property ("autoCautionaries");
- SCM barnum = get_bar_num ();
-
- 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_;
- Context * origin = accidentals_[i].origin_;
-
- Pitch * pitch = unsmob_pitch (note->get_property ("pitch"));
- if (!pitch)
- continue;
-
- bool different = false;
- bool different_caut = false;
-
- int num = number_accidentals (&different,
- pitch, origin,
- accidentals, barnum);
- int num_caut = number_accidentals (&different_caut,
- pitch, origin,
- cautionaries, barnum);
-
- bool cautionary = to_boolean (note->get_property ("cautionary"));
-
- if (num_caut > num)
- {
- num = num_caut;
- different = different_caut;
- cautionary = true;
- }
-
- if (num == 0 && to_boolean (note->get_property ("force-accidental")))
- num = 1;
-
-
- /*
- Can not look for ties: it's not guaranteed that they reach
- us before the notes
- */
-
- if (num)
- {
- /*
- 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 (origin,
- ly_symbol2scm ("Accidental"));
- a->set_parent (support, Y_AXIS);
-
- if (!accidental_placement_)
- {
- accidental_placement_ = make_item ("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_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]);
- }
- }