Go to the source code of this file.
|
#define | BY(n, k) ((char)((uint32)(n) >> (8 * (k)) & 0xFF)) |
|
#define | WRD(n) BY(n,0), BY(n,1) |
|
#define | DWRD(n) BY(n,0), BY(n,1), BY(n,2), BY(n,3) |
|
◆ BY
#define BY |
( |
|
n, |
|
|
|
k |
|
) |
| ((char)((uint32)(n) >> (8 * (k)) & 0xFF)) |
◆ DWRD
#define DWRD |
( |
|
n | ) |
BY(n,0), BY(n,1), BY(n,2), BY(n,3) |
◆ WRD
#define WRD |
( |
|
n | ) |
BY(n,0), BY(n,1) |
◆ main()
Definition at line 208 of file wave-reader-test.cc.
References UnitTest().
211 std::cout <<
"LGTM\n";
213 }
catch (
const std::exception &e) {
214 std::cerr << e.what();
◆ UnitTest()
◆ UnitTestEndless1()
static void UnitTestEndless1 |
( |
| ) |
|
|
static |
Definition at line 127 of file wave-reader-test.cc.
References kaldi::AssertEqual(), WaveData::Data(), DWRD, WaveData::Read(), Matrix< Real >::Read(), and WRD.
Referenced by UnitTest().
129 const int byps = hz * 1 * 2 ;
130 const char file_data[] = {
148 const char expect_mat[] =
"[ 1 2 3 ]";
151 std::istringstream iws(std::string(file_data,
sizeof file_data),
152 std::ios::in | std::ios::binary);
157 std::istringstream ies(expect_mat, std::ios::in);
159 expected.
Read(ies,
false );
void Read(std::istream &is)
Read() will throw on error.
const Matrix< BaseFloat > & Data() const
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
This class's purpose is to read in Wave files.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
◆ UnitTestEndless2()
static void UnitTestEndless2 |
( |
| ) |
|
|
static |
Definition at line 164 of file wave-reader-test.cc.
References kaldi::AssertEqual(), WaveData::Data(), DWRD, WaveData::Read(), Matrix< Real >::Read(), and WRD.
Referenced by UnitTest().
166 const int byps = hz * 1 * 2 ;
167 const char file_data[] = {
185 const char expect_mat[] =
"[ 1 2 3 ]";
188 std::istringstream iws(std::string(file_data,
sizeof file_data),
189 std::ios::in | std::ios::binary);
194 std::istringstream ies(expect_mat, std::ios::in);
196 expected.
Read(ies,
false );
void Read(std::istream &is)
Read() will throw on error.
const Matrix< BaseFloat > & Data() const
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
This class's purpose is to read in Wave files.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
◆ UnitTestMono22K()
static void UnitTestMono22K |
( |
| ) |
|
|
static |
Definition at line 81 of file wave-reader-test.cc.
References kaldi::AssertEqual(), WaveData::Data(), WaveData::Duration(), DWRD, WaveData::Read(), Matrix< Real >::Read(), WaveData::SampFreq(), and WRD.
Referenced by UnitTest().
90 const int byps = hz * 1 * 2 ;
91 const char file_data[] = {
109 const char expect_mat[] =
"[ 0 -1 -32768 32767 1 ]";
112 std::istringstream iws(std::string(file_data,
sizeof file_data),
113 std::ios::in | std::ios::binary);
118 std::istringstream ies(expect_mat, std::ios::in);
120 expected.
Read(ies,
false );
void Read(std::istream &is)
Read() will throw on error.
BaseFloat SampFreq() const
const Matrix< BaseFloat > & Data() const
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
This class's purpose is to read in Wave files.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
BaseFloat Duration() const
◆ UnitTestStereo8K()
static void UnitTestStereo8K |
( |
| ) |
|
|
static |
Definition at line 33 of file wave-reader-test.cc.
References kaldi::AssertEqual(), WaveData::Data(), WaveData::Duration(), DWRD, WaveData::Read(), Matrix< Real >::Read(), WaveData::SampFreq(), and WRD.
Referenced by UnitTest().
42 const int byps = hz * 2 * 2 ;
43 const char file_data[] = {
63 const char expect_mat[] =
"[ 0 -32768 32767 \n -1 0 1 ]";
66 std::istringstream iws(std::string(file_data,
sizeof file_data),
67 std::ios::in | std::ios::binary);
72 std::istringstream ies(expect_mat, std::ios::in);
74 expected.
Read(ies,
false );
void Read(std::istream &is)
Read() will throw on error.
BaseFloat SampFreq() const
const Matrix< BaseFloat > & Data() const
void Read(std::istream &in, bool binary, bool add=false)
read from stream.
This class's purpose is to read in Wave files.
static void AssertEqual(float a, float b, float relative_tolerance=0.001)
assert abs(a - b) <= relative_tolerance * (abs(a)+abs(b))
BaseFloat Duration() const