Hello, I've put online some easy to read FFT C code here: Maybe usefull for self contained project not striving the level of performance you can get with FFTW or Intel libs. http://www.philou.ch/libdsp.html It has an awfull hungarian-like notation used all other the place, aaahem when you're a beginner in C... ugly, but otherwise very easy to read code. Regards.
some old, easy to read, FFT code of mine
Started by ●January 20, 2012
Reply by ●January 20, 20122012-01-20
Philippe Strauss wrote:> Hello, > > I've put online some easy to read FFT C code here: > > Maybe usefull for self contained project not striving the level of > performance you can get with FFTW or Intel libs. > > http://www.philou.ch/libdsp.html > It has an awfull hungarian-like notation used all other the place, > aaahem when you're a beginner in C... ugly, but otherwise very easy to > read code.Here is an ABC textbook implementation of FFT for my little friend. It is several times slower compared to FFTW, however it takes only about 50 lines of code. There is nothing wrong with the textbooks. void fft(float *x,float *y,int order,int param) { unsigned int n,l,e,f,i,j,o,o1,k; float u,v,z,c,s,p,q,r,t,w,a; n=1u<<order; for(l=1;l<=order;l++) { u=1.0f; v=0.0f; e=1u<<(order-l+1); f=e/2; z=M_PI/f; c = cosf(z); s = sinf(z); if(param==FFT) s=-s; for(j=1;j<=f;j++) { for(i=j;i<=n;i+=e) { o=i+f-1; o1=i-1; p=x[o1]+x[o]; r=x[o1]-x[o]; q=y[o1]+y[o]; t=y[o1]-y[o]; x[o]=r*u-t*v; y[o]=t*u+r*v; x[o1]=p; y[o1]=q; } w=u*c-v*s; v=v*c+u*s; u=w; } } j=1; for(i=1;i<n;i++) { if(i<j) { p=x[j-1]; q=y[j-1]; x[j-1]=x[i-1]; y[j-1]=y[i-1]; x[i-1]=p; y[i-1]=q; } k=n/2; while(k<j) { j=j-k; k=k/2; } j+=k; } if(param!=FFT) { a=1.0f/n; for(k=0;k<n;k++) { x[k]*=a; y[k]*=a; } } } //============ VLV
Reply by ●January 20, 20122012-01-20
Vladimir, did you mom fed you dog food? Why do you need, as an human being, to bark like this on EVERY post on comp.dsp, every single post. You're such an asshole, must be terrible to try to live in your surrounding, hope you have no wife and children. Problem with your penis? Unbelievable. You need to get a life, to learn how to live.
Reply by ●January 21, 20122012-01-21
On 1/20/2012 3:52 PM, Philippe Strauss wrote:> > Vladimir, did you mom fed you dog food? > > Why do you need, as an human being, to bark like this on EVERY post on > comp.dsp, every single post. > > You're such an asshole, must be terrible to try to live in your > surrounding, hope you have no wife and children. > > Problem with your penis? > > Unbelievable. You need to get a life, to learn how to live.Philippe, I agree that Vladimir can be unpleasantly caustic, but usually when a (perhaps milder) caustic comment is called for. Having been a guest in his house and at his table, I can assure you that your assumptions about his domestic arrangements are quite wrong. He posted complete (and I presume accurate) code for performing an FFT and described its limitation. What about that do you find objectionable? Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●January 25, 20122012-01-25
On Fri, 20 Jan 2012 14:11:51 -0600, Vladimir Vassilevsky <nospam@nowhere.com> wrote:> > >Philippe Strauss wrote: > >> Hello, >> >> I've put online some easy to read FFT C code here: >> >> Maybe usefull for self contained project not striving the level of >> performance you can get with FFTW or Intel libs. >> >> http://www.philou.ch/libdsp.html >> It has an awfull hungarian-like notation used all other the place, >> aaahem when you're a beginner in C... ugly, but otherwise very easy to >> read code. > >Here is an ABC textbook implementation of FFT for my little friend. It >is several times slower compared to FFTW, however it takes only about 50 >lines of code. There is nothing wrong with the textbooks. > >[snip] I really like it when people post code no matter what. Glad to see your post and the OP. Thanks, Mark DeArman