- return (alteration_def == SCM_BOOL_T)
- || (scm_is_pair (alteration_def) && scm_car (alteration_def) == SCM_BOOL_T);
-}
-
-static int
-number_accidentals_from_sig (bool *different, SCM sig, Pitch *pitch,
- int bar_number, SCM laziness, bool ignore_octave)
-{
- int n = pitch->get_notename ();
- int o = pitch->get_octave ();
-
- SCM previous_alteration = SCM_BOOL_F;
-
- SCM from_same_octave = ly_assoc_get (scm_cons (scm_from_int (o),
- scm_from_int (n)), sig, SCM_BOOL_F);
- SCM from_key_signature = ly_assoc_get (scm_from_int (n), sig, SCM_BOOL_F);
- SCM from_other_octaves = SCM_BOOL_F;
- for (SCM s = sig; scm_is_pair (s); s = scm_cdr (s))
- {
- SCM entry = scm_car (s);
- if (scm_is_pair (scm_car (entry))
- && scm_cdar (entry) == scm_from_int (n))
- from_other_octaves = scm_cdr (entry);
- }
-
- if (from_same_octave != SCM_BOOL_F
- && recent_enough (bar_number, from_same_octave, laziness))
- previous_alteration = from_same_octave;
- else if (ignore_octave
- && from_other_octaves != SCM_BOOL_F
- && recent_enough (bar_number, from_other_octaves, laziness))
- previous_alteration = from_other_octaves;
- else if (from_key_signature != SCM_BOOL_F)
- previous_alteration = from_key_signature;
-
- int num = 1;
- if (is_tied (previous_alteration))
- {
- num = 1;
- *different = true;
- }
- else
- {
- int prev = extract_alteration (previous_alteration);
- int alter = pitch->get_alteration ();
-
- if (alter == prev)
- num = 0;
- else if ((abs (alter) < abs (prev)
- || prev * alter < 0) && alter != 0)
- num = 2;
- *different = (alter != prev);
- }
- return num;
-}
+ bool need_acc;
+ bool need_restore;
+
+ Accidental_result ()
+ {
+ need_restore = need_acc = false;
+ }
+
+ Accidental_result (bool restore, bool acc)
+ {
+ need_restore = restore;
+ need_acc = acc;
+ }
+
+ Accidental_result (SCM scm)
+ {
+ need_restore = to_boolean (scm_car (scm));
+ need_acc = to_boolean (scm_cdr (scm));
+ }
+
+ int score () const
+ {
+ return need_acc ? 1 : 0
+ + need_restore ? 1 : 0;
+ }
+};