/************ * Includes * *********/ #include #include #include #include "sndbuf_config.h" #include "sndbuf_smart.h" /************* * Constants * **********/ //-- Geometry -- #define GEOM_FREQ 689.0625 #define GEOM_WAVELENGTH 64 #define GEOM_MICDIST 29 //-- Pattern -- #define PAT_CHAN 1 #define PAT_LEN 1024 //-- Memory -- #define SBUF_CHAN_MAX 2 #define SBUF_LEN_MAX 4096 /******** * Main *******/ int main(int argc, char** argv) { //-- Variable Declarations -- sndbuf_smart dat(SBUF_CHAN_MAX, SBUF_LEN_MAX);//The sound buffer we're working with sndbuf_smart pat(SBUF_CHAN_MAX, SBUF_LEN_MAX);//The pat we're filtering against double ang_r; //The angle of incidence, in radians double ang_d; //The angle of incidence, in degrees int iteration; //How many times have we run? time_t now; //What time is it now? //-- Generate pattern -- printf("Generating pat..."); pat.chan = PAT_CHAN; pat.samp = PAT_LEN; pat.gen_tone(ALL_CHAN, GEOM_FREQ); printf("\tdone.\n"); //-- Opening sound board -- dat.dsp_open(BUF_DEVICE); //-- Go! -- iteration=0; while(true) { //-- Capture Data -- dat.dsp_capture(); //-- Data -- dat.fir(pat); //-- Calculate the angle of incidence -- ang_r = dat.incidence_quick(0, 1, GEOM_WAVELENGTH, GEOM_MICDIST); //-- Did we get an intelligable result? -- if (0 == isnan(ang_r)) { //-- Convert to degrees -- ang_d = ang_r * 180 / M_PI; //-- What time is it? -- time(&now); //-- Output -- printf("%d - %d: Incidence:\t%f\n", (int)now, iteration, ang_d); } //-- Counter -- iteration++; } //-- Close sound board -- dat.dsp_close(); }