]> granicus.if.org Git - taglib/commitdiff
Added information about the number of bits per sample in WAVE and AIFF files
authorLukáš Lalinský <lalinsky@gmail.com>
Tue, 24 Aug 2010 15:49:47 +0000 (15:49 +0000)
committerLukáš Lalinský <lalinsky@gmail.com>
Tue, 24 Aug 2010 15:49:47 +0000 (15:49 +0000)
Patch by Stephen F. Booth

git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1167432 283d02a7-25f6-0310-bc7c-ecb5cbfe19da

taglib/riff/aiff/aiffproperties.cpp
taglib/riff/aiff/aiffproperties.h
taglib/riff/wav/wavproperties.cpp
taglib/riff/wav/wavproperties.h

index e60d936d856fceb8573abb3b90a2241ad3e1b53d..87ad4b10f13037cc3cf11d9262438be193356bf1 100644 (file)
@@ -84,7 +84,8 @@ public:
     length(0),
     bitrate(0),
     sampleRate(0),
-    channels(0)
+    channels(0),
+    sampleWidth(0)
   {
 
   }
@@ -93,6 +94,7 @@ public:
   int bitrate;
   int sampleRate;
   int channels;
+  int sampleWidth;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -130,6 +132,11 @@ int RIFF::AIFF::Properties::channels() const
   return d->channels;
 }
 
+int RIFF::AIFF::Properties::sampleWidth() const
+{
+  return d->sampleWidth;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // private members
 ////////////////////////////////////////////////////////////////////////////////
@@ -138,9 +145,9 @@ void RIFF::AIFF::Properties::read(const ByteVector &data)
 {
   d->channels       = data.mid(0, 2).toShort();
   uint sampleFrames = data.mid(2, 4).toUInt();
-  short sampleSize  = data.mid(6, 2).toShort();
+  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 * sampleSize * d->channels) / 1024.0;
+  d->bitrate        = (sampleRate * d->sampleWidth * d->channels) / 1024.0;
   d->length         = sampleFrames / d->sampleRate;
 }
index 1408cb3edfda6f6b6a389a600a31dbaed7c87a74..25bf233349a5bca84f667c49c67f804e868088a7 100644 (file)
@@ -64,6 +64,8 @@ namespace TagLib {
        virtual int sampleRate() const;
        virtual int channels() const;
 
+       int sampleWidth() const;
+
       private:
        Properties(const Properties &);
        Properties &operator=(const Properties &);
index b0e4e034a0313e94f5dc94e878d0408819e51904..2127814116274a5f5e81c82ef94a5f8f6b9958ee 100644 (file)
@@ -41,7 +41,8 @@ public:
     bitrate(0),
     sampleRate(0),
     channels(0),
-       streamLength(streamLength)
+    sampleWidth(0),
+    streamLength(streamLength)
   {
 
   }
@@ -51,6 +52,7 @@ public:
   int bitrate;
   int sampleRate;
   int channels;
+  int sampleWidth;
   uint streamLength;
 };
 
@@ -95,6 +97,11 @@ int RIFF::WAV::Properties::channels() const
   return d->channels;
 }
 
+int RIFF::WAV::Properties::sampleWidth() const
+{
+  return d->sampleWidth;
+}
+
 ////////////////////////////////////////////////////////////////////////////////
 // private members
 ////////////////////////////////////////////////////////////////////////////////
@@ -104,6 +111,7 @@ void RIFF::WAV::Properties::read(const ByteVector &data)
   d->format = data.mid(0, 2).toShort(false);
   d->channels = data.mid(2, 2).toShort(false);
   d->sampleRate = data.mid(4, 4).toUInt(false);
+  d->sampleWidth = data.mid(14, 2).toShort(false);
 
   uint byteRate = data.mid(8, 4).toUInt(false);
   d->bitrate = byteRate * 8 / 1024;
index 10fbba1cf2729165eae3bf4fad4c78126e6361f5..9f344ec2ebd38f22a804cb320a995f2a894b24b5 100644 (file)
@@ -73,6 +73,8 @@ namespace TagLib {
        virtual int sampleRate() const;
        virtual int channels() const;
 
+       int sampleWidth() const;
+
       private:
        Properties(const Properties &);
        Properties &operator=(const Properties &);