diff base/RealTime.cpp @ 26:090c22aa726a

* Add the Note layer for pianoroll-type display of note-type data * Complete the MIDI file importer (well, nearly -- it would be nice to be able to import the non-note data as other sorts of models, and that's not done yet). * Minor refactoring in RealTime etc
author Chris Cannam
date Fri, 10 Feb 2006 17:51:36 +0000
parents 2fb933f88604
children 39ae3dee27b9
line wrap: on
line diff
--- a/base/RealTime.cpp	Thu Feb 09 18:01:52 2006 +0000
+++ b/base/RealTime.cpp	Fri Feb 10 17:51:36 2006 +0000
@@ -26,6 +26,7 @@
 using std::endl;
 
 #include "base/RealTime.h"
+#include "sys/time.h"
 
 // A RealTime consists of two ints that must be at least 32 bits each.
 // A signed 32-bit int can store values exceeding +/- 2 billion.  This
@@ -53,6 +54,23 @@
     }
 }
 
+RealTime
+RealTime::fromSeconds(double sec)
+{
+    return RealTime(int(sec), int((sec - int(sec)) * ONE_BILLION));
+}
+
+RealTime
+RealTime::fromMilliseconds(int msec)
+{
+    return RealTime(msec / 1000, (msec % 1000) * 1000000);
+}
+
+RealTime
+RealTime::fromTimeval(const struct timeval &tv)
+{
+    return RealTime(tv.tv_sec, tv.tv_usec * 1000);
+}
 
 std::ostream &operator<<(std::ostream &out, const RealTime &rt)
 {