Laetire.cpp
862 Bytes
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
46
47
48
#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*5
int main(int argc, char **argv)
{
float pi=3.141592;
WavData w;
char *data = new char[SIZE];
char *data2 = new char[SIZE*2];
int i,j=0;
//Creation de la données
for(i=0;i<SIZE;i++){
float wla=2.0*3.14*FREQLA;
float t=(float)i/FREQ;
data[i]=AMPLITUDE*(1+sin(wla*t));
}
for(i=0;i<SIZE;i++){
data2[j]=data[i];
data2[j+1]=data[i];
j=j+2;
}
//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*2);
w.setData(data2);
w.save("laetire.WAV");
}