|
发表于 2007-3-21 19:30:26
|
显示全部楼层
FP32 FFT_THD(FP32 const *CosTab,
FP32 const *SinTab) {
FP32 Kr, Ki, Krms; //系数,实部,虚部
INT8U i;
Kr = ((FP32)sample_data[0] - (FP32)sample_data[32]) * CosTab[0];
Ki = ((FP32)sample_data[16] - (FP32)sample_data[48]) * SinTab[16];
for (i=1;i<16;i++)
{
Kr += ((FP32)sample_data - (FP32)sample_data[32-i] - (FP32)sample_data[32+i] +
(FP32)sample_data[64 - i]) * CosTab;
Ki += ((FP32)sample_data + (FP32)sample_data[32-i] - (FP32)sample_data[32+i] -
(FP32)sample_data[64 - i]) * SinTab;
}
Krms = sqrt(Kr *Kr + Ki * Ki);
return(Krms);
}
const float costab1[17]=
{
1.0, //0
0.99518472, //1
0.98078528, //2
0.95694033, //3
0.92387953, //4
0.88192126, //5
0.83146961, //6
0.77301046, //7
0.70710679, //8
0.63439329, //9
0.55557024, //10
0.47139675, //11
0.38268345, //12
0.29028469, //13
0.19509034, //14
0.09801716, //15
0.0 //16
};
const float sintab1[17]=
{
0.0, //0
0.09801714, //1
0.19509032, //2
0.29028467, //3
0.38268343, //4
0.47139673, //5
0.55557023, //6
0.63439328, //7
0.70710678, //8
0.77301045, //9
0.83146961, //10
0.88192126, //11
0.92387953, //12
0.95694033, //13
0.98078528, //14
0.99518472, //15
1.0 //16
};
const float costab3[17]=
{
1.0,
0.95694034, //1
0.83146961, //2
0.63439328, //3
0.38268343, //4
0.09801714, //5
-0.19509032, //6
-0.47139673, //7
-0.70710678, //8
-0.88192126, //9
-0.98078528, //10
-0.99518472, //11
-0.92387953, //12
-0.77301045, //13
-0.55557023, //14
-0.29028467, //15
0.0 //16
};
const float sintab3[17]=
{
0.0, //0
0.29028468, //1
0.55557023, //2
0.77301045, //3
0.92387953, //4
0.99518473, //5
0.98078528, //6
0.88192126, //7
0.70710678, //8
0.47139674, //9
0.19509032, //10
-0.09801710, //11
-0.38268340, //12
-0.63439330, //13
-0.83146961, //14
-0.95694034, //15
-1.0 //16
};
const float costab5[17]=
{
1.0, //0
0.88192126, //1
0.555568324, //2
0.09801714, //3
-0.38268343, //4
-0.77301045, //5
-0.98078528, //6
-0.95694033, //7
-0.70710678, //8
-0.29028468, //9
0.195090322, //10
0.634393284, //11
0.923879532, //12
0.995184726, //13
0.831469612, //14
0.471396737, //15
0.0 //16
};
const float sintab5[17]=
{
0.0, //0
0.47139674, //1
0.83146961, //2
0.99518473, //3
0.92387953, //4
0.63439328, //5
0.19509032, //6
-0.29028468, //7
-0.70710678, //8
-0.95694034, //9
-0.98078528, //10
-0.77301045, //11
-0.38268343, //12
0.098017140, //13
0.555570233, //14
0.881921264, //15
1.0 //16
};
const float costab7[17]=
{
1.0, //0
0.77301045, //1
0.19509032, //2
-0.47139674, //3
-0.92387953, //4
-0.95694034, //5
-0.55557023, //6
0.098017140, //7
0.707106781, //8
0.995184727, //9
0.831469612, //10
0.290284677, //11
-0.382683430, //12
-0.881921264, //13
-0.980785280, //14
-0.634393284, //15
0.0 //16
};
const float sintab7[17]=
{
0.0, //0
0.63439328, //1
0.98078528, //2
0.88192126, //3
0.38268343, //4
-0.29028468, //5
-0.83146961, //6
-0.99518473, //7
-0.70710678, //8
-0.09801714, //9
0.55557023, //10
0.95694034, //11
0.92387953, //12
0.47139674, //13
-0.19509030, //14
-0.77301045, //15
-1.0 //16
};
//9
const float costab9[17]=
{
1.0, //0
0.63439328, //1
-0.19509032, //2
-0.88192126, //3
-0.92387953, //4
-0.29028468, //5
0.55557023, //6
0.99518473, //7
0.70710678, //8
-0.09801714, //9
-0.83146961, //10
-0.95694034, //11
-0.38268343, //12
0.47139674, //13
0.98078528, //14
0.77301045, //15
0.0 //16
};
const float sintab9[17]=
{
0.0, //0
0.77301045, //1
0.98078528, //2
0.47139674, //3
-0.38268343, //4
-0.95694034, //5
-0.83146961, //6
-0.09801714, //7
0.70710678, //8
0.99518473, //9
0.55557023, //10
-0.29028468, //11
-0.92387953, //12
-0.88192126, //13
-0.19509032, //14
0.63439328, //15
1.0 //16
};
//11
const float costab11[17]=
{
1.0, //0
0.47139674, //1
-0.5555702, //2
-0.99518473, //3
-0.38268343, //4
0.63439328, //5
0.98078528, //6
0.29028467, //7
-0.70710678, //8
-0.95694033, //9
-0.19509032, //10
0.77301045, //11
0.92387953, //12
0.09801714, //13
-0.83146961, //14
-0.88192126, //15
0.0 //16
};
const float sintab11[17]=
{
0.0, //0
0.88192126, //1
0.83146961, //2
-0.09801714, //3
-0.92387953, //4
-0.77301045, //5
0.19509032, //6
0.95694034, //7
0.70710678, //8
-0.29028468, //9
-0.98078528, //10
-0.63439328, //11
0.38268343, //12
0.99518473, //13
0.55557023, //14
-0.47139674, //15
-1.0 //16
};
//13
const float costab13[17]=
{
1.0, //0
0.29028468, //1
-0.83146961, //2
-0.77301045, //3
0.38268343, //4
0.99518472, //5
0.19509032, //6
-0.88192126, //7
-0.70710678, //8
0.47139674, //9
0.98078528, //10
0.09801714, //11
-0.92387953, //12
-0.63439328, //13
0.55557023, //14
0.95694033, //15
0.0 //16
};
const float sintab13[17]=
{
0.0, //0
0.95694034, //1
0.55557023, //2
-0.63439328, //3
-0.92387953, //4
0.09801714, //5
0.98078528, //6
0.47139673, //7
-0.70710678, //8
-0.88192126, //9
0.19509032, //10
0.99518473, //11
0.38268343, //12
-0.77301045, //13
-0.83146961, //14
0.29028468, //15
1.0 //16
};
//15
const float costab15[17]=
{
1.0, //0
0.09801714, //1
-0.98078528, //2
-0.29028468, //3
0.92387953, //4
0.47139674, //5
-0.83146961, //6
-0.63439328, //7
0.70710678, //8
0.77301045, //9
-0.55557023, //10
-0.88192126, //11
0.38268343, //12
0.95694034, //13
-0.19509032, //14
-0.99518473, //15
0.0 //16
};
const float sintab15[17]=
{
0.0, //0
0.99518473, //1
0.19509032, //2
-0.95694034, //3
-0.38268343, //4
0.88192126, //5
0.55557023, //6
-0.77301045, //7
-0.70710678, //8
0.63439328, //9
0.83146961, //10
-0.47139674, //11
-0.92387953, //12
0.29028468, //13
0.98078528, //14
-0.09801714, //15
-1.0 //16
}; |
|