[an error occurred while processing this directive]
|
Вы правы,фильтр получется не стабильний ,его хватает буквально на несколько оборотов , а потом делта получаетьса огромной
коеффициенты очень точные(сравнивал с Матлабом)
вот функ. лев-дур:
/*******************************************************************************/
/* The Levinson-Durbin algorithm for compute prediction filter coefficients */
/* with a prescribed deterministic autocorrelation sequence. */
/* */
/*******************************************************************************/
int LevDur(
float *x, /* windowed input signal */
int n, /* # samples in x */
int order, /* predictor order required */
float *h, /* returned predictor coefficients */
float *pe /* returned predictor error */
) /* returns 0=OK, 1=zero power, 2=fail */
{
float r[MAX_ORDER+1]; /* autocorrelations */
float pc[MAX_ORDER+1]; /* predictor coefficients */
float ai,aj,akk; /* temporary coefficient values */
float sum; /* accumulator */
int i,k; /* loop counters */
int retcode=0;
/* check */
if (order > MAX_ORDER) {
order = MAX_ORDER;
retcode=2;
}
/* compute autocorrelations */
for (i=0;i<=order;i++) {
sum = 0;
for (k=0;k<(n-i);k++)
sum += x[k] * x[k+i];
r[i] = sum;
}
/* compute predictor coefficients */
if (r[0] == 0)
/* no signal ! */
retcode = 1;
else {
*pe = r[0];
pc[0] = 1.0;
for (k=1;k<=order;k++) {
sum = 0;
for (i=1;i<=k;i++)
sum -= pc[k-i] * r[i];
akk = sum/(*pe);
/* new predictor coefficients */
pc[k] = akk;
for (i=1;i<=(k/2);i++) {
ai = pc[i];
aj = pc[k-i];
pc[i] = ai + akk * aj;
pc[k-i] = aj + akk * ai;
}
/* new prediction error */
*pe = *pe * (1.0 - akk*akk);
if (*pe <= 0)
/* negative/zero error ! */
retcode = 2;
}
}
/* copy into System */
h[i-1] = pc[i];
h[0] = pc[0];
return (retcode);
}
создается такое впечатление ,что функция работает слишком долго!
E-mail: info@telesys.ru