Blame view

strech/timestrechcow.cpp 1.34 KB
6a961b68   rsimonin   modifications
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
  #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*2
  
  
  int main(int argc, char **argv)
  {
  //Definition variables
      int i;
  	float pi=3.141592;
  	WavData w;
  	w.load("COW.WAV");
  	char *data = w.data();
      double test[w.datasize()*2][2];
  	double test1[w.datasize()*2][2];
  	double test2[w.datasize()*2][2];
  	double test3[w.datasize()*2][2];
  	
  	
      printf("===Création data\n");
  //Creation de la donnée
  	char *data2 = new char[w.datasize()*2];
  	printf("===load success\n");
  
  	for(i=0;i<w.datasize();i++){
  		test[i][0]=(double)data[i];
  		test[i][1]=0;
      }
  	
  //FFT
  	printf("===fft\n");
  	fft(32768*2,test,test2);
  
  //Modification dans le domaine fréquentiel
  	printf("===modif freq\n");
  	for(i=1;i<w.datasize()+1;i++){
  		int x=i-1;
6a961b68   rsimonin   modifications
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  
  		test3[2*x][0]=test2[x][0];
  		test3[2*x+1][0]=test2[x][0];
  		test3[2*x][1]=0;
          test3[2*x+1][1]=0;
  	}
  	
  //FFT inverse
  	printf("===ifft\n");
  	ifft(32768*2,test1,test3);
  
  //Récupération des données
  	for(i=0;i<w.datasize();i++){
  		data2[i]=test1[i][0];
  	}
  
  //Preapation format final
  	w.setAudioFormat(1);
  	w.setNbrChanel(1);
  	w.setFrequency(FREQ);
  	w.setBytePerBloc(4);
  	w.setBytePerSec(FREQ);
  	w.setBitsPerSample(8);
  	w.clearData();
  	
  	w.setDatasize(w.datasize());
  	w.setData(data2);
  	w.save("strechcow.WAV");
  
  }