comparison base/RealTime.h @ 1070:b8a788c9a6f1

Fixes to, and tests for, RealTime-to-text methods
author Chris Cannam
date Tue, 12 May 2015 16:19:45 +0100
parents a1cd5abcb38b
children c811991a5efa
comparison
equal deleted inserted replaced
1069:32ab6c48efaa 1070:b8a788c9a6f1
16 This is a modified version of a source file from the 16 This is a modified version of a source file from the
17 Rosegarden MIDI and audio sequencer and notation editor. 17 Rosegarden MIDI and audio sequencer and notation editor.
18 This file copyright 2000-2006 Chris Cannam. 18 This file copyright 2000-2006 Chris Cannam.
19 */ 19 */
20 20
21 #ifndef _REAL_TIME_H_ 21 #ifndef SV_REAL_TIME_H
22 #define _REAL_TIME_H_ 22 #define SV_REAL_TIME_H
23 23
24 #include "BaseTypes.h" 24 #include "BaseTypes.h"
25 25
26 #include <iostream> 26 #include <iostream>
27 #include <string> 27 #include <string>
126 * object. 126 * object.
127 */ 127 */
128 static RealTime fromString(std::string); 128 static RealTime fromString(std::string);
129 129
130 /** 130 /**
131 * Return a user-readable string to the nearest millisecond, in a 131 * Return a user-readable string to the nearest millisecond,
132 * form like HH:MM:SS.mmm 132 * typically in a form like HH:MM:SS.mmm. The exact format will
133 * depend on the application preferences for time display
134 * precision and hours:minutes:seconds format -- this function
135 * simply dispatches to toMSText or toFrameText with appropriate
136 * arguments depending on the preferences.
137 *
138 * If fixedDp is true, the result will be padded to 3 dp,
139 * i.e. millisecond resolution, even if the number of milliseconds
140 * is a multiple of 10.
133 */ 141 */
134 std::string toText(bool fixedDp = false) const; 142 std::string toText(bool fixedDp = false) const;
135 143
144 /**
145 * Return a user-readable string to the nearest millisecond.
146 *
147 * If fixedDp is true, the result will be padded to 3 dp,
148 * i.e. millisecond resolution, even if the number of milliseconds
149 * is a multiple of 10.
150 *
151 * If hms is true, results may be returned in the form
152 * HH:MM:SS.mmm (if the time is large enough). If hms is false,
153 * the result will always be a (fractional) number of seconds.
154 *
155 * Unlike toText, this function does not depend on the application
156 * preferences.
157 */
158 std::string toMSText(bool fixedDp, bool hms) const;
159
136 /** 160 /**
137 * Return a user-readable string in which seconds are divided into 161 * Return a user-readable string in which seconds are divided into
138 * frames (presumably at a lower frame rate than audio rate, 162 * frames (presumably at a lower frame rate than audio rate,
139 * e.g. 24 or 25 video frames), in a form like HH:MM:SS:FF. fps 163 * e.g. 24 or 25 video frames), in a form like HH:MM:SS:FF. fps
140 * gives the number of frames per second, and must be integral 164 * gives the number of frames per second, and must be integral
141 * (29.97 not supported). 165 * (29.97 not supported).
142 */ 166 *
143 std::string toFrameText(int fps) const; 167 * Unlike toText, this function does not depend on the application
144 168 * preferences.
145 /** 169 */
146 * Return a user-readable string to the nearest second, in a form 170 std::string toFrameText(int fps, bool hms) const;
147 * like "6s" (for less than a minute) or "2:21" (for more). 171
172 /**
173 * Return a user-readable string to the nearest second, in H:M:S
174 * form. Does not include milliseconds or frames. The result will
175 * be suffixed "s" if it contains only seconds (no hours or
176 * minutes).
177 *
178 * Unlike toText, this function does not depend on the application
179 * preferences.
148 */ 180 */
149 std::string toSecText() const; 181 std::string toSecText() const;
150 182
151 /** 183 /**
152 * Return a string in xsd:duration format. 184 * Return a string in xsd:duration format.