kopia lustrzana https://github.com/Dsplib/libdspl-2.0
some changes
rodzic
c3a60ae256
commit
5e5ec534d1
|
@ -27,9 +27,9 @@
|
|||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
/******************************************************************************
|
||||
Analog Normalized Butterworth filter
|
||||
***************************************************************************************************/
|
||||
*******************************************************************************/
|
||||
int DSPL_API butter_ap(double rp, int ord, double* b, double* a)
|
||||
{
|
||||
int res;
|
||||
|
@ -74,10 +74,11 @@ exit_label:
|
|||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
/******************************************************************************
|
||||
Analog Normalized Butterworth filter zeros and poles
|
||||
***************************************************************************************************/
|
||||
int DSPL_API butter_ap_zp(int ord, double rp, complex_t *z, int* nz, complex_t *p, int* np)
|
||||
*******************************************************************************/
|
||||
int DSPL_API butter_ap_zp(int ord, double rp, complex_t *z, int* nz,
|
||||
complex_t *p, int* np)
|
||||
{
|
||||
double alpha;
|
||||
double theta;
|
||||
|
@ -122,9 +123,9 @@ int L;
|
|||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
/******************************************************************************
|
||||
Analog Normalized Chebyshev type 1 filter
|
||||
***************************************************************************************************/
|
||||
*******************************************************************************/
|
||||
int DSPL_API cheby1_ap(double rp, int ord, double* b, double* a)
|
||||
{
|
||||
int res;
|
||||
|
@ -179,10 +180,11 @@ exit_label:
|
|||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
/******************************************************************************
|
||||
Analog Normalized Chebyshev type 1 filter zeros and poles
|
||||
***************************************************************************************************/
|
||||
int DSPL_API cheby1_ap_zp(int ord, double rp, complex_t *z, int* nz, complex_t *p, int* np)
|
||||
*******************************************************************************/
|
||||
int DSPL_API cheby1_ap_zp(int ord, double rp, complex_t *z, int* nz,
|
||||
complex_t *p, int* np)
|
||||
{
|
||||
double theta;
|
||||
double ep;
|
||||
|
@ -231,13 +233,58 @@ int DSPL_API cheby1_ap_zp(int ord, double rp, complex_t *z, int* nz, complex_t *
|
|||
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
* Analog Normalized Chebyshev type 2 filter
|
||||
*******************************************************************************/
|
||||
int DSPL_API cheby2_ap(double rs, int ord, double* b, double* a)
|
||||
{
|
||||
int res;
|
||||
complex_t *z = NULL;
|
||||
complex_t *p = NULL;
|
||||
int nz, np;
|
||||
double norm;
|
||||
|
||||
|
||||
if(rs < 0.0)
|
||||
return ERROR_FILTER_RP;
|
||||
if(ord < 1)
|
||||
return ERROR_FILTER_ORD;
|
||||
if(!a || !b)
|
||||
return ERROR_PTR;
|
||||
|
||||
z = (complex_t*) malloc(ord*sizeof(complex_t));
|
||||
p = (complex_t*) malloc(ord*sizeof(complex_t));
|
||||
|
||||
|
||||
res = cheby2_ap_zp(ord, rs, z, &nz, p, &np);
|
||||
if(res != RES_OK)
|
||||
goto exit_label;
|
||||
|
||||
res = filter_zp2ab(z, nz, p, np, ord, b, a);
|
||||
if(res != RES_OK)
|
||||
goto exit_label;
|
||||
|
||||
norm = a[0] / b[0];
|
||||
|
||||
for(nz = 0; nz < ord+1; nz++)
|
||||
b[nz]*=norm;
|
||||
|
||||
exit_label:
|
||||
if(z)
|
||||
free(z);
|
||||
if(p)
|
||||
free(p);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
|
||||
/******************************************************************************
|
||||
Analog Normalized Chebyshev type 2 filter zeros and poles
|
||||
***************************************************************************************************/
|
||||
int DSPL_API cheby2_ap_zp(int ord, double rs, complex_t *z, int* nz, complex_t *p, int* np)
|
||||
*******************************************************************************/
|
||||
int DSPL_API cheby2_ap_zp(int ord, double rs, complex_t *z, int* nz,
|
||||
complex_t *p, int* np)
|
||||
{
|
||||
double es;
|
||||
int L, r, k;
|
||||
|
@ -304,10 +351,11 @@ int DSPL_API cheby2_ap_zp(int ord, double rs, complex_t *z, int* nz, complex_t *
|
|||
|
||||
|
||||
|
||||
/**************************************************************************************************
|
||||
/******************************************************************************
|
||||
Zeros and poles to filter coefficients recalc
|
||||
***************************************************************************************************/
|
||||
int DSPL_API filter_zp2ab(complex_t *z, int nz, complex_t *p, int np, int ord, double* b, double* a)
|
||||
*******************************************************************************/
|
||||
int DSPL_API filter_zp2ab(complex_t *z, int nz, complex_t *p, int np,
|
||||
int ord, double* b, double* a)
|
||||
{
|
||||
complex_t *acc = NULL;
|
||||
int res;
|
||||
|
|
|
@ -43,6 +43,7 @@ p_cheby_poly1 cheby_poly1 ;
|
|||
p_cheby_poly2 cheby_poly2 ;
|
||||
p_cheby1_ap cheby1_ap ;
|
||||
p_cheby1_ap_zp cheby1_ap_zp ;
|
||||
p_cheby2_ap cheby2_ap ;
|
||||
p_cheby2_ap_zp cheby2_ap_zp ;
|
||||
p_cmplx2re cmplx2re ;
|
||||
p_concat concat ;
|
||||
|
@ -152,6 +153,7 @@ void* dspl_load()
|
|||
LOAD_FUNC(cheby_poly2);
|
||||
LOAD_FUNC(cheby1_ap);
|
||||
LOAD_FUNC(cheby1_ap_zp);
|
||||
LOAD_FUNC(cheby2_ap);
|
||||
LOAD_FUNC(cheby2_ap_zp);
|
||||
LOAD_FUNC(cmplx2re);
|
||||
LOAD_FUNC(concat);
|
||||
|
|
|
@ -241,6 +241,11 @@ DECLARE_FUNC(int, cheby1_ap_zp, int
|
|||
COMMA complex_t*
|
||||
COMMA int*);
|
||||
//------------------------------------------------------------------------------
|
||||
DECLARE_FUNC(int, cheby2_ap, double rs
|
||||
COMMA int ord
|
||||
COMMA double* b
|
||||
COMMA double* a);
|
||||
//------------------------------------------------------------------------------
|
||||
DECLARE_FUNC(int, cheby2_ap_zp, int
|
||||
COMMA double
|
||||
COMMA complex_t*
|
||||
|
|
|
@ -43,6 +43,7 @@ p_cheby_poly1 cheby_poly1 ;
|
|||
p_cheby_poly2 cheby_poly2 ;
|
||||
p_cheby1_ap cheby1_ap ;
|
||||
p_cheby1_ap_zp cheby1_ap_zp ;
|
||||
p_cheby2_ap cheby2_ap ;
|
||||
p_cheby2_ap_zp cheby2_ap_zp ;
|
||||
p_cmplx2re cmplx2re ;
|
||||
p_concat concat ;
|
||||
|
@ -152,6 +153,7 @@ void* dspl_load()
|
|||
LOAD_FUNC(cheby_poly2);
|
||||
LOAD_FUNC(cheby1_ap);
|
||||
LOAD_FUNC(cheby1_ap_zp);
|
||||
LOAD_FUNC(cheby2_ap);
|
||||
LOAD_FUNC(cheby2_ap_zp);
|
||||
LOAD_FUNC(cmplx2re);
|
||||
LOAD_FUNC(concat);
|
||||
|
|
|
@ -241,6 +241,11 @@ DECLARE_FUNC(int, cheby1_ap_zp, int
|
|||
COMMA complex_t*
|
||||
COMMA int*);
|
||||
//------------------------------------------------------------------------------
|
||||
DECLARE_FUNC(int, cheby2_ap, double rs
|
||||
COMMA int ord
|
||||
COMMA double* b
|
||||
COMMA double* a);
|
||||
//------------------------------------------------------------------------------
|
||||
DECLARE_FUNC(int, cheby2_ap_zp, int
|
||||
COMMA double
|
||||
COMMA complex_t*
|
||||
|
|
Ładowanie…
Reference in New Issue