Blame view

pur/pur.cpp 904 Bytes
6c227d28   rsimonin   premier push
1
2
3
4
5
  #include <iostream>
  #include "wavdata.h"
  #include "fft.h"
  #include <math.h>
  
6a961b68   rsimonin   modifications
6
  #define FREQ 22400
6c227d28   rsimonin   premier push
7
8
9
10
11
12
13
14
15
16
  #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;
6c227d28   rsimonin   premier push
17
18
  	char *data = new char[SIZE];
  	char *data2 = new char[SIZE];
6c227d28   rsimonin   premier push
19
      int i;
6a961b68   rsimonin   modifications
20
21
  
  	//Creation de la données
6c227d28   rsimonin   premier push
22
  	for(i=0;i<SIZE;i++){
6a961b68   rsimonin   modifications
23
24
  		float wla=2.0*3.14*FREQLA;
  		float wdo=2.0*3.14*FREQDO;
6c227d28   rsimonin   premier push
25
26
  		float t=(float)i/FREQ;
  
6a961b68   rsimonin   modifications
27
28
  		data[i]=AMPLITUDE*(1+sin(wla*t));
  		data2[i]=AMPLITUDE*(1+sin(wdo*t));
6c227d28   rsimonin   premier push
29
30
      }
  
6a961b68   rsimonin   modifications
31
  	//setup du format audio de sortie
6c227d28   rsimonin   premier push
32
33
34
35
36
37
38
39
  	w.setAudioFormat(1);
  	w.setNbrChanel(1);
  	w.setFrequency(FREQ);
  	w.setBytePerBloc(4);
  	w.setBytePerSec(FREQ);
  	w.setBitsPerSample(8);
  	w.clearData();
  	
6a961b68   rsimonin   modifications
40
  	//implémentation des données de sortie
6c227d28   rsimonin   premier push
41
42
43
44
  	w.setDatasize(SIZE);
  	w.setData(data);
  	w.save("purla.WAV");
  
6a961b68   rsimonin   modifications
45
46
47
48
49
  	w.clearData();
  	w.setDatasize(SIZE);
  	w.setData(data2);
  	w.save("purdo.WAV");
  
6c227d28   rsimonin   premier push
50
  }