-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathNrSample .cpp
57 lines (38 loc) · 1.27 KB
/
NrSample .cpp
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
49
50
51
52
53
54
55
56
57
#include <string>
#include "DTLN_NR.h"
int main(int argc, char *argv[])
{
//lpszInputRecWave is a recording data
std::string lpszInputRecWave = std::string(argv[1]);
std::string lpszOutputWave = std::string(argv[2]);
FILE *lpoInputRecFile = NULL;
FILE *lpoOutputFile = NULL;
short *lpsInputRecSample = NULL;
short *lpsOutputSample = NULL;
int nReadSize, nFrameSize;
lpoInputRecFile = fopen(lpszInputRecWave.c_str(), "rb");
lpoOutputFile = fopen(lpszOutputWave.c_str(), "wb+");
DTLN_NR oDtln;
nFrameSize = oDtlnAec.Init();
lpsInputRecSample = new short[nFrameSize];
lpsOutputSample = new short[nFrameSize];
//Skip wave header
fread(lpsInputRecSample, 1, 44, lpoInputRecFile);
while (true)
{
nReadSize = fread(lpsInputRecSample, 1, nFrameSize * sizeof(short), lpoInputRecFile);
if (nReadSize <= 0)
break;
oDtln.Process(lpsInputRecSample, lpsOutputSample);
//write PCM
fwrite(lpsOutputSample, 1, nFrameSize * sizeof(short), lpoOutputFile);
}
fclose(lpoInputRecFile);
fclose(lpoOutputFile);
if (lpsInputRecSample != NULL)
delete[] lpsInputRecSample;
if (lpsOutputSample != NULL)
delete[] lpsOutputSample;
return 0;
}