fftcow.cpp 894 Bytes
#include <iostream>
#include "wavdata.h"
#include "fft.h"
#include <math.h>


#define FREQ 22400
#define AMPLITUDE 10
#define FREQDO 261
#define FREQLA	440
#define SIZE FREQ*4


int main(int argc, char **argv)
{
	float pi=3.141592;
	WavData w;
	
	double test[SIZE][2];
	double test1[SIZE][2];
	double test2[SIZE][2];

	char *data = new char[SIZE];
	char *data2 = new char[SIZE];

    int i;
	for(i=0;i<SIZE;i++){
		float w=2.0*3.14*FREQLA;
		float t=(float)i/FREQ;

		data[i]=AMPLITUDE*(1+sin(w*t));

		test[i][0]=(double)data[i];
		test[i][1]=(double)data[i];
    }

	fft(32768*2,test,test2);
	
	ifft(32768*2,test1,test2);

	for(i=0;i<SIZE;i++){
		data2[i]=test1[i][0];
	}

	w.setAudioFormat(1);
	w.setNbrChanel(1);
	w.setFrequency(FREQ);
	w.setBytePerBloc(4);
	w.setBytePerSec(FREQ);
	w.setBitsPerSample(8);
	w.clearData();
	
	w.setDatasize(SIZE);
	w.setData(data2);
	w.save("cowfft.WAV");

}