~ubuntu-branches/ubuntu/quantal/python-pyo/quantal

« back to all changes in this revision

Viewing changes to src/engine/fft.c

  • Committer: Package Import Robot
  • Author(s): Tiago Bortoletto Vaz
  • Date: 2012-07-03 23:45:41 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120703234541-jh5jg00lvljnwq8m
Tags: 0.6.2-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
**  Original file can be found on musicdsp.org :
19
19
**  http://www.musicdsp.org/archive.php?classid=2#79
20
20
****************************************************** */
21
 
 
22
 
//#include <stdlib.h>
23
21
#include "fft.h"
24
22
#include "pyomodule.h"
25
23
#include <math.h>
32
30
    MYFLT a = e;
33
31
    MYFLT a3;
34
32
    for(j=2; j<=n8; j++) {
35
 
        //j1 = j - 1;
36
33
        a3 = 3 * a;
37
34
        twiddle[0][j-1] = MYCOS(a);
38
35
        twiddle[1][j-1] = MYSIN(a);
113
110
            n4 = n2 >> 2;
114
111
            n8 = n2 >> 3;
115
112
            pas = n / n2;
116
 
            //e = 2 * PI / n2;
117
113
            i1 = 0;
118
114
            id = n2 << 1;
119
115
            do { 
142
138
                i1 = id - n2;
143
139
                id <<= 1;
144
140
            } while ( i1<n );
145
 
            //a = e;
146
141
            for (j=2; j<=n8; j++){ 
147
142
                pos = (j-1) * pas;
148
143
                cc1 = twiddle[0][pos];
149
144
                ss1 = twiddle[1][pos];
150
145
                cc3 = twiddle[2][pos];
151
146
                ss3 = twiddle[3][pos]; 
152
 
                //a3 = 3 * a;
153
 
                //cc1 = cos(a);
154
 
                //ss1 = sin(a);
155
 
                //cc3 = cos(a3);
156
 
                //ss3 = sin(a3);
157
 
                //a = j * e;
158
147
                i = 0;
159
148
                id = n2 << 1;
160
149
                do {
230
219
            n4 = n2 >> 2;
231
220
            n8 = n2 >> 3;
232
221
            pas = n / n2;
233
 
            //e = 2 * PI / n2;
234
222
            i1 = 0;
235
223
            do { 
236
224
                for (; i1<n; i1+=id) {
259
247
                i1 = id - n2;
260
248
                id <<= 1;
261
249
            } while ( i1<n1 );
262
 
            //a = e;
263
250
            for (j=2; j<=n8; j++) {  
264
251
                pos = (j-1) * pas;
265
252
                cc1 = twiddle[0][pos];
266
253
                ss1 = twiddle[1][pos];
267
254
                cc3 = twiddle[2][pos];
268
255
                ss3 = twiddle[3][pos];
269
 
                //a3 = 3 * a;
270
 
                //cc1 = cos(a);
271
 
                //ss1 = sin(a);
272
 
                //cc3 = cos(a3);
273
 
                //ss3 = sin(a3);
274
 
                //a = j * e;
275
256
                i = 0;
276
257
                id = n2 << 1;
277
258
                do {
341
322
        outdata[i] = data[i];   
342
323
}
343
324
 
344
 
/* *************************************************** */
345
 
 
346
325
/* *****************************************************
347
326
** Decimation-in-freq radix-2 in-place butterfly
348
327
** data: array of doubles:
372
351
            for(angle=0; l1<ol2; l1+=2, l2+=2) {
373
352
                wr = twiddle[angle];
374
353
                wi = -twiddle[size+angle]; /* size here is half the FFT size */
375
 
                /*
376
 
                ang = 2 * PI * angle / size;
377
 
                wr = cos(ang);
378
 
                wi = -sin(ang);
379
 
                */
380
354
                xr = *l1 + *l2;
381
355
                xi = *(l1+1) + *(l2+1);
382
356
                dr = *l1 - *l2;
420
394
            for(angle=0; l1<ol2; l1+=2, l2+=2) {
421
395
                wr = twiddle[angle];
422
396
                wi = twiddle[size+angle]; /* size here is half the FFT size */
423
 
                /*
424
 
                ang = 2 * PI * angle / size;
425
 
                wr = cos(ang);
426
 
                wi = sin(ang);
427
 
                */
428
397
                xr = *l1;
429
398
                xi = *(l1+1);
430
399
                yr = *l2;