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