Add coefficient query functions

Add some functions that allow the opaque struct iir_coeff_t to be queried
in order to retrieve the number and value of the filter coefficients.
This commit is contained in:
Laurence Withers 2014-07-05 11:12:42 +00:00
parent 77a526388d
commit 628e1d55a2
2 changed files with 71 additions and 0 deletions

View File

@ -58,6 +58,35 @@ iir_coeff_free(struct iir_coeff_t* coeff)
/* iir_coeff_get_*()
* Functions for querying the coefficients that make up an IIR filter.
*/
int
iir_coeff_get_nc(const struct iir_coeff_t* coeff)
{
return coeff->nc;
}
int
iir_coeff_get_nd(const struct iir_coeff_t* coeff)
{
return coeff->nd;
}
double
iir_coeff_get_c(const struct iir_coeff_t* coeff, int idx)
{
return coeff->c[idx];
}
double
iir_coeff_get_d(const struct iir_coeff_t* coeff, int idx)
{
return coeff->d[idx];
}
/* struct iir_filter_t /* struct iir_filter_t
* An instantiated IIR filter. This is actually a linked list node, so that we * An instantiated IIR filter. This is actually a linked list node, so that we
* can create chains of filters. It also has a copy of the coefficients so that * can create chains of filters. It also has a copy of the coefficients so that

View File

@ -69,6 +69,48 @@ void iir_coeff_free(struct iir_coeff_t* coeff);
/*! \brief Query number of C coefficients.
\param coeff Pointer to IIR filter object.
\returns Number of C coefficients (1).
*/
int iir_coeff_get_nc(const struct iir_coeff_t* coeff);
/*! \brief Query number of D coefficients.
\param coeff Pointer to IIR filter object.
\returns Number of D coefficients (1).
*/
int iir_coeff_get_nd(const struct iir_coeff_t* coeff);
/*! \brief Get value of C coefficient.
\param coeff Pointer to IIR filter object.
\param idx Index of coefficient (0, < \ref iir_coeff_get_nc()).
\returns C coefficient value.
*/
double iir_coeff_get_c(const struct iir_coeff_t* coeff, int idx);
/*! \brief Get value of D coefficient.
\param coeff Pointer to IIR filter object.
\param idx Index of coefficient (0, < \ref iir_coeff_get_nd()).
\returns D coefficient value.
*/
double iir_coeff_get_d(const struct iir_coeff_t* coeff, int idx);
/* opaque structure */ /* opaque structure */
struct iir_filter_t; struct iir_filter_t;