The following shows how to generate 4th order low-pass filter coefficients using Scilab.
wfir('lp', 4, [fc/fs, 0], 're', [0 0])
Typedefs | |
typedef void(* | dsp16_win_fct_t )(dsp16_t *window_data, int size) |
This type defines a pointer on a function that generates a window. | |
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 . | |
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 . | |
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 . | |
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. | |
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. | |
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. | |
void | dsp16_filt_lpfirdesign (dsp16_t *c, int fc, int fs, int order, dsp16_win_fct_t dsp16_win_fct, dsp_filt_design_options_t options) |
16-bit fixed point version of the low-pass FIR filter 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. | |
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 . | |
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 . | |
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 . | |
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. | |
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. |
typedef void(* dsp16_win_fct_t)(dsp16_t *window_data, int size) |
This type defines a pointer on a function that generates a window.
window_data | A pointer on a 16-bit fixed-point vector to store the window data. | |
size | The size in elements of the "window_data" buffer. |
Definition at line 397 of file dsp_filtering.h.
static void dsp16_filt_fir | ( | dsp16_t * | vect1, | |
dsp16_t * | vect2, | |||
int | size, | |||
dsp16_t * | h, | |||
int | h_size | |||
) | [inline, static] |
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) |
Definition at line 114 of file dsp_filtering.h.
References dsp16_vect_convpart().
00114 { dsp16_vect_convpart(vect1, vect2, size, h, h_size); };
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 containig 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 whithout 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, | |||
dsp16_win_fct_t | dsp16_win_fct, | |||
dsp_filt_design_options_t | options | |||
) |
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. | |
dsp16_win_fct | A window to apply to the coefficients. If this parameter is NULL, then no window is applied. | |
options | Specific options for the 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 whithout 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. |
static void dsp32_filt_fir | ( | dsp32_t * | vect1, | |
dsp32_t * | vect2, | |||
int | size, | |||
dsp32_t * | h, | |||
int | h_size | |||
) | [inline, static] |
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) |
Definition at line 124 of file dsp_filtering.h.
References dsp32_vect_convpart().
00124 { dsp32_vect_convpart(vect1, vect2, size, h, h_size); };
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 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 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 whithout 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 whithout 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. |