How does QCD Calculate time through "TrackExtents"? [Archive] - Quintessential Forum

PDA

View Full Version : How does QCD Calculate time through "TrackExtents"?


shaohao
08-04-2005, 05:10 PM
Hi, Paul:
I wanna know how QCD (QMP) calculate the track time through "TrackExtents" struct.
Are both of below codez same?


one is set the "ext->end" to the duration of a track in ms and set "ext->unitpersec" to 1000ms=1s.

int GetTrackExtents(const char* medianame, TrackExtents *ext, int flags)
{
ext->track = 1;
ext->start = 0;
ext->end = duration_in_ms;
ext->bytesize = file_length;
ext->unitpersec = 1000;
}

The other one is set the "ext->end" to the total number of samples of a track and set "ext->unitpersec" to dwSamplesPerSecond=1s (also srate=1s).

int GetTrackExtents(const char* medianame, TrackExtents *ext, int flags)
{
ext->track = 1;
ext->start = 0;
ext->end = numsamples;
ext->bytesize = file_length;
ext->unitpersec = dwSamplesPerSecond;
}


Are they exactly same? which one is more accurate to calculate a track's time?

Paul
08-04-2005, 06:10 PM
The TrackExtents is setup to allow the plugin to decide what units are most convenient for it to use. If the plugin is operating in ms, then unitpersec should be 1000.

You can choose whatever unit you decide. I think unitpersec should be > 1, but that isn't a requirement. I usually use 100 or 1000, but for CDs I use 75. A greater unitpersec will give greater accuracy, but a lot is lost in the UI (for example, the number of pixels in the progress slider is usually a lot less granular than the playback units).

The 'start' and 'end' parameters must reflect the units you are using.