@@ -9,79 +9,19 @@ class FastFourierTransformTestPatch : public Patch {
99 int passed;
1010 int failed;
1111 int fftsize;
12- FastFourierTransform fftArm;
13- FastFourierTransform fftGeneric;
14- bool assertt (float first, float second, const char *message){ // assert with tolerance
15- bool cond=false ;
16- float tol=0.0000001 ;
17- if (abs (second-first)<tol){
18- cond=true ;
19- }
20- assert (cond, message);
21- }
22- bool assert (bool condition,const char * message){
23- assert (condition, message, -1 );
24- }
25- bool assert (bool condition,const char * message, int n){
26- if (condition==false && success==true ){ // only hit this the first time, so only the first failed assertion gets displayed
27- success=false ;
28- if (n>=0 )
29- debugMessage (message, n);
30- else
31- debugMessage (message);
32- ASSERT (condition, message); // this actually causes the program to exit and the LED to turn red
33- // but if you comment out the line above you can get nice acoustic feedback instead (sinewave for success, noise for error)
34- failed++;
35- } else {
36- passed++;
37- }
38- return condition;
39- }
12+ FastFourierTransform fft;
4013 ComplexFloatArray fd;
4114public:
4215 FastFourierTransformTestPatch (){
43- registerParameter (PARAMETER_A, " Toggle FFT method" );
44- // success=true;
45- // passed=0;
46- // failed=0;
4716 fftsize=getBlockSize ();
48- fftArm.init (fftsize);
49- fftGeneric.init (fftsize);
17+ fft.init (fftsize);
5018 fd=ComplexFloatArray::create (fftsize);
51- // FastFourierTransform fftArm;
52- // FastFourierTransformGeneric fftGeneric;
53- // fftArm.init(fftsize);
54- // fftGeneric.init(fftsize);
5519
5620 };
5721 void processAudio (AudioBuffer &buffer){
5822 FloatArray td=buffer.getSamples (0 );
59- if (getParameterValue (PARAMETER_A)>0.5 ){
60- debugMessage (" generic" );
61- fftGeneric.fft (td,fd);
62- fftGeneric.ifft (fd,td);
63- } else {
64- debugMessage (" arm" );
65- fftArm.fft (td,fd);
66- fftArm.ifft (fd,td);
67- }
68- td.scale (0.2 );
69-
70- /*
71- float *sig=buffer.getSamples(0);
72- if(success==false){
73- for(int n=0; n<getBlockSize(); n++){
74- sig[n]+=0.05*rand()/(float)RAND_MAX;
75- }
76- } else {
77- static float phase=0;
78- float inc=2*M_PI/200.0f;
79- for(int n=0; n<getBlockSize(); n++){
80- sig[n]+=0.2*sinf(phase);
81- phase+=inc;
82- phase= phase>2*M_PI ? phase-2*M_PI : phase;
83- }
84- }*/
23+ fft.fft (td,fd);
24+ fft.ifft (fd,td);
8525 }
8626};
8727
0 commit comments