This is an example of how to use the class. It transforms a sine tone stored in the .dat file and saves the in, out, and power_spectrum results of using the class
#include <fstream>
#include <iostream>
using namespace std;
#include <mffm/realFFT.H>
#include <stdlib.h>
#define INPUTFILE "sine.1000Hz.dat"
#define OUTPUTFILE "powerSpectrum.txt"
#define OUTPUTFILE1 "in.txt"
#define OUTPUTFILE2 "out.txt"
int main (void){
ifstream input(INPUTFILE);
ofstream output(OUTPUTFILE);
ofstream output1(OUTPUTFILE1);
ofstream output2(OUTPUTFILE2);
int count=0;
double var;
if (!input){
cout <<"input not opened !"<<endl;
exit(-1);
}
while (input >> var)
count++;
cout<<count<<" variables in file "<<INPUTFILE<<endl;
input.clear();
input.seekg(0);
for (int i=0; i<count; i++)
input.close();
for (int i=0; i<count; i++)
for (int i=0; i<(count+1)/2; i++){
output << fftData.
power_spectrum[i]<<
'\n';
}
output.close();
for (int i=0; i<count; i++){
output1 << fftData.
in[i]/count<<
'\n';
output2 << fftData.
out[i]<<
'\n';
}
output1.close();
output2.close();
return 0;
}
class realFFTData controls and manipulates fft data
fftw_real * in
the input, output and power_spectrum arrays
int compPowerSpec()
This function computes the power spectrum and returns the max bin.
class realFFT controls fftw plans and executes fwd/inv transforms
void invTransform()
Inverse transform the data (out to in)
void fwdTransform()
Forward transform the data (in to out)