HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CL_FreqFilter Class Referencefinal

#include <CL_FreqFilter.h>

Public Types

enum  Type { Type::LOW_PASS, Type::HIGH_PASS, Type::BAND_PASS, Type::BAND_STOP }
 
enum  Design { Design::STANDARD, Design::BUTTERWORTH }
 
enum  Shape { Shape::GAUSSIAN, Shape::BOX }
 

Public Member Functions

 CL_FreqFilter (int size, fpreal overlap=0.1, fpreal discard=0.1, bool blend_chunks=true, bool filter_phase=false)
 
 ~CL_FreqFilter ()
 
void resize (int size)
 
void setFilter (int size, fpreal *filter, fpreal *phase=nullptr)
 
bool isReady () const
 Ensures the filter has been set and the window size is valid. More...
 
void setOverlap (fpreal overlap)
 
void setDiscard (fpreal discard)
 
void setBlendChunks (bool blend)
 
void setFilterPhase (bool filter_phase)
 
template<class F , class FD >
void filter (fpreal *dest, int dest_capacity, fpreal freqstep, const F &evaluate_data, const FD &design_filter)
 
template<class F >
void filter (fpreal *dest, int dest_capacity, fpreal freqstep, const F &evaluate_data)
 Variant of the filter method which does not need to redesign the filter depending on the chunk. More...
 
template<class F >
void constrainedFilter (fpreal *dest, int dest_capacity, fpreal freqstep, const F &evaluate_data, int constrain_region, bool shift=true)
 

Static Public Member Functions

template<class F >
static void designPassFilter (Type type, Design design, fpreal freq1, fpreal freq2, fpreal attenuation, fpreal pass_gain, int order, int size, fpreal freqstep, int index, int num, const F &override_parameters, fpreal *filter, fpreal *phase_filter=nullptr)
 
static void designPassFilter (Type type, Design design, fpreal freq1, fpreal freq2, fpreal attenuation, fpreal pass_gain, int order, int size, fpreal freqstep, fpreal *mag_filter, fpreal *phase_filter=nullptr)
 
template<class F >
static void designBandEQFilter (Shape shape, fpreal basefreq, fpreal *bands, int num_bands, int size, fpreal freqstep, int index, int num, const F &override_parameters, fpreal *filter)
 
template<class F >
static void designParaEQFilter (fpreal shape, fpreal freq, fpreal fgain, fpreal pgain, fpreal width, fpreal attenuation, int size, fpreal freqstep, int index, int num, const F &override_parameters, fpreal *filter)
 
template<class F >
static void designAverageSideband (fpreal fgain, fpreal gain, fpreal effect, int length, int passfreq, int size, const F &evaluate_data, fpreal *filter)
 
template<class F >
static void designContinuousSideband (fpreal fgain, fpreal gain, fpreal effect, int passfreq, int size, int index, const F &evaluate_data, fpreal *filter)
 

Detailed Description

Definition at line 26 of file CL_FreqFilter.h.

Member Enumeration Documentation

enum CL_FreqFilter::Design
strong
Enumerator
STANDARD 
BUTTERWORTH 

Definition at line 40 of file CL_FreqFilter.h.

enum CL_FreqFilter::Shape
strong
Enumerator
GAUSSIAN 
BOX 

Definition at line 47 of file CL_FreqFilter.h.

enum CL_FreqFilter::Type
strong
Enumerator
LOW_PASS 
HIGH_PASS 
BAND_PASS 
BAND_STOP 

Definition at line 31 of file CL_FreqFilter.h.

Constructor & Destructor Documentation

CL_FreqFilter::CL_FreqFilter ( int  size,
fpreal  overlap = 0.1,
fpreal  discard = 0.1,
bool  blend_chunks = true,
bool  filter_phase = false 
)
CL_FreqFilter::~CL_FreqFilter ( )

Member Function Documentation

template<class F >
void CL_FreqFilter::constrainedFilter ( fpreal dest,
int  dest_capacity,
fpreal  freqstep,
const F &  evaluate_data,
int  constrain_region,
bool  shift = true 
)

Filter method which constrains the endpoints by "bending" the smoothed curve to match the start and end point of the original curve.

Parameters
constrain_region- Number of samples over which to bend the curve at the beginning and end of the curve. Setting this equal to the sample rate, attenuated by the high frequency cutoff tends to give good results for smoothing animation curves. Example: constrain_region = SYSmax((1.0 - high_cutoff) * sample_rate), 1) Setting this to a value <= 0 will skip the constraining step.
shift- If true, will apply a y-offset to the input data so the starting value is zero before smoothing. The smoothed curve will then be shifted back after smoothing. This helps avoid the step response which occurs when smoothing data with a non-zero starting y-value. This can be especially seen when applying the filter to a constant function

Definition at line 455 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::designAverageSideband ( fpreal  fgain,
fpreal  gain,
fpreal  effect,
int  length,
int  passfreq,
int  size,
const F &  evaluate_data,
fpreal filter 
)
static

Definition at line 865 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::designBandEQFilter ( Shape  shape,
fpreal  basefreq,
fpreal bands,
int  num_bands,
int  size,
fpreal  freqstep,
int  index,
int  num,
const F &  override_parameters,
fpreal filter 
)
static

Definition at line 717 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::designContinuousSideband ( fpreal  fgain,
fpreal  gain,
fpreal  effect,
int  passfreq,
int  size,
int  index,
const F &  evaluate_data,
fpreal filter 
)
static

Definition at line 971 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::designParaEQFilter ( fpreal  shape,
fpreal  freq,
fpreal  fgain,
fpreal  pgain,
fpreal  width,
fpreal  attenuation,
int  size,
fpreal  freqstep,
int  index,
int  num,
const F &  override_parameters,
fpreal filter 
)
static

Definition at line 794 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::designPassFilter ( Type  type,
Design  design,
fpreal  freq1,
fpreal  freq2,
fpreal  attenuation,
fpreal  pass_gain,
int  order,
int  size,
fpreal  freqstep,
int  index,
int  num,
const F &  override_parameters,
fpreal filter,
fpreal phase_filter = nullptr 
)
static

Designs a pass filter, filling out the filter and phase_filter arrays Filter MUST be size floats long.

Definition at line 515 of file CL_FreqFilter.h.

static void CL_FreqFilter::designPassFilter ( Type  type,
Design  design,
fpreal  freq1,
fpreal  freq2,
fpreal  attenuation,
fpreal  pass_gain,
int  order,
int  size,
fpreal  freqstep,
fpreal mag_filter,
fpreal phase_filter = nullptr 
)
inlinestatic

Variant of the designPassFilter method which does not have a parameter override method

Definition at line 90 of file CL_FreqFilter.h.

template<class F , class FD >
void CL_FreqFilter::filter ( fpreal dest,
int  dest_capacity,
fpreal  freqstep,
const F &  evaluate_data,
const FD &  design_filter 
)

Filter input data by applying the frequency domain filter

Parameters
evaluate_datalambda function which returns the data value at the given index
design_filterlambda function which redesigns the filter at the currently processed chunk.

Definition at line 221 of file CL_FreqFilter.h.

template<class F >
void CL_FreqFilter::filter ( fpreal dest,
int  dest_capacity,
fpreal  freqstep,
const F &  evaluate_data 
)
inline

Variant of the filter method which does not need to redesign the filter depending on the chunk.

Definition at line 148 of file CL_FreqFilter.h.

bool CL_FreqFilter::isReady ( ) const
inline

Ensures the filter has been set and the window size is valid.

Definition at line 66 of file CL_FreqFilter.h.

void CL_FreqFilter::resize ( int  size)
void CL_FreqFilter::setBlendChunks ( bool  blend)
inline

Definition at line 75 of file CL_FreqFilter.h.

void CL_FreqFilter::setDiscard ( fpreal  discard)
inline

Definition at line 74 of file CL_FreqFilter.h.

void CL_FreqFilter::setFilter ( int  size,
fpreal filter,
fpreal phase = nullptr 
)
void CL_FreqFilter::setFilterPhase ( bool  filter_phase)
inline

Definition at line 76 of file CL_FreqFilter.h.

void CL_FreqFilter::setOverlap ( fpreal  overlap)
inline

Definition at line 73 of file CL_FreqFilter.h.


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