From dc628204c06acf826ce522e6eab578bdd589edf8 Mon Sep 17 00:00:00 2001 From: "Stephen F. Booth" Date: Sat, 4 Feb 2012 08:30:34 -0500 Subject: [PATCH] Added sampleFrames() for TTA files --- taglib/trueaudio/trueaudioproperties.cpp | 13 ++++++++++--- taglib/trueaudio/trueaudioproperties.h | 5 +++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/taglib/trueaudio/trueaudioproperties.cpp b/taglib/trueaudio/trueaudioproperties.cpp index 5b1bf12d..bae386aa 100644 --- a/taglib/trueaudio/trueaudioproperties.cpp +++ b/taglib/trueaudio/trueaudioproperties.cpp @@ -48,7 +48,8 @@ public: bitrate(0), sampleRate(0), channels(0), - bitsPerSample(0) {} + bitsPerSample(0), + sampleFrames(0) {} ByteVector data; long streamLength; @@ -59,6 +60,7 @@ public: int sampleRate; int channels; int bitsPerSample; + uint sampleFrames; }; //////////////////////////////////////////////////////////////////////////////// @@ -101,6 +103,11 @@ int TrueAudio::Properties::channels() const return d->channels; } +uint TrueAudio::Properties::sampleFrames() const +{ + return d->sampleFrames; +} + int TrueAudio::Properties::ttaVersion() const { return d->version; @@ -129,8 +136,8 @@ void TrueAudio::Properties::read() d->sampleRate = d->data.mid(pos, 4).toUInt(false); pos += 4; - unsigned long samples = d->data.mid(pos, 4).toUInt(false); - d->length = samples / d->sampleRate; + d->sampleFrames = d->data.mid(pos, 4).toUInt(false); + d->length = d->sampleFrames / d->sampleRate; d->bitrate = d->length > 0 ? ((d->streamLength * 8L) / d->length) / 1000 : 0; } diff --git a/taglib/trueaudio/trueaudioproperties.h b/taglib/trueaudio/trueaudioproperties.h index f66fd2e9..126b6788 100644 --- a/taglib/trueaudio/trueaudioproperties.h +++ b/taglib/trueaudio/trueaudioproperties.h @@ -73,6 +73,11 @@ namespace TagLib { */ int bitsPerSample() const; + /*! + * Returns the total number of sample frames + */ + uint sampleFrames() const; + /*! * Returns the major version number. */