OnlineVectorSource Class Reference

#include <online-audio-source.h>

Inheritance diagram for OnlineVectorSource:
Collaboration diagram for OnlineVectorSource:

Public Member Functions

 OnlineVectorSource (const VectorBase< BaseFloat > &input)
 
bool Read (Vector< BaseFloat > *data)
 
- Public Member Functions inherited from OnlineAudioSourceItf
virtual ~OnlineAudioSourceItf ()
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (OnlineVectorSource)
 

Private Attributes

Vector< BaseFloatsrc_
 
uint32 pos_
 

Detailed Description

Definition at line 139 of file online-audio-source.h.

Constructor & Destructor Documentation

◆ OnlineVectorSource()

OnlineVectorSource ( const VectorBase< BaseFloat > &  input)
inline

Definition at line 141 of file online-audio-source.h.

References OnlineAudioSourceItf::Read().

142  : src_(input), pos_(0) {}

Member Function Documentation

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( OnlineVectorSource  )
private

◆ Read()

bool Read ( Vector< BaseFloat > *  data)
virtual

Implements OnlineAudioSourceItf.

Definition at line 171 of file online-audio-source.cc.

References VectorBase< Real >::CopyFromVec(), VectorBase< Real >::Dim(), rnnlm::i, and KALDI_ASSERT.

171  {
172  KALDI_ASSERT(data->Dim() > 0);
173  int32 n_elem = std::min(src_.Dim() - pos_,
174  static_cast<uint32>(data->Dim()));
175  if (n_elem > 0) {
176  SubVector<BaseFloat> subsrc(src_, pos_, n_elem);
177  if (data->Dim() == subsrc.Dim()) {
178  data->CopyFromVec(subsrc);
179  } else {
180  for (int32 i = 0; i < subsrc.Dim(); ++i)
181  (*data)(i) = subsrc(i);
182  }
183  pos_ += n_elem;
184  }
185  return (pos_ < src_.Dim());
186 }
kaldi::int32 int32
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

Member Data Documentation

◆ pos_

uint32 pos_
private

Definition at line 149 of file online-audio-source.h.

◆ src_

Vector<BaseFloat> src_
private

Definition at line 148 of file online-audio-source.h.


The documentation for this class was generated from the following files: