Added information about the number of bits per sample in WAVE and AIFF files

Patch by Stephen F. Booth


git-svn-id: svn://anonsvn.kde.org/home/kde/trunk/kdesupport/taglib@1167432 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
This commit is contained in:
Lukáš Lalinský 2010-08-24 15:49:47 +00:00
parent f887f5eec3
commit 1c225ed37a
4 changed files with 23 additions and 4 deletions

View 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;
}

View 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 &);

View 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;

View 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 &);