Skip to content

Commit f5266e4

Browse files
committed
Added documentation for FastFourierTransform
1 parent 647f87a commit f5266e4

1 file changed

Lines changed: 50 additions & 7 deletions

File tree

LibSource/FastFourierTransform.h

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifndef __FastFourierTransform_h__
22
#define __FastFourierTransform_h__
33

4+
5+
/**
6+
* This class performs direct and inverse Fast Fourier Transform.
7+
*/
8+
49
#ifdef ARM_CORTEX
510
class FastFourierTransform {
611
private:
@@ -43,21 +48,47 @@ class FastFourierTransform {
4348
ComplexFloat *data;
4449
int size;
4550
public:
51+
/**
52+
* Default constructor.
53+
* Does **not** initialize the instance.
54+
* @remarks You need to call init(int size) before calling any other method
55+
*/
4656
FastFourierTransform() : data(NULL), size(0){}
47-
FastFourierTransform(int len){
48-
init(len);
57+
58+
/**
59+
* Construct and initialize the instance.
60+
* @param[in] aSize The size of the FFT
61+
* @remarks Only sizes of 32, 64, 128, 256, 512, 1024, 2048, 4096 are supported, due to limitations of the CMSIS library.
62+
* @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>
63+
*/
64+
FastFourierTransform(int aSize){
65+
init(aSize);
4966
}
67+
5068
~FastFourierTransform(){
5169
free(data);
5270
}
53-
void init(int len){
54-
ASSERT(len==32 || len ==64 || len==128 || len==256 || len==512 || len==1024 || len==2048 || len==4096, "Unsupported FFT size");
55-
cfgfft = kiss_fft_alloc(len, 0 , 0, 0);
56-
cfgifft = kiss_fft_alloc(len, 1,0, 0);
57-
size=len;
71+
72+
/**
73+
* Initialize the instance.
74+
* @param aSize The size of the FFT
75+
* @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>
76+
*/
77+
void init(int aSize){
78+
ASSERT(aSize==32 || aSize ==64 || aSize==128 || aSize==256 || aSize==512 || aSize==1024 || aSize==2048 || aSize==4096, "Unsupported FFT size");
79+
cfgfft = kiss_fft_alloc(aSize, 0 , 0, 0);
80+
cfgifft = kiss_fft_alloc(aSize, 1,0, 0);
81+
size=aSize;
5882
data=(ComplexFloat *)malloc(sizeof(ComplexFloat)*getSize());
5983
temp=ComplexFloatArray(data, getSize());
6084
}
85+
86+
/**
87+
* Perform the direct FFT.
88+
* @param[in] in The real-valued input array
89+
* @param[out] out The complex-valued output array
90+
* @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>
91+
*/
6192
void fft(FloatArray& in, ComplexFloatArray& out){
6293
ASSERT(in.getSize() >= getSize(), "Input array too small");
6394
ASSERT(out.getSize() >= getSize(), "Output array too small");
@@ -67,6 +98,13 @@ class FastFourierTransform {
6798
}
6899
kiss_fft(cfgfft, (kiss_fft_cpx*)(float*)temp.getData(), (kiss_fft_cpx*)(float*)out);
69100
}
101+
102+
/**
103+
* Perform the inverse FFT.
104+
* @param[in] in The complex-valued input array
105+
* @param[out] out The real-valued output array
106+
* @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>
107+
*/
70108
void ifft(ComplexFloatArray& in, FloatArray& out){
71109
ASSERT(in.getSize() >= getSize(), "Input array too small");
72110
ASSERT(out.getSize() >= getSize(), "Output array too small");
@@ -76,6 +114,11 @@ class FastFourierTransform {
76114
out[n]=temp[n].re*scale;
77115
}
78116
}
117+
118+
/**
119+
* Get the size of the FFT
120+
* @return The size of the FFT
121+
*/
79122
int getSize(){
80123
return size;
81124
}

0 commit comments

Comments
 (0)