SCM make_chord_elements (Input loc, SCM pitch, SCM dur, SCM modification_list);
SCM make_chord_step (SCM step, Rational alter);
SCM make_simple_markup (SCM a);
-SCM make_duration (SCM t, int dots = 0);
+SCM make_duration (SCM t, int dots = 0, SCM factor = SCM_UNDEFINED);
bool is_regular_identifier (SCM id, bool multiple=false);
SCM try_string_variants (SCM pred, SCM str);
int yylex (YYSTYPE *s, YYLTYPE *loc, Lily_parser *parser);
}
}
| DURATION_IDENTIFIER dots {
- Duration *d = unsmob<Duration> ($1);
- Duration k (d->duration_log (),
- d->dot_count () + scm_to_int ($2));
- k = k.compressed (d->factor ());
- scm_remember_upto_here_1 ($1);
- $$ = k.smobbed_copy ();
+ $$ = make_duration ($1, scm_to_int ($2));
}
;
multiplied_duration:
- steno_duration {
- $$ = $1;
- }
- | multiplied_duration '*' UNSIGNED {
- $$ = unsmob<Duration> ($$)->compressed (scm_to_int ($3)).smobbed_copy ();
- }
- | multiplied_duration '*' FRACTION {
- Rational m (scm_to_int (scm_car ($3)), scm_to_int (scm_cdr ($3)));
-
- $$ = unsmob<Duration> ($$)->compressed (m).smobbed_copy ();
+ steno_duration multipliers {
+ $$ = make_duration ($1, 0, $2);
}
;
}
;
+multipliers:
+ /* empty */
+ {
+ $$ = SCM_UNDEFINED;
+ }
+ | multipliers '*' UNSIGNED
+ {
+ if (!SCM_UNBNDP ($1))
+ $$ = scm_product ($1, $3);
+ else
+ $$ = $3;
+ }
+ | multipliers '*' FRACTION
+ {
+ if (!SCM_UNBNDP ($1))
+ $$ = scm_product ($1, scm_divide (scm_car ($3),
+ scm_cdr ($3)));
+ else
+ $$ = scm_divide (scm_car ($3), scm_cdr ($3));
+ }
+ ;
+
tremolo_type:
':' {
$$ = scm_from_int (parser->default_tremolo_type_);
n->set_property ("pitch", simple);
return n->unprotect ();
}
+ SCM d = simple;
+ if (scm_is_integer (simple))
+ d = make_duration (simple);
+ if (unsmob<Duration> (d)) {
+ Music *n = MY_MAKE_MUSIC ("NoteEvent", loc);
+ n->set_property ("duration", d);
+ return n->unprotect ();
+ }
return simple;
} else if (parser->lexer_->is_lyric_state ()) {
if (Text_interface::is_markup (simple))
}
SCM
-make_duration (SCM d, int dots)
+make_duration (SCM d, int dots, SCM factor)
{
- int t = scm_to_int (d);
- if (t > 0 && (t & (t-1)) == 0)
- return Duration (intlog2 (t), dots).smobbed_copy ();
- else
- return SCM_UNDEFINED;
+ Duration k;
+
+ if (Duration *dur = unsmob<Duration> (d)) {
+ if (!dots && SCM_UNBNDP (factor))
+ return d;
+ k = *dur;
+ if (dots)
+ k = Duration (k.duration_log (), k.dot_count () + dots)
+ .compressed (k.factor ());
+ } else {
+ int t = scm_to_int (d);
+ if (t > 0 && (t & (t-1)) == 0)
+ k = Duration (intlog2 (t), dots);
+ else
+ return SCM_UNDEFINED;
+ }
+
+ if (!SCM_UNBNDP (factor))
+ k = k.compressed (ly_scm2rational (factor));
+
+ return k.smobbed_copy ();
}
SCM