- Moment now = now_mom ();
- if (dir == START
- && now.grace_part_)
- {
- return false;
- }
-
- SCM wild = scm_list_n (ly_symbol2scm ("*"), ly_symbol2scm ("*"), SCM_UNDEFINED);
- SCM function;
- if (dir == START)
- function = scm_list_n (ly_symbol2scm ("begin"), SCM_UNDEFINED);
- else
- function = scm_list_n (ly_symbol2scm ("end"), SCM_UNDEFINED);
-
- Moment one_beat = *unsmob_moment (get_property ("beatLength"));
- int num = int ((*unsmob_moment (get_property ("measureLength")) / one_beat).main_part_);
- int den = one_beat.den ();
- SCM time = scm_list_n (scm_int2num (num), scm_int2num (den), SCM_UNDEFINED);
-
- SCM type = scm_list_n (scm_int2num (test_mom.num ()),
- scm_int2num (test_mom.den ()), SCM_UNDEFINED);
-
- /*
- UGH UGH.
- settings aren't grob-properties.
- */
- SCM settings = get_property ("autoBeamSettings");
-
- /* first guess */
-
- /* begin beam at any position
- (and fallback for end) */
- Moment moment (0);
-
- /* end beam at end of beat */
- if (dir == STOP)
- {
- SCM beat (get_property ("beatLength"));
-
- if (unsmob_moment (beat))
- moment = *unsmob_moment (beat);
- }
-
- /* second guess: property generic time exception */
- SCM m = scm_assoc (gh_append3 (function, wild, time), settings);
-
- if (m != SCM_BOOL_F && unsmob_moment (ly_cdr (m)))
- moment = * unsmob_moment (ly_cdr (m));
-
- /* third guess: property time exception, specific for duration type */
- m = scm_assoc (gh_append3 (function, type, time), settings);
- if (m != SCM_BOOL_F && unsmob_moment (ly_cdr (m)))
- moment = * unsmob_moment (ly_cdr (m));
-
- /* fourth guess [user override]: property plain generic */
- m = scm_assoc (gh_append3 (function, wild, wild), settings);
- if (m != SCM_BOOL_F && unsmob_moment (ly_cdr (m)))
- moment = * unsmob_moment (ly_cdr (m));
-
- /* fifth guess [user override]: property plain, specific for duration type */
- m = scm_assoc (gh_append3 (function, type, wild), settings);
- if (m != SCM_BOOL_F && unsmob_moment (ly_cdr (m)))
- moment = * unsmob_moment (ly_cdr (m));
-
- Rational r;
- if (moment.to_bool ())
- {
- /* Ugh? measurePosition can be negative, when \partial
- We may have to fix this elsewhere (timing translator)
- r = unsmob_moment (get_property ("measurePosition"))->mod_rat (moment);
- */
- Moment pos = * unsmob_moment (get_property ("measurePosition"));
- if (pos < Moment (0))
- {
- Moment length = * unsmob_moment (get_property ("measureLength"));
- pos = length - pos;
- }
- r = pos.main_part_.mod_rat (moment.main_part_);
- }
- else
- {
- if (dir == START)
- /* if undefined, starting is ok */
- r = 0;
- else
- /* but ending is not */
- r = 1;
- }
-
- return !r;