Heu mon besoin n'a strictement aucun rapport avec les TIs hein
Je mettrais le code en question bientot
Mon code (qui a 1ans 1/2 qui date d'un projet foireux : )
/**************************************
** DFT **
** **
** TransformÈ de fourier discrËte **
In:
- s : Pointeur vers une structure signal
Out:
- Nothing
**************************************/
TANGUY_DLL_API void DFT(Signal *s /* int MAX_TRIG */)
{
double PtsA[MAX_TRIG], PtsB[MAX_TRIG];
double Ap,Bp,A,Phi;
char tmp[10];
int i,j;
if ( TableInited == 0 )
{ /* Si non gÈnÈrÈ : */
j = 0;
/* gÈnÈration des table sin et cos */
for ( i = 360 ; i > 0 ; i -= (360 / MAX_TRIG) )
{
tCos[j] = Round( cos(Deg2Rad(i)) , 10000 );
tSin[j++] = Round( sin(Deg2Rad(i)) , 10000 );
}
TableInited = 1;
}
/* On efface la zone d'affichage */
clear_bitmap(Buffer);
hline(Buffer,0,ScreenHeight-20,ScreenWidth,255);
vline(Buffer,0,0,ScreenHeight,255);
for ( i = ScreenHeight - 20 ; i > 0 ; i -= 30 )
putpixel(Buffer,1,i,255);
for ( i = 1 ; i < MAX_TRIG ; i ++ )
{
j = i*(ScreenWidth/MAX_TRIG);
putpixel(Buffer,j,ScreenHeight-19,255);
sprintf(tmp,"%d",i);
textout_centre(Buffer, font, tmp, j,ScreenHeight-18,255);
}
for ( i = 0 ; i < MAX_TRIG ; i ++ )
{
/* i : harmonique a tester
0 = fondamentale
*/
/* Selection des points a utiliser */
for ( j = 0 ; j < MAX_TRIG ; j ++ )
{
PtsA[j] = tSin[(j*(i+1))%MAX_TRIG];
PtsB[j] = tCos[(j*(i+1))%MAX_TRIG];
}
Ap = 0; Bp = 0;
for ( j = 0 ; j < MAX_TRIG ; j ++ )
{
Ap += PtsA[j%MAX_TRIG] * s->sign[j];
Bp += PtsB[j%MAX_TRIG] * s->sign[j];
}
Ap /= MAX_TRIG;
Bp /= MAX_TRIG;
A = sqrt(pow(Ap,2)+pow(Bp,2)) * 2; // A/2 = racine(A'? + B'?)
/*
B' = A/2 sin(Phi)
donc
(A/2) / B' = sin(Phi)
donc
Phi = asin((A/2)/B')
*/
Phi = asin((A/2.0)/Bp);
j = i*(ScreenWidth/MAX_TRIG);
line(Buffer,j,ScreenHeight-19,j,ScreenHeight-19-(int)(30*A),4);
}
AfficheBuffer();
}