kaldi-native-fbank C++ API
Kaldi-compatible feature extraction C++ API
Loading...
Searching...
No Matches
feature-window.h File Reference

Waveform windowing and frame extraction. More...

#include <cstdint>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
Include dependency graph for feature-window.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  knf::FrameExtractionOptions
 Options for extracting frames from a waveform. More...
class  knf::FeatureWindowFunction
 Stores the windowing coefficients and applies them to a frame. More...

Namespaces

namespace  knf
 This file is part of kaldi-native-fbank.

Macros

#define KNF_PRINT(x)

Functions

int32_t knf::RoundUpToNearestPowerOfTwo (int32_t n)
 Round n up to the nearest power of two.
std::ostream & knf::operator<< (std::ostream &os, const FrameExtractionOptions &opts)
 Write the options to the stream, one option per line.
int64_t knf::FirstSampleOfFrame (int32_t frame, const FrameExtractionOptions &opts)
 Return the index of the first sample of the frame indexed frame.
int32_t knf::NumFrames (int64_t num_samples, const FrameExtractionOptions &opts, bool flush=true)
 This function returns the number of frames that we can extract from a wave file with the given number of samples in it (assumed to have the same sampling rate as specified in 'opts').
void knf::ExtractWindow (int64_t sample_offset, const std::vector< float > &wave, int32_t f, const FrameExtractionOptions &opts, const FeatureWindowFunction &window_function, std::vector< float > *window, float *log_energy_pre_window=nullptr)
 ExtractWindow() extracts a windowed frame of waveform (possibly with a power-of-two, padded size, depending on the config), including all the processing done by ProcessWindow().
void knf::ProcessWindow (const FrameExtractionOptions &opts, const FeatureWindowFunction &window_function, float *window, float *log_energy_pre_window=nullptr)
 This function does all the windowing steps after actually extracting the windowed signal: depending on the configuration, it does dithering, dc offset removal, preemphasis, and multiplication by the windowing function.
float knf::InnerProduct (const float *a, const float *b, int32_t n)
 Compute the inner product of two vectors of size n.
std::vector< float > knf::GetWindow (const std::string &window_type, int32_t window_size, float blackman_coeff=0.42)
 Return the window coefficients of the given window type.

Detailed Description

Waveform windowing and frame extraction.

This file provides the options and the helper functions used to split a waveform into overlapping frames and to apply dithering, DC offset removal, preemphasis, and a windowing function to each frame before the FFT.

Macro Definition Documentation

◆ KNF_PRINT

#define KNF_PRINT ( x)
Value:
os << #x << ": " << x << "\n"