- SCM localsig = get_property ("localKeySignature");
- SCM accidentals_l = get_property ("autoAccidentals");
- SCM cautionaries_l = get_property ("autoCautionaries");
- SCM barnum = get_property ("currentBarNumber");
-
- bool extra_natural_b = get_property ("extraNatural")==SCM_BOOL_T;
- for (int i=0; i < mel_l_arr_.size (); i++)
- {
- Grob * support_l = head_l_arr_[i];
- Note_req * note_l = mel_l_arr_[i];
-
- int num = number_accidentals(localsig,note_l,accidentals_l,barnum);
- int num_caut = number_accidentals(localsig,note_l,cautionaries_l,barnum);
- bool cautionary = to_boolean (note_l->get_mus_property ("cautionary"));
- if (abs(num_caut)>abs(num))
- {
- num=num_caut;
- cautionary=true;
- }
-
- 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 i=0; i < tie_l_arr_.size (); i++)
- if (support_l == Tie::head (tie_l_arr_[i], 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 = tie_l_arr_[i];
- break;
- }
-
- if (num)
- {
- if (!key_item_p_)
- {
- key_item_p_ = new Item (get_property ("Accidentals"));
- Local_key_item::set_interface (key_item_p_);
-
- Staff_symbol_referencer::set_interface (key_item_p_);
- 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 = gh_cons (gh_int2scm (o), gh_int2scm (n));
- 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, 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, gh_cons(gh_int2scm (a),barnum));
- }