diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index e60d936d..87ad4b10 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -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(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; } diff --git a/taglib/riff/aiff/aiffproperties.h b/taglib/riff/aiff/aiffproperties.h index 1408cb3e..25bf2333 100644 --- a/taglib/riff/aiff/aiffproperties.h +++ b/taglib/riff/aiff/aiffproperties.h @@ -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 &); diff --git a/taglib/riff/wav/wavproperties.cpp b/taglib/riff/wav/wavproperties.cpp index b0e4e034..21278141 100644 --- a/taglib/riff/wav/wavproperties.cpp +++ b/taglib/riff/wav/wavproperties.cpp @@ -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; diff --git a/taglib/riff/wav/wavproperties.h b/taglib/riff/wav/wavproperties.h index 10fbba1c..9f344ec2 100644 --- a/taglib/riff/wav/wavproperties.h +++ b/taglib/riff/wav/wavproperties.h @@ -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 &);