Mercurial > hg > svcore
comparison base/RealTime.h @ 1057:5c5d4863b428 tonioni
Merge from cxx11 branch
author | Chris Cannam |
---|---|
date | Mon, 23 Mar 2015 11:26:28 +0000 |
parents | a1cd5abcb38b |
children | b8a788c9a6f1 |
comparison
equal
deleted
inserted
replaced
1056:c4898e57eea5 | 1057:5c5d4863b428 |
---|---|
19 */ | 19 */ |
20 | 20 |
21 #ifndef _REAL_TIME_H_ | 21 #ifndef _REAL_TIME_H_ |
22 #define _REAL_TIME_H_ | 22 #define _REAL_TIME_H_ |
23 | 23 |
24 #include "BaseTypes.h" | |
25 | |
24 #include <iostream> | 26 #include <iostream> |
25 #include <string> | 27 #include <string> |
26 | 28 |
29 #include <vamp-hostsdk/RealTime.h> | |
30 | |
27 struct timeval; | 31 struct timeval; |
28 | |
29 | 32 |
30 /** | 33 /** |
31 * RealTime represents time values to nanosecond precision | 34 * RealTime represents time values to nanosecond precision |
32 * with accurate arithmetic and frame-rate conversion functions. | 35 * with accurate arithmetic and frame-rate conversion functions. |
33 */ | 36 */ |
44 RealTime(int s, int n); | 47 RealTime(int s, int n); |
45 | 48 |
46 RealTime(const RealTime &r) : | 49 RealTime(const RealTime &r) : |
47 sec(r.sec), nsec(r.nsec) { } | 50 sec(r.sec), nsec(r.nsec) { } |
48 | 51 |
52 RealTime(const Vamp::RealTime &r) : | |
53 sec(r.sec), nsec(r.nsec) { } | |
54 | |
49 static RealTime fromSeconds(double sec); | 55 static RealTime fromSeconds(double sec); |
50 static RealTime fromMilliseconds(int msec); | 56 static RealTime fromMilliseconds(int msec); |
51 static RealTime fromTimeval(const struct timeval &); | 57 static RealTime fromTimeval(const struct timeval &); |
52 static RealTime fromXsdDuration(std::string xsdd); | 58 static RealTime fromXsdDuration(std::string xsdd); |
53 | 59 |
54 double toDouble() const; | 60 double toDouble() const; |
61 Vamp::RealTime toVampRealTime() const { return Vamp::RealTime(sec, nsec); } | |
55 | 62 |
56 RealTime &operator=(const RealTime &r) { | 63 RealTime &operator=(const RealTime &r) { |
57 sec = r.sec; nsec = r.nsec; return *this; | 64 sec = r.sec; nsec = r.nsec; return *this; |
58 } | 65 } |
59 | 66 |
147 std::string toXsdDuration() const; | 154 std::string toXsdDuration() const; |
148 | 155 |
149 /** | 156 /** |
150 * Convert a RealTime into a sample frame at the given sample rate. | 157 * Convert a RealTime into a sample frame at the given sample rate. |
151 */ | 158 */ |
152 static long realTime2Frame(const RealTime &r, unsigned int sampleRate); | 159 static sv_frame_t realTime2Frame(const RealTime &r, sv_samplerate_t sampleRate); |
153 | 160 |
154 /** | 161 /** |
155 * Convert a sample frame at the given sample rate into a RealTime. | 162 * Convert a sample frame at the given sample rate into a RealTime. |
156 */ | 163 */ |
157 static RealTime frame2RealTime(long frame, unsigned int sampleRate); | 164 static RealTime frame2RealTime(sv_frame_t frame, sv_samplerate_t sampleRate); |
158 | 165 |
159 static const RealTime zeroTime; | 166 static const RealTime zeroTime; |
160 }; | 167 }; |
161 | 168 |
162 std::ostream &operator<<(std::ostream &out, const RealTime &rt); | 169 std::ostream &operator<<(std::ostream &out, const RealTime &rt); |