- added alternate_impl for gardner

git-svn-id: http://moon:8086/svn/software/trunk/libsrc/radio@991 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2022-06-15 15:37:06 +00:00
parent f4860db361
commit e45fc5d020
2 changed files with 16 additions and 3 deletions
+15 -3
View File
@@ -91,6 +91,7 @@ void LeadLagSetState(lead_lag_filter_t *pObj, radio_float_t state)
void STRGardnerInit(str_t *pObj)
{
memset(pObj->d, 0, sizeof(pObj->d));
pObj->alternate_impl = 0;
}
radio_float_t STRGardnerProcess(str_t *pObj, cpx_t x)
@@ -100,9 +101,20 @@ radio_float_t STRGardnerProcess(str_t *pObj, cpx_t x)
pD = pObj->d;
t.real = (pD[1].real - x.real) * pD[0].real;
t.imag = (pD[1].imag - x.imag) * pD[0].imag;
Vd = (t.real + t.imag);
if (pObj->alternate_impl)
{
t.real = (x.real - pD[1].real) * pD[0].real;
t.imag = (x.imag - pD[1].imag) * pD[0].imag;
radio_float_t sign = (t.real*t.imag) < 0 ? -1.0 : 1.0;
Vd = sqrt(fabs(t.real) * fabs(t.imag)) * sign;
}
else
{
t.real = (pD[1].real - x.real) * pD[0].real;
t.imag = (pD[1].imag - x.imag) * pD[0].imag;
Vd = (t.real + t.imag);
}
// Adjust delay line
pD[1] = pD[0];
+1
View File
@@ -32,6 +32,7 @@ typedef struct _lead_lag_coeff_t
typedef struct _str_t
{
cpx_t d[2];
int alternate_impl;
} str_t;