Added sampleFrames() to audio properties

This commit is contained in:
Stephen F. Booth
2012-04-06 18:30:13 -04:00
parent 2297a6d531
commit 69ac59f5f0
6 changed files with 51 additions and 11 deletions

View File

@ -46,6 +46,7 @@ public:
channels(0),
version(0),
bitsPerSample(0),
sampleFrames(0),
file(file),
streamLength(streamLength) {}
@ -55,6 +56,7 @@ public:
int channels;
int version;
int bitsPerSample;
uint sampleFrames;
File *file;
long streamLength;
};
@ -104,6 +106,11 @@ int APE::Properties::bitsPerSample() const
return d->bitsPerSample;
}
uint APE::Properties::sampleFrames() const
{
return d->sampleFrames;
}
////////////////////////////////////////////////////////////////////////////////
// private members
////////////////////////////////////////////////////////////////////////////////
@ -192,8 +199,8 @@ void APE::Properties::analyzeCurrent()
uint totalFrames = header.mid(12, 4).toUInt(false);
uint blocksPerFrame = header.mid(4, 4).toUInt(false);
uint finalFrameBlocks = header.mid(8, 4).toUInt(false);
uint totalBlocks = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
d->length = d->sampleRate > 0 ? totalBlocks / d->sampleRate : 0;
d->sampleFrames = totalFrames > 0 ? (totalFrames - 1) * blocksPerFrame + finalFrameBlocks : 0;
d->length = d->sampleRate > 0 ? d->sampleFrames / d->sampleRate : 0;
d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0;
}

View File

@ -71,6 +71,7 @@ namespace TagLib {
* Returns number of bits per sample.
*/
int bitsPerSample() const;
uint sampleFrames() const;
/*!
* Returns APE version.