Blame view

main.cpp 1.85 KB
8a202cc2   eishchuk   Initial commit
1
2
3
4
5
6
  #include <iostream>
  #include "wavdata.h"
  #include "fft.h"
  #include <math.h>
  
  #define DELAY 5000
88c1f94c   eishchuk   Add notes
7
  #define TOUCH 35000
8a202cc2   eishchuk   Initial commit
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
46
47
  #define AMPLITUDE 0.5
  
  int main(int argc, char **argv)
  {
  	/*WavData w;
      char * name = "COW.WAV";
  	w.load(name);
  
  	char *data = w.data();
  	char *data2 = new char[w.datasize()*2];
  
  	int i;
  	for(i=0;i<w.datasize();i++)
  		data2[i]=data[i];
  	for(;i<w.datasize()*2;i++)
  		data2[i]=128;
  
  	for(int i=DELAY;i<2*w.datasize();i++)
  	{
  		float value = (float)(unsigned char)data2[i-DELAY]-128.0;
  		value = value * AMPLITUDE;
  		int val = (unsigned int)value + (unsigned char)data2[i];
  		if(val>255)val=255;
  		if(val<0)val=0;
  
  		data2[i]= (unsigned char)(unsigned int)val;
  	}
  
  	w.clearData();
  	w.setDatasize(w.datasize()*2);
  	w.setData(data2);
  
      char * name_save = "COW_d.WAV";
  	w.save(name_save);*/
      
      
      // recréer une note ) partir du son de la vache
      
      WavData note_do;
      note_do.load("COW.WAV");
88c1f94c   eishchuk   Add notes
48
49
50
51
52
      
      printf("Frequency : %d\n", note_do.frequency());
      
      
      
8a202cc2   eishchuk   Initial commit
53
54
55
56
57
58
59
60
      char * data_do = note_do.data();
      
      // TOUCH = durée d'une note
      int size = note_do.datasize();
      if (size > TOUCH) size = TOUCH;
      
      // changer le son pour avoir une note approprié
      
88c1f94c   eishchuk   Add notes
61
      /*int i;
8a202cc2   eishchuk   Initial commit
62
63
      for (i = 0; i < size ; i++) {
          data_do[i] = i;
88c1f94c   eishchuk   Add notes
64
      }*/
8a202cc2   eishchuk   Initial commit
65
66
67
      
      // assign new data & save
      
88c1f94c   eishchuk   Add notes
68
69
70
71
      //note_do.clearData();
      note_do.setDatasize(TOUCH);
      note_do.setFrequency(16744);
      //note_do.setData(data_do);
8a202cc2   eishchuk   Initial commit
72
73
74
      
      note_do.save("DO.WAV");
      
88c1f94c   eishchuk   Add notes
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
      note_do.setFrequency(18794);
      note_do.save("RE.WAV");
      
      note_do.setFrequency(21096);
      note_do.save("MI.WAV");
      
      note_do.setFrequency(22350);
      note_do.save("FA.WAV");
      
      note_do.setFrequency(25087);
      note_do.save("SOL.WAV");
      
      note_do.setFrequency(28160);
      note_do.save("LA.WAV");
      
      note_do.setFrequency(31608);
      note_do.save("SI.WAV");
      
8a202cc2   eishchuk   Initial commit
93
94
      
  }