All the filtering functions currently supported by the DSP library.
The following functions are using coefficients to operate. These coefficients define the properties of the filter used and must be generated first.
There are different ways to do it:
The following shows how to generate 4th order low-pass filter coefficients using Scilab.
This function computes a real FIR filter using the impulse response of the desire filter onto a fixed-length signal. It returns a signal of a length equals to (size - h_size + 1) elements.
Here is the formula of the FIR filter:
Relative functions:
This function computes a real IIR filter using the coefficients of the desire filter onto a fixed-length signal. It returns a signal of a length equals to size elements.
Here is the formula of the IIR filter:
Relative functions:
This function computes a real IIR filter using the coefficients of the desire filter onto a fixed-length signal. It returns a signal of a length equals to (size - num_size + 1) elements.
Here is the formula of the IIR filter:
Relative functions:
This function computes an adaptive LMS filter. It returns a (size)-length signal.
Here is the formula of the LMS filter:
Relative functions:
This function computes an adaptive NLMS filter. It returns a (size)-length signal.
Here is the formula of the NLMS filter:
Relative functions:
This function performs an interpolation over the input signal. It returns a (vect2_size * interpolation_ratio)-length signal.
Here is the principle of the interpolation:
Relative functions:
These functions calculate lowpass FIR filter's coefficients.
Relative functions:
Functions | |
static void | dsp16_filt_fir (dsp16_t *vect1, dsp16_t *vect2, int size, dsp16_t *h, int h_size) |
16 bits fixed point version of the FIR . More... | |
void | dsp16_filt_iir (dsp16_t *y, dsp16_t *x, int size, dsp16_t *num, int num_size, dsp16_t *den, int den_size, int num_prediv, int den_prediv) |
16-bit fixed point version of the IIR . More... | |
void | dsp16_filt_iirpart (dsp16_t *vect1, dsp16_t *vect2, int size, dsp16_t *num, int num_size, dsp16_t *den, int den_size, int num_prediv, int den_prediv) |
16 bits fixed point version of the IIR . More... | |
void | dsp16_filt_interpolation (dsp16_t *vect1, dsp16_t *vect2, int vect2_size, dsp16_t *h, int h_size, int interpolation_ratio) |
This function interpolates a vector. More... | |
void | dsp16_filt_interpolation_coefsort (dsp16_t *fir_coefs, int n_tap, int interpolation_ratio) |
This function resort the coefficients of a FIR filter to be used with the function dsp16_filt_interpolation. More... | |
void | dsp16_filt_lms (dsp16_t *x, dsp16_t *w, int size, dsp16_t new_x, dsp16_t d, dsp16_t *y, dsp16_t *e) |
16-bit fixed point version of the LMS filter. More... | |
void | dsp16_filt_lpfirdesign (dsp16_t *c, int fc, int fs, int order) |
16-bit fixed point version of the low-pass FIR filter design. More... | |
void | dsp16_filt_lpfirdesign_windowed_sinc (dsp16_t *c, int fc_hz, int fs_hz, int order) |
16-bit fixed point version of the windowed sinc low-pass FIR filter design. More... | |
void | dsp16_filt_nlms (dsp16_t *x, dsp16_t *w, int size, dsp16_t new_x, dsp16_t d, dsp16_t *y, dsp16_t *e) |
16-bit fixed point version of the NLMS filter. More... | |
static void | dsp32_filt_fir (dsp32_t *vect1, dsp32_t *vect2, int size, dsp32_t *h, int h_size) |
32 bits fixed point version of the FIR . More... | |
void | dsp32_filt_iir (dsp32_t *y, dsp32_t *x, int size, dsp32_t *num, int num_size, dsp32_t *den, int den_size, int num_prediv, int den_prediv) |
32-bit fixed point version of the IIR . More... | |
void | dsp32_filt_iirpart (dsp32_t *vect1, dsp32_t *vect2, int size, dsp32_t *num, int num_size, dsp32_t *den, int den_size, int num_prediv, int den_prediv) |
32 bits fixed point version of the IIR . More... | |
void | dsp32_filt_lms (dsp32_t *x, dsp32_t *w, int size, dsp32_t new_x, dsp32_t d, dsp32_t *y, dsp32_t *e) |
32-bit fixed point version of the LMS filter. More... | |
void | dsp32_filt_nlms (dsp32_t *x, dsp32_t *w, int size, dsp32_t new_x, dsp32_t d, dsp32_t *y, dsp32_t *e) |
32-bit fixed point version of the NLMS filter. More... | |
|
inlinestatic |
16 bits fixed point version of the FIR .
vect1 | A pointer on a 16-bit fixed-point vector of (size - h_size + 1) elements corresponding to the output buffer. |
vect2 | A pointer on a 16-bit fixed-point vector of size elements corresponding to the input buffer. |
size | The length of the input buffer (must be greater or equals to 4). |
h | A pointer on a 16-bit fixed-point vector of h_size elements corresponding to the buffer containing the impulse response coefficients. |
h_size | The length of the impulse response of the filter (must be greater than 7) |
References dsp16_vect_convpart().
void dsp16_filt_iir | ( | dsp16_t * | y, |
dsp16_t * | x, | ||
int | size, | ||
dsp16_t * | num, | ||
int | num_size, | ||
dsp16_t * | den, | ||
int | den_size, | ||
int | num_prediv, | ||
int | den_prediv | ||
) |
16-bit fixed point version of the IIR .
y | A pointer on a 16-bit fixed-point vector of size elements corresponding to the output buffer. The den_size previous elements correspond to values of old output samples and have to be set to 0 at the initialization (y-1, y-2, ...). |
x | A pointer on a 16-bit fixed-point vector of size elements corresponding to the input buffer. The num_size previous elements correspond to old samples intput samples have to be set to 0 at the initialization (x-1, x-2, ...). |
size | The length of the input buffer. |
num | A pointer on a 16-bit fixed-point vector of num_size elements corresponding to the buffer containing the numerator's coefficients of the filter. |
num_size | The length of the numerator's coefficients of the filter (must be a multiple of 2). |
den | A pointer on a 16-bit fixed-point vector of den_size elements corresponding to the buffer containing the denominator's coefficients of the filter. |
den_size | The length of the denominator's coefficients of the filter (must be a multiple of 2). |
num_prediv | The predivisor used to scale down the numerator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the numerator's coefficients by 2^num_prediv else leave this field to 0. |
den_prediv | The predivisor used to scale down the denominator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the denominator's coefficients by 2^den_prediv else leave this field to 0. |
void dsp16_filt_iirpart | ( | dsp16_t * | vect1, |
dsp16_t * | vect2, | ||
int | size, | ||
dsp16_t * | num, | ||
int | num_size, | ||
dsp16_t * | den, | ||
int | den_size, | ||
int | num_prediv, | ||
int | den_prediv | ||
) |
16 bits fixed point version of the IIR .
vect1 | A pointer on a 16-bit fixed-point vector of (size - num_size + 1) elements corresponding to the output buffer. |
vect2 | A pointer on a 16-bit fixed-point vector of size elements corresponding to the input buffer. |
size | The length of the input buffer. |
num | A pointer on a 16-bit fixed-point vector of num_size elements corresponding to the buffer containing the numerator's coefficients of the filter. |
num_size | The length of the numerator's coefficients of the filter. |
den | A pointer on a 16-bit fixed-point vector of den_size elements corresponding to the buffer containing the denominator's coefficients of the filter. |
den_size | The length of the denominator's coefficients of the filter. |
num_prediv | The predivisor used to scale down the numerator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the numerator's coefficients by 2^num_prediv else leave this field to 0. |
den_prediv | The predivisor used to scale down the denominator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the denominator's coefficients by 2^den_prediv else leave this field to 0. |
void dsp16_filt_interpolation | ( | dsp16_t * | vect1, |
dsp16_t * | vect2, | ||
int | vect2_size, | ||
dsp16_t * | h, | ||
int | h_size, | ||
int | interpolation_ratio | ||
) |
This function interpolates a vector.
vect1 | A pointer on a 16-bit fixed-point vector where to store the result. It must be of a size (in sample) equals to the size of the input buffer multiplied by the interpolation factor. |
vect2 | A pointer on a 16-bit fixed-point vector containing the input samples. |
vect2_size | The size of the input buffer. |
h | A pointer on a 16-bit fixed-point vector which contains the coefficients of the filter. These coefficients must be reorder with the function dsp16_filt_interpolation_coefsort before being used. |
h_size | The size of this buffer. |
interpolation_ratio | The interpolation factor desired for this interpolation. |
void dsp16_filt_interpolation_coefsort | ( | dsp16_t * | fir_coefs, |
int | n_tap, | ||
int | interpolation_ratio | ||
) |
This function resort the coefficients of a FIR filter to be used with the function dsp16_filt_interpolation.
fir_coefs | A pointer on a 16-bit fixed-point vector where the coefficients are stored. |
n_tap | The number of tap of this filter. |
interpolation_ratio | The interpolation factor of the interpolation to perform with this filter. |
void dsp16_filt_lms | ( | dsp16_t * | x, |
dsp16_t * | w, | ||
int | size, | ||
dsp16_t | new_x, | ||
dsp16_t | d, | ||
dsp16_t * | y, | ||
dsp16_t * | e | ||
) |
16-bit fixed point version of the LMS filter.
x | A pointer on a 16-bit fixed-point vector of (size) elements that acts as a circular buffer, filled with the input samples. Its elements have to be initialized to zero and then you just need to reinject this vector each time you call this functions without filling any of its values. |
w | A pointer on a 16-bit fixed-point vector of size elements corresponding to the coefficients of the filter. Just initialize its elements to zero and after several iterations, this buffer will be filled with the actual coefficients of the filter. |
size | The length of the circular buffer (x) and of the coefficient's buffer (w). It must be a multiple of 4. |
new_x | A 16-bit fixed-point value which contains a new input sample signal. |
d | A 16-bit fixed-point value which contains the current sample of the reference's signal. |
y | A pointer on a 16-bit fixed-point value corresponding to the current sample of the output signal. |
e | A pointer on a 16-bit fixed-point value corresponding to the current sample of the output error signal. |
void dsp16_filt_lpfirdesign | ( | dsp16_t * | c, |
int | fc, | ||
int | fs, | ||
int | order | ||
) |
16-bit fixed point version of the low-pass FIR filter design.
c | A pointer on a 16-bit fixed-point vector of "order" size, used to store the coefficients of the filter designed. |
fc | Cutoff frequency of the low-pass filter. |
fs | Sample rate of the signal to filter. |
order | Order of the filter to design. |
void dsp16_filt_lpfirdesign_windowed_sinc | ( | dsp16_t * | c, |
int | fc_hz, | ||
int | fs_hz, | ||
int | order | ||
) |
16-bit fixed point version of the windowed sinc low-pass FIR filter design.
c | A pointer on a 16-bit fixed-point vector of "order" size, used to store the coefficients of the filter designed. |
fc | Cutoff frequency of the low-pass filter. |
fs | Sample rate of the signal to filter. |
order | Order of the filter to design. |
void dsp16_filt_nlms | ( | dsp16_t * | x, |
dsp16_t * | w, | ||
int | size, | ||
dsp16_t | new_x, | ||
dsp16_t | d, | ||
dsp16_t * | y, | ||
dsp16_t * | e | ||
) |
16-bit fixed point version of the NLMS filter.
x | A pointer on a 16-bit fixed-point vector of (size) elements that acts as a circular buffer, filled with the input samples. Its elements have to be initialized to zero and then you just need to reinject this vector each time you call this functions without filling any of its values. |
w | A pointer on a 16-bit fixed-point vector of size elements corresponding to the coefficients of the filter. Just initialize its elements to zero and after several iterations, this buffer will be filled with the actual coefficients of the filter. |
size | The length of the circular buffer (x) and of the coefficient's buffer (w). It must be a multiple of 4. |
new_x | A 16-bit fixed-point value which contains a new input sample signal. |
d | A 16-bit fixed-point value which contains the current sample of the reference's signal. |
y | A pointer on a 16-bit fixed-point value corresponding to the current sample of the output signal. |
e | A pointer on a 16-bit fixed-point value corresponding to the current sample of the output error signal. |
|
inlinestatic |
32 bits fixed point version of the FIR .
vect1 | A pointer on a 32-bit fixed-point vector of (size - h_size + 1) elements corresponding to the output buffer. |
vect2 | A pointer on a 32-bit fixed-point vector of size elements corresponding to the input buffer. |
size | The length of the input buffer (must be greater or equals to 4). |
h | A pointer on a 32-bit fixed-point vector of h_size elements corresponding to the buffer containing the impulse response coefficients. |
h_size | The length of the impulse response of the filter (must be greater than 7) |
References dsp32_vect_convpart().
void dsp32_filt_iir | ( | dsp32_t * | y, |
dsp32_t * | x, | ||
int | size, | ||
dsp32_t * | num, | ||
int | num_size, | ||
dsp32_t * | den, | ||
int | den_size, | ||
int | num_prediv, | ||
int | den_prediv | ||
) |
32-bit fixed point version of the IIR .
y | A pointer on a 32-bit fixed-point vector of size elements corresponding to the output buffer. The den_size previous elements correspond to values of old output samples and have to be set to 0 at the initialization (y-1, y-2, ...). |
x | A pointer on a 32-bit fixed-point vector of size elements corresponding to the input buffer. The num_size previous elements correspond to old samples input samples have to be set to 0 at the initialization (x-1, x-2, ...). |
size | The length of the input buffer. |
num | A pointer on a 32-bit fixed-point vector of num_size elements corresponding to the buffer containing the numerator's coefficients of the filter. |
num_size | The length of the numerator's coefficients of the filter (must be a multiple of 2). |
den | A pointer on a 32-bit fixed-point vector of den_size elements corresponding to the buffer containing the denominator's coefficients of the filter. |
den_size | The length of the denominator's coefficients of the filter (must be a multiple of 2). |
num_prediv | The predivisor used to scale down the numerator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the numerator's coefficients by 2^num_prediv else leave this field to 0. |
den_prediv | The predivisor used to scale down the denominator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the denominator's coefficients by 2^den_prediv else leave this field to 0. |
void dsp32_filt_iirpart | ( | dsp32_t * | vect1, |
dsp32_t * | vect2, | ||
int | size, | ||
dsp32_t * | num, | ||
int | num_size, | ||
dsp32_t * | den, | ||
int | den_size, | ||
int | num_prediv, | ||
int | den_prediv | ||
) |
32 bits fixed point version of the IIR .
vect1 | A pointer on a 32-bit fixed-point vector of (size - num_size + 1) elements corresponding to the output buffer. |
vect2 | A pointer on a 32-bit fixed-point vector of size elements corresponding to the input buffer. |
size | The length of the input buffer. |
num | A pointer on a 32-bit fixed-point vector of num_size elements corresponding to the buffer containing the numerator's coefficients of the filter. |
num_size | The length of the numerator's coefficients of the filter. |
den | A pointer on a 32-bit fixed-point vector of den_size elements corresponding to the buffer containing the denominator's coefficients of the filter. |
den_size | The length of the denominator's coefficients of the filter. |
num_prediv | The predivisor used to scale down the numerator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the numerator's coefficients by 2^num_prediv else leave this field to 0. |
den_prediv | The predivisor used to scale down the denominator's coefficients of the filter in order to avoid overflow values. So when you use this feature, you have to prescale manually the denominator's coefficients by 2^den_prediv else leave this field to 0. |
void dsp32_filt_lms | ( | dsp32_t * | x, |
dsp32_t * | w, | ||
int | size, | ||
dsp32_t | new_x, | ||
dsp32_t | d, | ||
dsp32_t * | y, | ||
dsp32_t * | e | ||
) |
32-bit fixed point version of the LMS filter.
x | A pointer on a 32-bit fixed-point vector of (size) elements that acts as a circular buffer, filled with the input samples. Its elements have to be initialized to zero and then you just need to reinject this vector each time you call this functions without filling any of its values. |
w | A pointer on a 32-bit fixed-point vector of size elements corresponding to the coefficients of the filter. Just initialize its elements to zero and after several iterations, this buffer will be filled with the actual coefficients of the filter. |
size | The length of the circular buffer (x) and of the coefficient's buffer (w). |
new_x | A 32-bit fixed-point value which contains a new input sample signal. |
d | A 32-bit fixed-point value which contains the current sample of the reference's signal. |
y | A pointer on a 32-bit fixed-point value corresponding to the current sample of the output signal. |
e | A pointer on a 32-bit fixed-point value corresponding to the current sample of the output error signal. |
void dsp32_filt_nlms | ( | dsp32_t * | x, |
dsp32_t * | w, | ||
int | size, | ||
dsp32_t | new_x, | ||
dsp32_t | d, | ||
dsp32_t * | y, | ||
dsp32_t * | e | ||
) |
32-bit fixed point version of the NLMS filter.
x | A pointer on a 32-bit fixed-point vector of (size) elements that acts as a circular buffer, filled with the input samples. Its elements have to be initialized to zero and then you just need to reinject this vector each time you call this functions without filling any of its values. |
w | A pointer on a 32-bit fixed-point vector of size elements corresponding to the coefficients of the filter. Just initialize its elements to zero and after several iterations, this buffer will be filled with the actual coefficients of the filter. |
size | The length of the circular buffer (x) and of the coefficient's buffer (w). |
new_x | A 32-bit fixed-point value which contains a new input sample signal. |
d | A 32-bit fixed-point value which contains the current sample of the reference's signal. |
y | A pointer on a 32-bit fixed-point value corresponding to the current sample of the output signal. |
e | A pointer on a 32-bit fixed-point value corresponding to the current sample of the output error signal. |