+/** Calculate the number of accidentals on basis of the current local key
+ sig (passed as argument)
+
+ * First check step+octave (taking into account barnumbers if necessary).
+
+ * Then check the global signature (only step).
+
+ Return number of accidentals (0, 1 or 2). */
+
+static bool
+recent_enough (int bar_number, SCM alteration_def, SCM laziness)
+{
+ if (scm_is_number (alteration_def)
+ || laziness== SCM_BOOL_T)
+ return true;
+
+ return (bar_number <= scm_to_int (scm_cdr (alteration_def)) + scm_to_int (laziness));
+}
+
+static int
+extract_alteration (SCM alteration_def)
+{
+ if (scm_is_number (alteration_def))
+ return scm_to_int (alteration_def);
+ else if (scm_is_pair (alteration_def))
+ return scm_to_int (scm_car (alteration_def));
+ else if (alteration_def == SCM_BOOL_F)
+ return 0;
+ else
+ assert (0);
+ return 0;
+}
+
+bool
+is_tied (SCM alteration_def)
+{
+ return (alteration_def == SCM_BOOL_T)
+ || (scm_is_pair (alteration_def) && scm_car (alteration_def) == SCM_BOOL_T);
+}