WaveHeaderReadGofer Struct Reference
Collaboration diagram for WaveHeaderReadGofer:

Public Member Functions

 WaveHeaderReadGofer (std::istream &is)
 
void Expect4ByteTag (const char *expected)
 
void Read4ByteTag ()
 
uint32 ReadUint32 ()
 
uint16 ReadUint16 ()
 

Public Attributes

std::istream & is
 
bool swap
 
char tag [5]
 

Detailed Description

Definition at line 35 of file wave-reader.cc.

Constructor & Destructor Documentation

◆ WaveHeaderReadGofer()

WaveHeaderReadGofer ( std::istream &  is)
inline

Definition at line 40 of file wave-reader.cc.

40  : is(is), swap(false) {
41  memset(tag, '\0', sizeof tag);
42  }

Member Function Documentation

◆ Expect4ByteTag()

void Expect4ByteTag ( const char *  expected)
inline

Definition at line 44 of file wave-reader.cc.

References KALDI_ERR.

Referenced by WaveInfo::Read().

44  {
45  is.read(tag, 4);
46  if (is.fail())
47  KALDI_ERR << "WaveData: expected " << expected
48  << ", failed to read anything";
49  if (strcmp(tag, expected))
50  KALDI_ERR << "WaveData: expected " << expected << ", got " << tag;
51  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ Read4ByteTag()

void Read4ByteTag ( )
inline

Definition at line 53 of file wave-reader.cc.

References KALDI_ERR.

Referenced by WaveInfo::Read().

53  {
54  is.read(tag, 4);
55  if (is.fail())
56  KALDI_ERR << "WaveData: expected 4-byte chunk-name, got read error";
57  }
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ ReadUint16()

uint16 ReadUint16 ( )
inline

Definition at line 72 of file wave-reader.cc.

References KALDI_ERR, and KALDI_SWAP2.

Referenced by WaveInfo::Read().

72  {
73  union {
74  char result[2];
75  int16 ans;
76  } u;
77  is.read(u.result, 2);
78  if (swap)
79  KALDI_SWAP2(u.result);
80  if (is.fail())
81  KALDI_ERR << "WaveData: unexpected end of file or read error";
82  return u.ans;
83  }
#define KALDI_SWAP2(a)
Definition: kaldi-utils.h:114
#define KALDI_ERR
Definition: kaldi-error.h:147

◆ ReadUint32()

uint32 ReadUint32 ( )
inline

Definition at line 59 of file wave-reader.cc.

References KALDI_ERR, and KALDI_SWAP4.

Referenced by WaveInfo::Read().

59  {
60  union {
61  char result[4];
62  uint32 ans;
63  } u;
64  is.read(u.result, 4);
65  if (swap)
66  KALDI_SWAP4(u.result);
67  if (is.fail())
68  KALDI_ERR << "WaveData: unexpected end of file or read error";
69  return u.ans;
70  }
#define KALDI_ERR
Definition: kaldi-error.h:147
#define KALDI_SWAP4(a)
Definition: kaldi-utils.h:107

Member Data Documentation

◆ is

std::istream& is

Definition at line 36 of file wave-reader.cc.

◆ swap

bool swap

Definition at line 37 of file wave-reader.cc.

Referenced by WaveInfo::Read().

◆ tag

char tag[5]

Definition at line 38 of file wave-reader.cc.

Referenced by WaveInfo::Read().


The documentation for this struct was generated from the following file: