RealTime Struct Reference

#include <RealTime.h>

Collaboration diagram for RealTime:

Collaboration graph
[legend]
List of all members.

Detailed Description

RealTime represents time values to nanosecond precision with accurate arithmetic and frame-rate conversion functions.

Definition at line 35 of file RealTime.h.

Public Member Functions

int usec () const
int msec () const
 RealTime ()
 RealTime (int s, int n)
 RealTime (const RealTime &r)
RealTimeoperator= (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 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).

Static Public Member Functions

static RealTime fromSeconds (double sec)
static RealTime fromMilliseconds (int msec)
static RealTime fromTimeval (const struct timeval &)
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


Constructor & Destructor Documentation

RealTime::RealTime (  )  [inline]

Definition at line 43 of file RealTime.h.

Referenced by fromMilliseconds(), fromSeconds(), fromString(), fromTimeval(), operator+(), operator-(), and operator/().

RealTime::RealTime ( int  s,
int  n 
)

Definition at line 47 of file RealTime.cpp.

References nsec, ONE_BILLION, and sec.

RealTime::RealTime ( const RealTime r  )  [inline]

Definition at line 46 of file RealTime.h.


Member Function Documentation

int RealTime::usec (  )  const [inline]

Definition at line 40 of file RealTime.h.

References nsec.

Referenced by ItemEditDialog::frameDurationChanged(), ItemEditDialog::frameTimeChanged(), ItemEditDialog::ItemEditDialog(), realTime2Frame(), ItemEditDialog::setFrameDuration(), and ItemEditDialog::setFrameTime().

int RealTime::msec (  )  const [inline]

Definition at line 41 of file RealTime.h.

References nsec.

Referenced by WaveformLayer::getFeatureDescription(), TimeRulerLayer::getMajorTickSpacing(), realTime2Frame(), and toText().

RealTime RealTime::fromSeconds ( double  sec  )  [static]

Definition at line 63 of file RealTime.cpp.

References ONE_BILLION, and RealTime().

Referenced by MIDIFileReader::calculateTempoTimestamps(), AudioCallbackPlaySource::getCurrentFrame(), MIDIFileReader::getTimeForMIDITime(), operator *(), operator/(), AudioCallbackPlaySource::play(), and MainWindowBase::rewind().

RealTime RealTime::fromMilliseconds ( int  msec  )  [static]

Definition at line 69 of file RealTime.cpp.

References RealTime().

Referenced by TimeRulerLayer::paint(), SpectrogramLayer::paint(), and TimeRulerLayer::snapToFeatureFrame().

RealTime RealTime::fromTimeval ( const struct timeval &   )  [static]

Definition at line 75 of file RealTime.cpp.

References RealTime().

Referenced by SpectrogramLayer::paint(), Profiler::Profiler(), Profiler::update(), and Profiler::~Profiler().

RealTime& RealTime::operator= ( const RealTime r  )  [inline]

Definition at line 53 of file RealTime.h.

References nsec, and sec.

RealTime RealTime::operator+ ( const RealTime r  )  const [inline]

Definition at line 57 of file RealTime.h.

References nsec, RealTime(), and sec.

RealTime RealTime::operator- ( const RealTime r  )  const [inline]

Definition at line 60 of file RealTime.h.

References nsec, RealTime(), and sec.

RealTime RealTime::operator- (  )  const [inline]

Definition at line 63 of file RealTime.h.

References nsec, RealTime(), and sec.

bool RealTime::operator< ( const RealTime r  )  const [inline]

Definition at line 67 of file RealTime.h.

References nsec, and sec.

bool RealTime::operator> ( const RealTime r  )  const [inline]

Definition at line 72 of file RealTime.h.

References nsec, and sec.

bool RealTime::operator== ( const RealTime r  )  const [inline]

Definition at line 77 of file RealTime.h.

References nsec, and sec.

bool RealTime::operator!= ( const RealTime r  )  const [inline]

Definition at line 81 of file RealTime.h.

bool RealTime::operator>= ( const RealTime r  )  const [inline]

Definition at line 85 of file RealTime.h.

References nsec, and sec.

bool RealTime::operator<= ( const RealTime r  )  const [inline]

Definition at line 90 of file RealTime.h.

References nsec, and sec.

RealTime RealTime::operator * ( int  m  )  const

Definition at line 257 of file RealTime.cpp.

References fromSeconds(), nsec, ONE_BILLION, and sec.

RealTime RealTime::operator/ ( int  d  )  const

Definition at line 265 of file RealTime.cpp.

References nsec, ONE_BILLION, RealTime(), and sec.

RealTime RealTime::operator * ( double  m  )  const

Definition at line 276 of file RealTime.cpp.

References fromSeconds(), nsec, ONE_BILLION, and sec.

RealTime RealTime::operator/ ( double  d  )  const

Definition at line 284 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 292 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 105 of file RealTime.cpp.

References stringstream, and zeroTime.

Referenced by TextPoint::toDelimitedDataString(), TimeValuePoint::toDelimitedDataString(), OneDimensionalPoint::toDelimitedDataString(), Note::toDelimitedDataString(), ImagePoint::toDelimitedDataString(), AlignmentModel::PathPoint::toDelimitedDataString(), and Transform::toXml().

RealTime RealTime::fromString ( std::string   )  [static]

Convert a string as obtained from toString back to a RealTime object.

Definition at line 126 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 171 of file RealTime.cpp.

References msec(), sec, stringstream, and zeroTime.

Referenced by WaveformLayer::getFeatureDescription(), TimeValueLayer::getFeatureDescription(), TimeInstantLayer::getFeatureDescription(), TextLayer::getFeatureDescription(), SpectrogramLayer::getFeatureDescription(), SliceLayer::getFeatureDescription(), NoteLayer::getFeatureDescription(), TimeRulerLayer::paint(), SpectrogramLayer::paintCrosshairs(), MainWindowBase::playbackFrameChanged(), and MainWindow::updateVisibleRangeDisplay().

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 222 of file RealTime.cpp.

References sec, stringstream, and zeroTime.

Referenced by MainWindowBase::playbackFrameChanged().

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 302 of file RealTime.cpp.

References msec(), nsec, sec, usec(), and zeroTime.

Referenced by MainWindowBase::ffwd(), AudioCallbackPlaySource::getCurrentFrame(), MIDIFileReader::loadTrack(), ItemEditDialog::realDurationSecsChanged(), ItemEditDialog::realDurationUSecsChanged(), ItemEditDialog::realTimeSecsChanged(), ItemEditDialog::realTimeUSecsChanged(), MainWindowBase::rewind(), RealTimeEffectModelTransformer::run(), FeatureExtractionModelTransformer::run(), ItemEditDialog::setRealDuration(), ItemEditDialog::setRealTime(), TimeRulerLayer::snapToFeatureFrame(), and Document::writeBackwardCompatibleDerivation().

RealTime RealTime::frame2RealTime ( long  frame,
unsigned int  sampleRate 
) [static]

Convert a sample frame at the given sample rate into a RealTime.

Definition at line 319 of file RealTime.cpp.

References nsec, and sec.

Referenced by Pane::drawCentreLine(), Pane::drawDurationAndRate(), TimeInstantLayer::drawEnd(), View::drawSelections(), TimeInstantLayer::editEnd(), MainWindowBase::ffwd(), ItemEditDialog::frameDurationChanged(), ItemEditDialog::frameTimeChanged(), ModelTransformerFactory::getConfigurationForTransform(), AudioCallbackPlaySource::getCurrentFrame(), AudioCallbackPlaySource::getCurrentPlayingFrame(), WaveformLayer::getFeatureDescription(), TimeValueLayer::getFeatureDescription(), TimeInstantLayer::getFeatureDescription(), TextLayer::getFeatureDescription(), SliceLayer::getFeatureDescription(), NoteLayer::getFeatureDescription(), ImageLayer::getFeatureDescription(), Colour3DPlotLayer::getFeatureDescription(), TimeRulerLayer::getMajorTickSpacing(), ItemEditDialog::getRealDuration(), ItemEditDialog::getRealTime(), SpectrogramLayer::getXBinSourceRange(), MainWindowBase::insertInstantAt(), ItemEditDialog::ItemEditDialog(), CSVFileReader::load(), SpectrogramLayer::paintCrosshairs(), MainWindowBase::playbackFrameChanged(), SVFileReader::readDerivation(), AudioCallbackPlaySource::rebuildRangeLists(), MainWindowBase::rewind(), ItemEditDialog::setFrameDuration(), ItemEditDialog::setFrameTime(), TimeRulerLayer::snapToFeatureFrame(), TextPoint::toDelimitedDataString(), TimeValuePoint::toDelimitedDataString(), OneDimensionalPoint::toDelimitedDataString(), Note::toDelimitedDataString(), ImagePoint::toDelimitedDataString(), AlignmentModel::PathPoint::toDelimitedDataString(), MainWindow::updateDescriptionLabel(), and MainWindow::updateVisibleRangeDisplay().


Member Data Documentation

int RealTime::sec

Definition at line 37 of file RealTime.h.

Referenced by frame2RealTime(), ItemEditDialog::frameDurationChanged(), ItemEditDialog::frameTimeChanged(), fromString(), WaveformLayer::getFeatureDescription(), TimeRulerLayer::getMajorTickSpacing(), operator *(), operator+(), operator-(), operator/(), operator<(), operator<<(), operator<=(), operator=(), operator==(), operator>(), operator>=(), MainWindowBase::playbackFrameChanged(), ItemEditDialog::realDurationSecsChanged(), RealTime(), realTime2Frame(), ItemEditDialog::realTimeSecsChanged(), ItemEditDialog::setFrameDuration(), ItemEditDialog::setFrameTime(), 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>=(), ItemEditDialog::realDurationUSecsChanged(), RealTime(), realTime2Frame(), ItemEditDialog::realTimeUSecsChanged(), and usec().

const RealTime RealTime::zeroTime [static]

Definition at line 142 of file RealTime.h.

Referenced by MIDIFileReader::calculateTempoTimestamps(), AudioCallbackPlaySource::getCurrentBufferedFrame(), AudioCallbackPlaySource::getCurrentFrame(), MIDIFileReader::getTimeForMIDITime(), operator<<(), AudioCallbackPlaySource::play(), realTime2Frame(), AudioCallbackPlaySource::rebuildRangeLists(), MainWindowBase::rewind(), toSecText(), toString(), toText(), MIDIFileReader::updateTempoMap(), and Document::writeBackwardCompatibleDerivation().


The documentation for this struct was generated from the following files:
Generated on Wed Feb 20 15:45:35 2008 for SonicVisualiser by  doxygen 1.5.1