FeatureWindowFunction Struct Reference

#include <feature-window.h>

Collaboration diagram for FeatureWindowFunction:

Public Member Functions

 FeatureWindowFunction ()
 
 FeatureWindowFunction (const FrameExtractionOptions &opts)
 
 FeatureWindowFunction (const FeatureWindowFunction &other)
 

Public Attributes

Vector< BaseFloatwindow
 

Detailed Description

Definition at line 119 of file feature-window.h.

Constructor & Destructor Documentation

◆ FeatureWindowFunction() [1/3]

Definition at line 120 of file feature-window.h.

120 {}

◆ FeatureWindowFunction() [2/3]

FeatureWindowFunction ( const FrameExtractionOptions opts)
explicit

Definition at line 109 of file feature-window.cc.

References FrameExtractionOptions::blackman_coeff, rnnlm::i, KALDI_ASSERT, KALDI_ERR, M_2PI, FeatureWindowFunction::window, FrameExtractionOptions::window_type, and FrameExtractionOptions::WindowSize().

109  {
110  int32 frame_length = opts.WindowSize();
111  KALDI_ASSERT(frame_length > 0);
112  window.Resize(frame_length);
113  double a = M_2PI / (frame_length-1);
114  for (int32 i = 0; i < frame_length; i++) {
115  double i_fl = static_cast<double>(i);
116  if (opts.window_type == "hanning") {
117  window(i) = 0.5 - 0.5*cos(a * i_fl);
118  } else if (opts.window_type == "sine") {
119  // when you are checking ws wikipedia, please
120  // note that 0.5 * a = M_PI/(frame_length-1)
121  window(i) = sin(0.5 * a * i_fl);
122  } else if (opts.window_type == "hamming") {
123  window(i) = 0.54 - 0.46*cos(a * i_fl);
124  } else if (opts.window_type == "povey") { // like hamming but goes to zero at edges.
125  window(i) = pow(0.5 - 0.5*cos(a * i_fl), 0.85);
126  } else if (opts.window_type == "rectangular") {
127  window(i) = 1.0;
128  } else if (opts.window_type == "blackman") {
129  window(i) = opts.blackman_coeff - 0.5*cos(a * i_fl) +
130  (0.5 - opts.blackman_coeff) * cos(2 * a * i_fl);
131  } else {
132  KALDI_ERR << "Invalid window type " << opts.window_type;
133  }
134  }
135 }
Vector< BaseFloat > window
kaldi::int32 int32
#define KALDI_ERR
Definition: kaldi-error.h:147
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185
#define M_2PI
Definition: kaldi-math.h:52

◆ FeatureWindowFunction() [3/3]

FeatureWindowFunction ( const FeatureWindowFunction other)
inline

Definition at line 122 of file feature-window.h.

122  :
123  window(other.window) { }
Vector< BaseFloat > window

Member Data Documentation

◆ window


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