|
ECE 486 Lab Assignments
|
Implementation of running-mean filters for in which a very long input sequence x[n] can be processed by breaking the input sequence into fixed length blocks. More...
Data Structures | |
| struct | running_mean |
| filter structure containing the filter state More... | |
Typedefs | |
| typedef struct running_mean | RUNNING_MEAN_T |
| filter structure containing the filter state More... | |
Functions | |
| RUNNING_MEAN_T * | init_running_mean (int M, int blocksize) |
| running mean filter initialization More... | |
| void | calc_running_mean (RUNNING_MEAN_T *s, float *x, float *y) |
| Calculate a block of output samples of a running meain filter from an input sample block. More... | |
| void | destroy_running_mean (RUNNING_MEAN_T *s) |
| Release memory associated with an #FIR_T. More... | |
Implementation of running-mean filters for in which a very long input sequence x[n] can be processed by breaking the input sequence into fixed length blocks.
Filter output values are given by
* y(n) = 1/M*( x[n] + x[n-1] + ... + x[n-M+1] ) *
Filters are initialized by a single call to init_running_mean(), which allocates and initializes a filter descriptor structure of type RUNNING_MEAN_T
Once a filter descriptor is initialized, repeated calls to calc_running_mean() provide the filter outputs, where the input samples are provided in fixed length blocks of "blocksize" samples at a time.
When processing completes, destroy_running_mean() should be called to release any allocated memory.
| typedef struct running_mean RUNNING_MEAN_T |
filter structure containing the filter state
| void calc_running_mean | ( | RUNNING_MEAN_T * | s, |
| float * | x, | ||
| float * | y | ||
| ) |
Calculate a block of output samples of a running meain filter from an input sample block.
Calling calc_running_mean() repeatedly generates the filter output for an arbitrary sequence of input samples. The FIR filter output samples y(n) are given by
* * i=M-1 * y[n] = (1/M) sum x[n-i] * i=0 *
For each call, an input block of samples x[i] with length "blocksize" (as specified in init_running_mean() ) is processed to generate the corresponding output samples in the output vector y[i]. In subsequent calls to calc_running_mean(), the new input blocks x[i] are assumed to follow the input blocks provided in the previous calls to calc_running_mean(). As a result, very long input sequences may be processed by breaking the sequence into many fixed-length blocks of "blocksize" samples.
Memory required to store the output vector y[i] must be allocated by the caller.
| [in,out] | s | [in,out] Pointer to previously initialized running mean filter structure, as provided by init_running() (and possibly modified by previous calls to calc_running_mean() ) |
| [in] | x | [in] pointer to the input sample array |
| [out] | y | [out] Pointer to an array for storage of output samples |
Definition at line 45 of file ece486_running_mean.c.
| void destroy_running_mean | ( | RUNNING_MEAN_T * | s | ) |
Release memory associated with an #FIR_T.
| [in] | s | [in] Pointer to previously initialized FIR filter structure, provided by init_fir() |
Definition at line 75 of file ece486_running_mean.c.
| RUNNING_MEAN_T* init_running_mean | ( | int | M, |
| int | blocksize | ||
| ) |
running mean filter initialization
Call init_running_mean() to create and initialize a running meain filter structure.
| [in] | M | [in] Number of samples to average for each output sample |
| [in] | blocksize | [in] Block size for input sample blocks |
Definition at line 21 of file ece486_running_mean.c.