annotate tools/audio_processor_test/gen_tone/gen_tone.cpp @ 50:2b18894f75e2
pygar svn.51
[svn r51] fixed processor- it works
author |
punk |
date |
Wed, 05 May 2010 15:19:32 -0400 |
parents |
90197e3375e2 |
children |
|
rev |
line source |
rlm@23
|
1 #include <stdio.h>
|
rlm@23
|
2 #include <assert.h>
|
rlm@23
|
3 #include <string.h>
|
rlm@23
|
4 #include <sndfile.h>
|
rlm@23
|
5 #include <stdlib.h>
|
rlm@23
|
6 #include "SndfileWavUtil.h"
|
rlm@23
|
7
|
rlm@23
|
8 // foreward declaration. This is defined in DFT.cpp
|
rlm@23
|
9 int DFT(int dir,int m,double *x1,double *y1);
|
rlm@23
|
10
|
rlm@23
|
11 const int Points = 8;
|
rlm@23
|
12
|
rlm@23
|
13 int
|
rlm@23
|
14 do_gen (int argc, char * argv [])
|
rlm@23
|
15 {
|
rlm@23
|
16 int frames;
|
rlm@23
|
17 int targ_freqA;
|
rlm@23
|
18 int targ_freqB;
|
rlm@23
|
19 char* refWavFile;
|
rlm@23
|
20 char* outWavFile;
|
rlm@23
|
21 FILE* outPCM;
|
rlm@23
|
22 const int short_sz = sizeof(short int);
|
rlm@23
|
23
|
rlm@23
|
24 frames = atoi(argv[1]);
|
rlm@23
|
25 targ_freqA = atoi(argv[2]);
|
rlm@23
|
26 targ_freqB = atoi(argv[3]);
|
rlm@23
|
27 refWavFile = argv[4];
|
rlm@23
|
28 outWavFile = argv[5];
|
rlm@23
|
29
|
rlm@23
|
30 outPCM = fopen("output.pcm", "w");
|
rlm@23
|
31
|
rlm@23
|
32 printf("targ_freqA %d\ntarg_freqB %d\nframes %d\n", targ_freqA, targ_freqB, frames);
|
rlm@23
|
33
|
rlm@23
|
34 while(frames-- > 0){
|
rlm@23
|
35
|
rlm@23
|
36 double dreal[Points];
|
rlm@23
|
37 double dimag[Points];
|
rlm@23
|
38
|
rlm@23
|
39 for(int i = 0; i < Points; i++)
|
rlm@23
|
40 dreal[i] = (i == targ_freqA) ? 1000 : (i == targ_freqB) ? 1000 : 0;
|
rlm@23
|
41 for(int i = 0; i < Points; i++)
|
rlm@23
|
42 dimag[i] = 0.0;
|
rlm@23
|
43
|
rlm@23
|
44 DFT(-1,Points,dreal,dimag);
|
rlm@23
|
45
|
rlm@23
|
46 for(int i = 0; i < Points; i++){
|
rlm@23
|
47 short int rv = (int)dreal[i];
|
rlm@23
|
48 assert(fwrite(&rv,short_sz,1,outPCM));
|
rlm@23
|
49 }
|
rlm@23
|
50
|
rlm@23
|
51 }
|
rlm@23
|
52
|
rlm@23
|
53 fclose(outPCM);
|
rlm@23
|
54
|
rlm@23
|
55 generate_wav("output.pcm", refWavFile, outWavFile);
|
rlm@23
|
56 }
|
rlm@23
|
57
|
rlm@23
|
58 int
|
rlm@23
|
59 main(int argc, char* argv[])
|
rlm@23
|
60 {
|
rlm@23
|
61 do_gen(argc, argv);
|
rlm@23
|
62 exit(1);
|
rlm@23
|
63 }
|