Add interface to query coefficients from chain

This commit is contained in:
Laurence Withers 2014-07-07 11:57:16 +00:00
parent a08f846437
commit b12a49542a
2 changed files with 48 additions and 0 deletions

View File

@ -217,6 +217,25 @@ iir_filter(struct iir_filter_t* fi, double samp)
int
iir_filter_coeff_sets(const struct iir_filter_t* fi)
{
int count;
for(count = 0; fi; ++count) fi = fi->next;
return count;
}
struct iir_coeff_t*
iir_filter_coeff_set(const struct iir_filter_t* fi, int idx)
{
while(idx--) fi = fi->next;
return iir_coeff_new(fi->nc, fi->c, fi->nd, fi->d);
}
/* options for text editors /* options for text editors
vim: expandtab:ts=4:sw=4 vim: expandtab:ts=4:sw=4
*/ */

View File

@ -121,6 +121,35 @@ double iir_filter(struct iir_filter_t* fi, double samp);
/*! \brief Count number of coefficient sets in IIR filter chain
\param fi Filter object.
\returns Number of coefficient sets in chain (1).
Returns the number of discrete IIR filter coefficient sets used in the filter
object \a fi. There will always be at least one set.
*/
int iir_filter_coeff_sets(const struct iir_filter_t* fi);
/*! \brief Get IIR coefficient set from filter chain
\param fi Filter object.
\param idx Index of coefficient set (0 \a idx < \ref iir_filter_coeff_sets()).
\returns Newly-allocated coefficient set object.
Extracts the IIR filter coefficient set for the given step (\a idx) in the chain
of filters in \a fi. Returns a newly-allocated filter coefficient set object
which can be freed with \ref iir_coeff_free().
*/
struct iir_coeff_t* iir_filter_coeff_set(const struct iir_filter_t* fi,
int idx);
/*!@}*/ /*!@}*/
/* options for text editors /* options for text editors
vim: expandtab:ts=4:sw=4:syntax=c.doxygen vim: expandtab:ts=4:sw=4:syntax=c.doxygen