comparison base/RealTime.h @ 383:94fc0591ea43 1.2-stable

* merge from trunk (1.2 ended up being tracked from trunk, but we may want this branch for fixes later)
author Chris Cannam
date Wed, 27 Feb 2008 10:32:45 +0000
parents 21b9b25bff48
children
comparison
equal deleted inserted replaced
349:f39d33b0b265 383:94fc0591ea43
93 } 93 }
94 94
95 RealTime operator*(int m) const; 95 RealTime operator*(int m) const;
96 RealTime operator/(int d) const; 96 RealTime operator/(int d) const;
97 97
98 // Find the fractional difference between times 98 RealTime operator*(double m) const;
99 // 99 RealTime operator/(double d) const;
100
101 /**
102 * Return the ratio of two times.
103 */
100 double operator/(const RealTime &r) const; 104 double operator/(const RealTime &r) const;
101 105
102 // Return a human-readable debug-type string to full precision 106 /**
103 // (probably not a format to show to a user directly). If align 107 * Return a human-readable debug-type string to full precision
104 // is true, prepend " " to the start of positive values so that 108 * (probably not a format to show to a user directly). If align
105 // they line up with negative ones (which start with "-"). 109 * is true, prepend " " to the start of positive values so that
106 // 110 * they line up with negative ones (which start with "-").
111 */
107 std::string toString(bool align = false) const; 112 std::string toString(bool align = false) const;
108 113
109 // Return a user-readable string to the nearest millisecond 114 /**
110 // in a form like HH:MM:SS.mmm 115 * Convert a string as obtained from toString back to a RealTime
111 // 116 * object.
117 */
118 static RealTime fromString(std::string);
119
120 /**
121 * Return a user-readable string to the nearest millisecond, in a
122 * form like HH:MM:SS.mmm
123 */
112 std::string toText(bool fixedDp = false) const; 124 std::string toText(bool fixedDp = false) const;
113 125
114 // Return a user-readable string to the nearest second in a form 126 /**
115 // like "6s" (for less than a minute) or "2:21" (for more). 127 * Return a user-readable string to the nearest second, in a form
116 // 128 * like "6s" (for less than a minute) or "2:21" (for more).
129 */
117 std::string toSecText() const; 130 std::string toSecText() const;
118 131
119 // Convenience functions for handling sample frames 132 /**
120 // 133 * Convert a RealTime into a sample frame at the given sample rate.
134 */
121 static long realTime2Frame(const RealTime &r, unsigned int sampleRate); 135 static long realTime2Frame(const RealTime &r, unsigned int sampleRate);
136
137 /**
138 * Convert a sample frame at the given sample rate into a RealTime.
139 */
122 static RealTime frame2RealTime(long frame, unsigned int sampleRate); 140 static RealTime frame2RealTime(long frame, unsigned int sampleRate);
123 141
124 static const RealTime zeroTime; 142 static const RealTime zeroTime;
125 }; 143 };
126 144