svcore
1.9
|
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conversion functions. More...
#include <RealTime.h>
Public Member Functions | |
int | usec () const |
int | msec () const |
RealTime () | |
RealTime (int s, int n) | |
RealTime (const RealTime &r) | |
double | toDouble () const |
RealTime & | operator= (const RealTime &r) |
RealTime | operator+ (const RealTime &r) const |
RealTime | operator- (const RealTime &r) const |
RealTime | operator- () const |
bool | operator< (const RealTime &r) const |
bool | operator> (const RealTime &r) const |
bool | operator== (const RealTime &r) const |
bool | operator!= (const RealTime &r) const |
bool | operator>= (const RealTime &r) const |
bool | operator<= (const RealTime &r) const |
RealTime | operator* (int m) const |
RealTime | operator/ (int d) const |
RealTime | operator* (double m) const |
RealTime | operator/ (double d) const |
double | operator/ (const RealTime &r) const |
Return the ratio of two times. | |
std::string | toString (bool align=false) const |
Return a human-readable debug-type string to full precision (probably not a format to show to a user directly). | |
std::string | toText (bool fixedDp=false) const |
Return a user-readable string to the nearest millisecond, in a form like HH:MM:SS.mmm. | |
std::string | toFrameText (int fps) const |
Return a user-readable string in which seconds are divided into frames (presumably at a lower frame rate than audio rate, e.g. | |
std::string | toSecText () const |
Return a user-readable string to the nearest second, in a form like "6s" (for less than a minute) or "2:21" (for more). | |
std::string | toXsdDuration () const |
Return a string in xsd:duration format. | |
Static Public Member Functions | |
static RealTime | fromSeconds (double sec) |
static RealTime | fromMilliseconds (int msec) |
static RealTime | fromTimeval (const struct timeval &) |
static RealTime | fromXsdDuration (std::string xsdd) |
static RealTime | fromString (std::string) |
Convert a string as obtained from toString back to a RealTime object. | |
static long | realTime2Frame (const RealTime &r, unsigned int sampleRate) |
Convert a RealTime into a sample frame at the given sample rate. | |
static RealTime | frame2RealTime (long frame, unsigned int sampleRate) |
Convert a sample frame at the given sample rate into a RealTime. | |
Public Attributes | |
int | sec |
int | nsec |
Static Public Attributes | |
static const RealTime | zeroTime |
RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conversion functions.
Definition at line 35 of file RealTime.h.
RealTime::RealTime | ( | ) | [inline] |
Definition at line 43 of file RealTime.h.
Referenced by fromMilliseconds(), fromSeconds(), fromString(), fromTimeval(), fromXsdDuration(), operator+(), operator-(), and operator/().
RealTime::RealTime | ( | int | s, |
int | n | ||
) |
Definition at line 44 of file RealTime.cpp.
References nsec, ONE_BILLION, and sec.
RealTime::RealTime | ( | const RealTime & | r | ) | [inline] |
Definition at line 46 of file RealTime.h.
int RealTime::usec | ( | ) | const [inline] |
Definition at line 40 of file RealTime.h.
References nsec.
int RealTime::msec | ( | ) | const [inline] |
RealTime RealTime::fromSeconds | ( | double | sec | ) | [static] |
Definition at line 60 of file RealTime.cpp.
References ONE_BILLION, and RealTime().
Referenced by MIDIFileReader::calculateTempoTimestamps(), fromXsdDuration(), MIDIFileReader::getTimeForMIDITime(), operator*(), and operator/().
RealTime RealTime::fromMilliseconds | ( | int | msec | ) | [static] |
Definition at line 66 of file RealTime.cpp.
References RealTime().
RealTime RealTime::fromTimeval | ( | const struct timeval & | tv | ) | [static] |
Definition at line 72 of file RealTime.cpp.
References RealTime().
Referenced by Profiler::end(), Profiler::Profiler(), and Profiler::update().
RealTime RealTime::fromXsdDuration | ( | std::string | xsdd | ) | [static] |
Definition at line 78 of file RealTime.cpp.
References fromSeconds(), and RealTime().
Referenced by RDFImporterImpl::getDataModelsSparse(), and RDFTransformFactoryImpl::getTransforms().
double RealTime::toDouble | ( | ) | const |
Definition at line 159 of file RealTime.cpp.
References nsec, ONE_BILLION, and sec.
Referenced by FeatureExtractionModelTransformer::addFeature().
Definition at line 56 of file RealTime.h.
Definition at line 60 of file RealTime.h.
References nsec, RealTime(), and sec.
Definition at line 63 of file RealTime.h.
References nsec, RealTime(), and sec.
RealTime RealTime::operator- | ( | ) | const [inline] |
Definition at line 66 of file RealTime.h.
References nsec, RealTime(), and sec.
bool RealTime::operator< | ( | const RealTime & | r | ) | const [inline] |
Definition at line 70 of file RealTime.h.
bool RealTime::operator> | ( | const RealTime & | r | ) | const [inline] |
Definition at line 75 of file RealTime.h.
bool RealTime::operator== | ( | const RealTime & | r | ) | const [inline] |
Definition at line 80 of file RealTime.h.
bool RealTime::operator!= | ( | const RealTime & | r | ) | const [inline] |
Definition at line 84 of file RealTime.h.
bool RealTime::operator>= | ( | const RealTime & | r | ) | const [inline] |
Definition at line 88 of file RealTime.h.
bool RealTime::operator<= | ( | const RealTime & | r | ) | const [inline] |
Definition at line 93 of file RealTime.h.
RealTime RealTime::operator* | ( | int | m | ) | const |
Definition at line 397 of file RealTime.cpp.
References fromSeconds(), nsec, ONE_BILLION, and sec.
RealTime RealTime::operator/ | ( | int | d | ) | const |
Definition at line 405 of file RealTime.cpp.
References nsec, ONE_BILLION, RealTime(), and sec.
RealTime RealTime::operator* | ( | double | m | ) | const |
Definition at line 416 of file RealTime.cpp.
References fromSeconds(), nsec, ONE_BILLION, and sec.
RealTime RealTime::operator/ | ( | double | d | ) | const |
Definition at line 424 of file RealTime.cpp.
References fromSeconds(), nsec, ONE_BILLION, and sec.
double RealTime::operator/ | ( | const RealTime & | r | ) | const |
Return the ratio of two times.
Definition at line 432 of file RealTime.cpp.
References nsec, ONE_BILLION, and sec.
std::string RealTime::toString | ( | bool | align = false | ) | const |
Return a human-readable debug-type string to full precision (probably not a format to show to a user directly).
If align is true, prepend " " to the start of positive values so that they line up with negative ones (which start with "-").
Definition at line 191 of file RealTime.cpp.
References zeroTime.
Referenced by SparseModel< RegionRec >::getData(), PathPoint::toDelimitedDataString(), OneDimensionalPoint::toDelimitedDataString(), TimeValuePoint::toDelimitedDataString(), TextPoint::toDelimitedDataString(), ImagePoint::toDelimitedDataString(), RegionRec::toDelimitedDataString(), Note::toDelimitedDataString(), FlexiNote::toDelimitedDataString(), Transform::toXml(), and toXsdDuration().
RealTime RealTime::fromString | ( | std::string | s | ) | [static] |
Convert a string as obtained from toString back to a RealTime object.
Definition at line 208 of file RealTime.cpp.
References nsec, RealTime(), and sec.
Referenced by Transform::setFromXmlAttributes().
std::string RealTime::toText | ( | bool | fixedDp = false | ) | const |
Return a user-readable string to the nearest millisecond, in a form like HH:MM:SS.mmm.
Definition at line 252 of file RealTime.cpp.
References Preferences::getInstance(), Preferences::getTimeToTextMode(), msec(), sec, Preferences::TimeToText24Frame, Preferences::TimeToText25Frame, Preferences::TimeToText30Frame, Preferences::TimeToText50Frame, Preferences::TimeToText60Frame, Preferences::TimeToTextMs, Preferences::TimeToTextUs, toFrameText(), and zeroTime.
Referenced by DenseThreeDimensionalModel::getData(), and SparseModel< RegionRec >::getData().
std::string RealTime::toFrameText | ( | int | fps | ) | const |
Return a user-readable string in which seconds are divided into frames (presumably at a lower frame rate than audio rate, e.g.
24 or 25 video frames), in a form like HH:MM:SS:FF. fps gives the number of frames per second, and must be integral (29.97 not supported).
Definition at line 314 of file RealTime.cpp.
References nsec, ONE_BILLION, sec, and zeroTime.
Referenced by toText().
std::string RealTime::toSecText | ( | ) | const |
Return a user-readable string to the nearest second, in a form like "6s" (for less than a minute) or "2:21" (for more).
Definition at line 360 of file RealTime.cpp.
std::string RealTime::toXsdDuration | ( | ) | const |
Return a string in xsd:duration format.
Definition at line 390 of file RealTime.cpp.
References toString().
Referenced by RDFTransformFactoryImpl::writeTransformToRDF().
long RealTime::realTime2Frame | ( | const RealTime & | r, |
unsigned int | sampleRate | ||
) | [static] |
Convert a RealTime into a sample frame at the given sample rate.
Definition at line 442 of file RealTime.cpp.
References nsec, sec, and zeroTime.
Referenced by RDFImporterImpl::getDataModelsSparse(), MIDIFileReader::loadTrack(), RealTimeEffectModelTransformer::run(), FeatureExtractionModelTransformer::run(), and RDFFeatureWriter::writeDenseRDF().
RealTime RealTime::frame2RealTime | ( | long | frame, |
unsigned int | sampleRate | ||
) | [static] |
Convert a sample frame at the given sample rate into a RealTime.
Definition at line 450 of file RealTime.cpp.
Referenced by DenseThreeDimensionalModel::getData(), SparseModel< RegionRec >::getData(), MIDIFileReader::loadTrack(), PathPoint::toDelimitedDataString(), OneDimensionalPoint::toDelimitedDataString(), TimeValuePoint::toDelimitedDataString(), TextPoint::toDelimitedDataString(), ImagePoint::toDelimitedDataString(), RegionRec::toDelimitedDataString(), Note::toDelimitedDataString(), and FlexiNote::toDelimitedDataString().
int RealTime::sec |
Definition at line 37 of file RealTime.h.
Referenced by frame2RealTime(), fromString(), operator*(), operator+(), operator-(), operator/(), operator<(), operator<<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), RealTime(), realTime2Frame(), toDouble(), toFrameText(), toSecText(), and toText().
int RealTime::nsec |
Definition at line 38 of file RealTime.h.
Referenced by frame2RealTime(), fromString(), msec(), operator*(), operator+(), operator-(), operator/(), operator<(), operator<<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), RealTime(), realTime2Frame(), toDouble(), toFrameText(), and usec().
const RealTime RealTime::zeroTime [static] |
Definition at line 159 of file RealTime.h.
Referenced by MIDIFileReader::calculateTempoTimestamps(), MIDIFileReader::getTimeForMIDITime(), operator<<(), realTime2Frame(), toFrameText(), toSecText(), toString(), toText(), MIDIFileReader::updateTempoMap(), and RDFTransformFactoryImpl::writeTransformToRDF().