X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fduration-scheme.cc;h=f62bba582a40ca02bcd7987e45e50ee2c31411a0;hb=431029da44663278375c19cddd8c243afe98f473;hp=10a4bd16b28ff0a63a0eca4aa89063765be58614;hpb=4b975f3177880e16e759f67be4517f67109c2633;p=lilypond.git diff --git a/lily/duration-scheme.cc b/lily/duration-scheme.cc index 10a4bd16b2..f62bba582a 100644 --- a/lily/duration-scheme.cc +++ b/lily/duration-scheme.cc @@ -3,8 +3,8 @@ source file of the LilyPond music typesetter - (c) 1997--2005 Jan Nieuwenhuizen - Han-Wen Nienhuys + (c) 1997--2007 Jan Nieuwenhuizen + Han-Wen Nienhuys */ #include "duration.hh" @@ -27,12 +27,12 @@ LY_DEFINE (ly_duration_less_p, "ly:durationduration_log ()); } @@ -100,7 +98,7 @@ LY_DEFINE (ly_duration_dot_count, "ly:duration-dot-count", 1, 0, 0, (SCM dur), "Extract the dot count from @var{dur}") { - SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); + LY_ASSERT_SMOB (Duration, dur, 1); return scm_from_int (unsmob_duration (dur)->dot_count ()); } @@ -108,16 +106,32 @@ LY_DEFINE (ly_intlog2, "ly:intlog2", 1, 0, 0, (SCM d), "The 2-logarithm of 1/@var{d}.") { - SCM_ASSERT_TYPE (scm_is_number (d), d, SCM_ARG1, __FUNCTION__, "integer"); + LY_ASSERT_TYPE (scm_is_number, d, 1); int log = intlog2 (scm_to_int (d)); return scm_from_int (log); } +LY_DEFINE (ly_duration_length, "ly:duration-length", + 1, 0, 0, (SCM dur), + "The length of the duration as a Moment.") +{ + LY_ASSERT_SMOB (Duration, dur, 1); + return Moment (unsmob_duration (dur)->get_length ()).smobbed_copy (); +} + +LY_DEFINE (ly_duration_2_string, "ly:duration->string", + 1, 0, 0, (SCM dur), + "Convert @var{dur} to string.") +{ + LY_ASSERT_SMOB (Duration, dur, 1); + return ly_string2scm (unsmob_duration (dur)->to_string ()); +} + LY_DEFINE (ly_duration_factor, "ly:duration-factor", 1, 0, 0, (SCM dur), "Extract the compression factor from @var{dur}. Return as a pair.") { - SCM_ASSERT_TYPE (unsmob_duration (dur), dur, SCM_ARG1, __FUNCTION__, "duration"); + LY_ASSERT_SMOB (Duration, dur, 1); Rational r = unsmob_duration (dur)->factor (); return scm_cons (scm_from_int (r.num ()), scm_from_int (r.den ())); }