pur.cpp 904 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*10


int main(int argc, char **argv)
{
	float pi=3.141592;
	WavData w;
	char *data = new char[SIZE];
	char *data2 = new char[SIZE];
    int i;

	//Creation de la données
	for(i=0;i<SIZE;i++){
		float wla=2.0*3.14*FREQLA;
		float wdo=2.0*3.14*FREQDO;
		float t=(float)i/FREQ;

		data[i]=AMPLITUDE*(1+sin(wla*t));
		data2[i]=AMPLITUDE*(1+sin(wdo*t));
    }

	//setup du format audio de sortie
	w.setAudioFormat(1);
	w.setNbrChanel(1);
	w.setFrequency(FREQ);
	w.setBytePerBloc(4);
	w.setBytePerSec(FREQ);
	w.setBitsPerSample(8);
	w.clearData();
	
	//implémentation des données de sortie
	w.setDatasize(SIZE);
	w.setData(data);
	w.save("purla.WAV");

	w.clearData();
	w.setDatasize(SIZE);
	w.setData(data2);
	w.save("purdo.WAV");

}