|
FilterGen
1.0.0
A library to design digital filters in embedded systems.
|
The API for the C Programming language. More...
Classes | |
| struct | dh_filter_parameters |
| struct | dh_filter_data |
Functions | |
| DH_FILTER_RETURN_VALUE | dh_filter (dh_filter_data *filter, double input, double *output) |
| Runs an iteration of the filter. More... | |
| DH_FILTER_RETURN_VALUE | dh_create_filter (dh_filter_data *filter, dh_filter_parameters *options) |
| Allocates the buffers and initializes the filter. More... | |
| DH_FILTER_RETURN_VALUE | dh_initialize_filter (dh_filter_data *filter, double value) |
| Forces the filter to the steady state with output value by setting all pasts inputs and outputs to the given [value]. More... | |
| DH_FILTER_RETURN_VALUE | dh_free_filter (dh_filter_data *filter) |
| DH_FILTER_RETURN_VALUE | dh_filter_set_gain (dh_filter_data *filter, double gain) |
| DH_FILTER_RETURN_VALUE | dh_filter_get_gain (const dh_filter_data *filter, double *gain) |
| DH_FILTER_RETURN_VALUE | dh_filter_get_gain_at (const dh_filter_data *filter, double frequency, dh_frequency_response_t *gain) |
The API for the C Programming language.
The API of the filter library is kept as simple as possible. When you create a filter, you first create a dh_filter_parameters structure and initialize its data members. The filter must be initialized via dh_create_filter().
Here is an example for the basic usage of the API:
The return value for the public API of the library.
| enum DH_FILTER_TYPE |
The filter types supported by this library.
| DH_FILTER_RETURN_VALUE dh_create_filter | ( | dh_filter_data * | filter, |
| dh_filter_parameters * | options | ||
| ) |
Allocates the buffers and initializes the filter.
A filter generated by this function will always have gain 1. If you need a different gain, call dh_filter_set_gain().
| [out] | filter | pointer to the filter structure that will be initialized. |
| [in] | options | the desired filter type. |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |
| DH_FILTER_UNKNOWN_FILTER_TYPE | An unknown filter was requested in the options. |
| DH_FILTER_ALLOCATION_FAILED | Not enough memory for the filter could be allocated. |
| DH_FILTER_RETURN_VALUE dh_filter | ( | dh_filter_data * | filter, |
| double | input, | ||
| double * | output | ||
| ) |
Runs an iteration of the filter.
The function runs a loop for the feedforward and feedback coefficients. The ring buffer holding the past inputs and outputs will be updated.
| [in] | filter | The data structure of the filter. Must be initialized (the buffers/coefficients must be set). |
| [in] | input | The next input value to the filter. |
| [out] | output | The current output value. Parameter is optional. If it is not NULL, then the output value is written to the given address. |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |
| DH_FILTER_DATA_STRUCTURE_NOT_INITIALIZED | The filter data structure was not correctly initialized. |
| DH_FILTER_RETURN_VALUE dh_filter_get_gain | ( | const dh_filter_data * | filter, |
| double * | gain | ||
| ) |
Gets the gain of the filter.
| [in] | filter | the filter structure |
| [out] | gain | pointer to output |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |
| DH_FILTER_DATA_STRUCTURE_NOT_INITIALIZED | The filter data structure was not correctly initialized. |
| DH_FILTER_RETURN_VALUE dh_filter_get_gain_at | ( | const dh_filter_data * | filter, |
| double | frequency, | ||
| dh_frequency_response_t * | gain | ||
| ) |
Gets the gain of the filter.
| [in] | filter | the filter structure |
| [in] | frequency | frequency/sampling_frequency where the gain is computed. Range: [0,0.5] |
| [out] | gain | pointer to output |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |
| DH_FILTER_DATA_STRUCTURE_NOT_INITIALIZED | The filter data structure was not correctly initialized. |
| DH_FILTER_RETURN_VALUE dh_filter_set_gain | ( | dh_filter_data * | filter, |
| double | gain | ||
| ) |
Sets the gain of the filter to the given value.
| [in] | filter | the filter structure |
| [in] | gain | the desired gain |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |
| DH_FILTER_DATA_STRUCTURE_NOT_INITIALIZED | The filter data structure was not correctly initialized. |
| DH_FILTER_RETURN_VALUE dh_free_filter | ( | dh_filter_data * | filter | ) |
Frees the filter created with dh_create_filter().
If the filter is marked as owner of the buffer, free() will be called to clean up the allocated memory.
| [in] | filter | the filter structure that will be freed. |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_RETURN_VALUE dh_initialize_filter | ( | dh_filter_data * | filter, |
| double | value | ||
| ) |
Forces the filter to the steady state with output value by setting all pasts inputs and outputs to the given [value].
| [in] | filter | the filter structure |
| [in] | value | the desired steady state |
| DH_FILTER_OK | Operation was successfull |
| DH_FILTER_NO_DATA_STRUCTURE | You gave NULL as first argument. |