SAF
Loading...
Searching...
No Matches
saf_utility_filters.c File Reference

A collection of IIR/FIR filter and filterbank designs. More...

#include "saf_utilities.h"
#include "saf_externals.h"

Go to the source code of this file.

Data Structures

struct  faf_IIRFB_data
 Main structure for the Favrot&Faller filterbank. More...
 

Functions

static void applyWindowingFunction (WINDOWING_FUNCTION_TYPES type, int winlength, float *x)
 Applies a windowing function (see WINDOWING_FUNCTION_TYPES enum) of length 'winlength', to vector 'x'.
 
static void applyIIR_1 (float *in_signal, int nSamples, float *b, float *a, float *wz, float *out_signal)
 Applies IIR filter of order 1.
 
static void applyIIR_2 (float *in_signal, int nSamples, float *b, float *a, float *wz, float *out_signal)
 Applies IIR filter of order 2.
 
static void applyIIR_3 (float *in_signal, int nSamples, float *b, float *a, float *wz, float *out_signal)
 Applies IIR filter of order 3.
 
void getWindowingFunction (WINDOWING_FUNCTION_TYPES type, int winlength, float *win)
 Computes the weights of a specific windowing function.
 
void getOctaveBandCutoffFreqs (float *centreFreqs, int nCentreFreqs, float *cutoffFreqs)
 Converts octave band CENTRE frequencies into CUTOFF frequencies.
 
void flattenMinphase (float *x, int len)
 Equalises input sequence by its minimum phase form, in order to bring its magnitude response to unity, as described in [1].
 
void interpolateFiltersH (int inFFTsize, int outFFTsize, int nFilters, float_complex *filters_in, float_complex *filters_out)
 Interpolate filters (w.r.t.
 
float convertBW2Q (float BW)
 Converts filter octave band-width to Q-factor.
 
float convertQ2BW (float Q)
 Converts filter Q-factor to octave band-width.
 
void biQuadCoeffs (BIQUAD_FILTER_TYPES filterType, float fc, float fs, float Q, float gain_dB, float b[3], float a[3])
 Calculates 2nd order IIR filter coefficients [1].
 
void applyBiQuadFilter (float b[3], float a[3], float w_z_12[2], float *signal, int nSamples)
 Applies biQuad filter to an input signal using the direct form II difference equation: https://en.wikipedia.org/wiki/Digital_biquad_filter.
 
void evalBiQuadTransferFunction (float b[3], float a[3], float *freqs, int nFreqs, float fs, int mag2dB, float *magnitude, float *phase_rad)
 Evaluates the 2nd order IIR transfer function at one or more frequencies, returning its magnitude and/or phase response.
 
void evalIIRTransferFunctionf (float *b_coeff, float *a_coeff, int nCoeffs, float *freqs, int nFreqs, float fs, int mag2dB, float *magnitude, float *phase_rad)
 Computes magnitude and phase response of an IIR filter from its coefficients (floats) at user-specified frequencies (Hz).
 
void evalIIRTransferFunction (double *b_coeff, double *a_coeff, int nCoeffs, float *freqs, int nFreqs, float fs, int mag2dB, float *magnitude, float *phase_rad)
 Computes magnitude and phase response of an IIR filter from its coefficients at user-specified frequencies (Hz).
 
void applyIIR (float *in_signal, int nSamples, int nCoeffs, float *b, float *a, float *wz, float *out_signal)
 Applies an IIR filter to a time-domain signal (using the direct form II difference equation)
 
void butterCoeffs (BUTTER_FILTER_TYPES filterType, int order, float cutoff1, float cutoff2, float sampleRate, double *b_coeffs, double *a_coeffs)
 Computes Butterworth IIR filter coefficients [1].
 
void faf_IIRFilterbank_create (void **phFaF, int order, float *fc, int nCutoffFreq, float sampleRate, int maxNumSamples)
 Computes a bank of IIR filter coefficients required to divide a signal into frequency bands, based on the design by Favrot & Faller [1].
 
void faf_IIRFilterbank_apply (void *hFaF, float *inSig, float **outBands, int nSamples)
 Applies the Favrot & Faller filterbank.
 
void faf_IIRFilterbank_flushBuffers (void *hFaF)
 Zeros the delay lines used during faf_IIRFilterbank_apply()
 
void faf_IIRFilterbank_destroy (void **phFaF)
 Destroys an instance of the Favrot & Faller filterbank.
 
void FIRCoeffs (FIR_FILTER_TYPES filterType, int order, float fc1, float fc2, float fs, WINDOWING_FUNCTION_TYPES windowType, int scalingFLAG, float *h_filt)
 Computes FIR filter coefficients by windowing.
 
void FIRFilterbank (int order, float *fc, int nCutoffFreq, float sampleRate, WINDOWING_FUNCTION_TYPES windowType, int scalingFLAG, float *filterbank)
 Computes a bank of FIR filter coefficients required to divide a signal into frequency bands.
 

Detailed Description

A collection of IIR/FIR filter and filterbank designs.

Author
Leo McCormack
Date
01.03.2019
License
ISC

Definition in file saf_utility_filters.c.

Function Documentation

◆ applyIIR_1()

static void applyIIR_1 ( float * in_signal,
int nSamples,
float * b,
float * a,
float * wz,
float * out_signal )
static

Applies IIR filter of order 1.

Definition at line 111 of file saf_utility_filters.c.

◆ applyIIR_2()

static void applyIIR_2 ( float * in_signal,
int nSamples,
float * b,
float * a,
float * wz,
float * out_signal )
static

Applies IIR filter of order 2.

Definition at line 139 of file saf_utility_filters.c.

◆ applyIIR_3()

static void applyIIR_3 ( float * in_signal,
int nSamples,
float * b,
float * a,
float * wz,
float * out_signal )
static

Applies IIR filter of order 3.

Definition at line 168 of file saf_utility_filters.c.

◆ applyWindowingFunction()

static void applyWindowingFunction ( WINDOWING_FUNCTION_TYPES type,
int winlength,
float * x )
static

Applies a windowing function (see WINDOWING_FUNCTION_TYPES enum) of length 'winlength', to vector 'x'.

Definition at line 34 of file saf_utility_filters.c.