merge in Tracks-derived session-end-is-N-seconds beyond last region end, but define...
[ardour.git] / libs / timecode / src / bbt_time.cc
index 2ece391786ba7edae63133acfab7180f35ad2a8e..3b74c2761213abf3189c471a11c68bcc1dbe1973 100644 (file)
 */
 
 #include <cmath>
+#include <cassert>
 
 #include "timecode/bbt_time.h"
 
 using namespace Timecode;
 
+/* This defines the smallest division of a "beat".
+
+   The number is intended to have as many integer factors as possible so that
+   1/Nth divisions are integer numbers of ticks.
+
+   1920 has many factors, though going up to 3840 gets a couple more.
+*/
+
 const double BBT_Time::ticks_per_beat = 1920.0;
 
 BBT_Time::BBT_Time (double dbeats)
@@ -31,7 +40,9 @@ BBT_Time::BBT_Time (double dbeats)
            always be zero.
         */
 
+       assert (dbeats >= 0);
+
         bars = 0;
-        beats = rint (floor (dbeats));
-        ticks = rint (floor (BBT_Time::ticks_per_beat * fmod (dbeats, 1.0)));
+        beats = lrint (floor (dbeats));
+        ticks = lrint (floor (BBT_Time::ticks_per_beat * fmod (dbeats, 1.0)));
 }