mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 14:30:36 +00:00
expose number of bits
This commit is contained in:
parent
422bfca221
commit
58fe117116
1 changed files with 9 additions and 5 deletions
14
wav.hh
14
wav.hh
|
|
@ -15,7 +15,7 @@ template <typename TYPE>
|
|||
class ReadWAV : public ReadPCM<TYPE>
|
||||
{
|
||||
std::ifstream is;
|
||||
int bits, bytes, rate_, channels_, frames_;
|
||||
int bits_, bytes, rate_, channels_, frames_;
|
||||
int offset, factor;
|
||||
int readLE(int b)
|
||||
{
|
||||
|
|
@ -61,10 +61,10 @@ public:
|
|||
rate_ = readLE(4);
|
||||
int ByteRate = readLE(4);
|
||||
int BlockAlign = readLE(2);
|
||||
bits = readLE(2);
|
||||
if (bits != 8 && bits != 16 && bits != 24 && bits != 32)
|
||||
bits_ = readLE(2);
|
||||
if (bits_ != 8 && bits_ != 16 && bits_ != 24 && bits_ != 32)
|
||||
return;
|
||||
bytes = bits / 8;
|
||||
bytes = bits_ / 8;
|
||||
if (bytes * channels_ != BlockAlign)
|
||||
return;
|
||||
if (rate_ * bytes * channels_ != ByteRate)
|
||||
|
|
@ -78,7 +78,7 @@ public:
|
|||
return;
|
||||
frames_ = Subchunk2Size / (bytes * channels_);
|
||||
|
||||
switch (bits) {
|
||||
switch (bits_) {
|
||||
case 8:
|
||||
offset = 128;
|
||||
factor = 127;
|
||||
|
|
@ -127,6 +127,10 @@ public:
|
|||
{
|
||||
return rate_;
|
||||
}
|
||||
int bits()
|
||||
{
|
||||
return bits_;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename TYPE>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue