#ifndef __ShortFastFourierTestPatch_hpp__
#define __ShortFastFourierTestPatch_hpp__
#include <stdlib.h>
#include <stdio.h>
#include "Patch.h"
#include "ShortFastFourierTransform.h"
void prettyPrint(ComplexShortArray X){
printf("[");
for(int n = 0; n < X.getSize(); ++n){
printf("%d + %di; ", X[n].re, X[n].im);
}
printf("];\n\n");
}
void prettyPrint(ShortArray x){
printf("[");
for(int n = 0; n < x.getSize(); ++n){
printf("%d; ", x[n]);
}
printf("];\n\n");
}
class ShortFastFourierTestPatch : public TestPatch {
private:
ShortFastFourierTransform transform;
ComplexShortArray X;
ShortArray x;
public:
ShortFastFourierTestPatch(){
int fftSize = 512;
transform.init(fftSize);
X = ComplexShortArray::create(fftSize);
x = ShortArray::create(fftSize);
for(int n = 0; n < x.getSize(); ++n){
x[n] = ((n * 4096) % 32768 ) - 16384;
}
transform.fft(x, X);
ShortArray data((int16_t*)X.getData(), X.getSize() * 2);
printf("Xc=");
prettyPrint(X);
transform.ifft(X, x);
x.shift(log2(fftSize));
printf("xc=");
prettyPrint(x);
}
~ShortFastFourierTestPatch(){
ComplexShortArray::destroy(X);
}
};
#endif