Skip to content

Commit d627273

Browse files
committed
Added warnings on fft documentations. Closes issue #11
1 parent af3cc5a commit d627273

2 files changed

Lines changed: 25 additions & 16 deletions

File tree

LibSource/FastFourierTransform.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FastFourierTransform {
3030
void ifft(ComplexFloatArray& in, FloatArray& out){
3131
ASSERT(in.getSize() >= getSize(), "Input array too small");
3232
ASSERT(out.getSize() >= getSize(), "Output array too small");
33-
arm_rfft_fast_f32(&instance, (float*)in, (float*)out, 1);
33+
arm_rfft_fast_f32(&instance, (float*)in, (float*)out, 1);
3434
}
3535
int getSize(){
3636
return instance.fftLenRFFT;
@@ -85,33 +85,37 @@ class FastFourierTransform {
8585

8686
/**
8787
* Perform the direct FFT.
88-
* @param[in] in The real-valued input array
89-
* @param[out] out The complex-valued output array
88+
* @param[in] input The real-valued input array
89+
* @param[out] output The complex-valued output array
90+
* @remarks Calling this method will mess up the content of the **input** array.
9091
* @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
9192
*/
92-
void fft(FloatArray& in, ComplexFloatArray& out){
93-
ASSERT(in.getSize() >= getSize(), "Input array too small");
94-
ASSERT(out.getSize() >= getSize(), "Output array too small");
93+
void fft(FloatArray& input, ComplexFloatArray& output){
94+
ASSERT(input.getSize() >= getSize(), "Input array too small");
95+
ASSERT(output.getSize() >= getSize(), "Output array too small");
9596
for(int n=0; n<getSize(); n++){
96-
temp[n].re=in[n];
97+
temp[n].re=input[n];
9798
temp[n].im=0;
9899
}
99-
kiss_fft(cfgfft, (kiss_fft_cpx*)(float*)temp.getData(), (kiss_fft_cpx*)(float*)out);
100+
kiss_fft(cfgfft, (kiss_fft_cpx*)(float*)temp.getData(), (kiss_fft_cpx*)(float*)output);
100101
}
101102

102103
/**
103104
* Perform the inverse FFT.
104-
* @param[in] in The complex-valued input array
105-
* @param[out] out The real-valued output array
105+
* The output is rescaled by 1/fftSize.
106+
* @param[in] input The complex-valued input array
107+
* @param[out] output The real-valued output array
108+
* @remarks Calling this method will mess up the content of the **input** array.
106109
* @note When built for ARM Cortex-M processor series, this method uses the optimized <a href="http://www.keil.com/pack/doc/CMSIS/General/html/index.html">CMSIS library</a>
110+
*
107111
*/
108-
void ifft(ComplexFloatArray& in, FloatArray& out){
109-
ASSERT(in.getSize() >= getSize(), "Input array too small");
110-
ASSERT(out.getSize() >= getSize(), "Output array too small");
111-
kiss_fft(cfgifft, (kiss_fft_cpx*)(float*)in, (kiss_fft_cpx*)(float*)temp.getData());
112+
void ifft(ComplexFloatArray& input, FloatArray& output){
113+
ASSERT(input.getSize() >= getSize(), "Input array too small");
114+
ASSERT(output.getSize() >= getSize(), "Output array too small");
115+
kiss_fft(cfgifft, (kiss_fft_cpx*)(float*)input, (kiss_fft_cpx*)(float*)temp.getData());
112116
float scale=1.0f/getSize();
113117
for(int n=0; n<getSize(); n++){
114-
out[n]=temp[n].re*scale;
118+
output[n]=temp[n].re*scale;
115119
}
116120
}
117121

TestPatches/FastFourierTransformTestPatch.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ class FastFourierTransformTestPatch : public Patch {
1111
int fftsize;
1212
FastFourierTransform fft;
1313
ComplexFloatArray fd;
14+
SuperSaw ss;
1415
public:
15-
FastFourierTransformTestPatch(){
16+
FastFourierTransformTestPatch(): ss(getSampleRate()){
17+
1618
fftsize=getBlockSize();
1719
fft.init(fftsize);
1820
fd=ComplexFloatArray::create(fftsize);
1921

2022
};
2123
void processAudio(AudioBuffer &buffer){
24+
ss.setFrequency(300);
2225
FloatArray td=buffer.getSamples(0);
26+
ss.getSamples(td);
2327
fft.fft(td,fd);
2428
fft.ifft(fd,td);
29+
td.scale(0.1);
2530
}
2631
};
2732

0 commit comments

Comments
 (0)