view tools/audio_processor_test/gen_tone/gen_tone.cpp @ 53:2991344775f8 pygar svn.54

[svn r54] mixer integrated
author punk
date Sun, 09 May 2010 10:58:40 -0400
parents 90197e3375e2
children
line wrap: on
line source
1 #include <stdio.h>
2 #include <assert.h>
3 #include <string.h>
4 #include <sndfile.h>
5 #include <stdlib.h>
6 #include "SndfileWavUtil.h"
8 // foreward declaration. This is defined in DFT.cpp
9 int DFT(int dir,int m,double *x1,double *y1);
11 const int Points = 8;
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);
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];
30 outPCM = fopen("output.pcm", "w");
32 printf("targ_freqA %d\ntarg_freqB %d\nframes %d\n", targ_freqA, targ_freqB, frames);
34 while(frames-- > 0){
36 double dreal[Points];
37 double dimag[Points];
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;
44 DFT(-1,Points,dreal,dimag);
46 for(int i = 0; i < Points; i++){
47 short int rv = (int)dreal[i];
48 assert(fwrite(&rv,short_sz,1,outPCM));
49 }
51 }
53 fclose(outPCM);
55 generate_wav("output.pcm", refWavFile, outWavFile);
56 }
58 int
59 main(int argc, char* argv[])
60 {
61 do_gen(argc, argv);
62 exit(1);
63 }