]> granicus.if.org Git - taglib/commitdiff
Added sampleFrames() for TTA files
authorStephen F. Booth <me@sbooth.org>
Sat, 4 Feb 2012 13:30:34 +0000 (08:30 -0500)
committerStephen F. Booth <me@sbooth.org>
Sat, 4 Feb 2012 13:30:34 +0000 (08:30 -0500)
taglib/trueaudio/trueaudioproperties.cpp
taglib/trueaudio/trueaudioproperties.h

index 5b1bf12d4c0c4733053c978765bc1b3936bdd0a9..bae386aa82755db603742e9c461736643fcd29fd 100644 (file)
@@ -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;
 }
index f66fd2e9a6d2dcf43f9577bd6edd97eb7e9d9a6c..126b6788b4a4596d3211b976c7c68c869fa455c5 100644 (file)
@@ -73,6 +73,11 @@ namespace TagLib {
        */
       int bitsPerSample() const;
 
+      /*!
+       * Returns the total number of sample frames
+       */
+      uint sampleFrames() const;
+
       /*!
        * Returns the major version number.
        */