]> granicus.if.org Git - taglib/commitdiff
Added sampleFrames() to AIFFProperties and WAVProperties
authorStephen F. Booth <me@sbooth.org>
Fri, 24 Jun 2011 14:43:13 +0000 (10:43 -0400)
committerStephen F. Booth <me@sbooth.org>
Fri, 24 Jun 2011 14:43:13 +0000 (10:43 -0400)
taglib/riff/aiff/aiffproperties.cpp
taglib/riff/aiff/aiffproperties.h
taglib/riff/wav/wavproperties.cpp
taglib/riff/wav/wavproperties.h

index 77c3d2776077044bff8e44c7b858d916330e285a..647696fd817fa968dcaa63dffd2aa7d6e5f4da5a 100644 (file)
@@ -85,7 +85,8 @@ public:
     bitrate(0),
     sampleRate(0),
     channels(0),
-    sampleWidth(0)
+    sampleWidth(0),
+       sampleFrames(0)
   {
 
   }
@@ -95,6 +96,7 @@ public:
   int sampleRate;
   int channels;
   int sampleWidth;
+  uint sampleFrames;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -137,6 +139,11 @@ int RIFF::AIFF::Properties::sampleWidth() const
   return d->sampleWidth;
 }
 
+uint RIFF::AIFF::Properties::sampleFrames() const
+{
+       return d->sampleFrames;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // private members
 ////////////////////////////////////////////////////////////////////////////////
@@ -144,10 +151,10 @@ int RIFF::AIFF::Properties::sampleWidth() const
 void RIFF::AIFF::Properties::read(const ByteVector &data)
 {
   d->channels       = data.mid(0, 2).toShort();
-  uint sampleFrames = data.mid(2, 4).toUInt();
+  d->sampleFrames   = data.mid(2, 4).toUInt();
   d->sampleWidth    = data.mid(6, 2).toShort();
   double sampleRate = ConvertFromIeeeExtended(reinterpret_cast<unsigned char *>(data.mid(8, 10).data()));
   d->sampleRate     = sampleRate;
   d->bitrate        = (sampleRate * d->sampleWidth * d->channels) / 1000.0;
-  d->length         = sampleFrames / d->sampleRate;
+  d->length         = d->sampleFrames / d->sampleRate;
 }
index 4c578dc68d6cecffe5e95ffb5bada44c9eaf22c0..ceefe32ea18ba8a85916c6883715a84965852c48 100644 (file)
@@ -65,6 +65,7 @@ namespace TagLib {
        virtual int channels() const;
 
        int sampleWidth() const;
+       uint sampleFrames() const;
 
       private:
        Properties(const Properties &);
index 3721686058f2bfcbd706353fb27e47ac8e608e62..a50979bd2fafc8f7410d2bbc845dee3d796da988 100644 (file)
@@ -42,6 +42,7 @@ public:
     sampleRate(0),
     channels(0),
     sampleWidth(0),
+       sampleFrames(0),
     streamLength(streamLength)
   {
 
@@ -53,6 +54,7 @@ public:
   int sampleRate;
   int channels;
   int sampleWidth;
+  uint sampleFrames;
   uint streamLength;
 };
 
@@ -102,6 +104,11 @@ int RIFF::WAV::Properties::sampleWidth() const
   return d->sampleWidth;
 }
 
+uint RIFF::WAV::Properties::sampleFrames() const
+{
+       return d->sampleFrames;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // private members
 ////////////////////////////////////////////////////////////////////////////////
@@ -117,4 +124,5 @@ void RIFF::WAV::Properties::read(const ByteVector &data)
   d->bitrate = byteRate * 8 / 1000;
 
   d->length = byteRate > 0 ? d->streamLength / byteRate : 0;
+  d->sampleFrames = d->streamLength / (d->channels * (d->sampleWidth / 8));
 }
index bf87ffe2a6aa40d38cb97925926b74ecbaec9ede..e75ec0fbb44a6a174cde31775641759dae00b031 100644 (file)
@@ -74,6 +74,7 @@ namespace TagLib {
        virtual int channels() const;
 
        int sampleWidth() const;
+       uint sampleFrames() const;
 
       private:
        Properties(const Properties &);