diff base/RealTime.h @ 1040:a1cd5abcb38b cxx11

Introduce and use a samplerate type
author Chris Cannam
date Wed, 04 Mar 2015 12:01:04 +0000
parents cc27f35aa75c
children b8a788c9a6f1
line wrap: on
line diff
--- a/base/RealTime.h	Tue Mar 03 17:09:19 2015 +0000
+++ b/base/RealTime.h	Wed Mar 04 12:01:04 2015 +0000
@@ -26,6 +26,8 @@
 #include <iostream>
 #include <string>
 
+#include <vamp-hostsdk/RealTime.h>
+
 struct timeval;
 
 /**
@@ -47,12 +49,16 @@
     RealTime(const RealTime &r) :
 	sec(r.sec), nsec(r.nsec) { }
 
+    RealTime(const Vamp::RealTime &r) :
+	sec(r.sec), nsec(r.nsec) { }
+
     static RealTime fromSeconds(double sec);
     static RealTime fromMilliseconds(int msec);
     static RealTime fromTimeval(const struct timeval &);
     static RealTime fromXsdDuration(std::string xsdd);
 
     double toDouble() const;
+    Vamp::RealTime toVampRealTime() const { return Vamp::RealTime(sec, nsec); }
 
     RealTime &operator=(const RealTime &r) {
 	sec = r.sec; nsec = r.nsec; return *this;
@@ -150,12 +156,12 @@
     /**
      * Convert a RealTime into a sample frame at the given sample rate.
      */
-    static sv_frame_t realTime2Frame(const RealTime &r, int sampleRate);
+    static sv_frame_t realTime2Frame(const RealTime &r, sv_samplerate_t sampleRate);
 
     /**
      * Convert a sample frame at the given sample rate into a RealTime.
      */
-    static RealTime frame2RealTime(sv_frame_t frame, int sampleRate);
+    static RealTime frame2RealTime(sv_frame_t frame, sv_samplerate_t sampleRate);
 
     static const RealTime zeroTime;
 };