Changeset 1132:0e464c838627 in roaraudio
- Timestamp:
- 01/20/09 17:57:54 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarfctest.c
r1103 r1132 31 31 #include <libroardsp/libroardsp.h> 32 32 33 int main ( void) {33 int main (int argc, char * argv[]) { 34 34 int rate = ROAR_RATE_DEFAULT; 35 35 int bits = 16; … … 42 42 int16_t amp = 32767; 43 43 int i; 44 char * k; 44 45 int32_t tmp; 45 46 int16_t out[1024]; … … 51 52 struct roardsp_filter filt[3]; 52 53 struct roar_stream stream[1]; 54 FILE * rmsout = NULL; 55 int kill_var; 56 #ifdef ROAR_HAVE_BIN_GNUPLOT 57 int do_gnuplot = 0; 58 #endif 59 60 for (i = 1; i < argc; i++) { 61 k = argv[i]; 62 kill_var = 1; 63 64 if ( !strcmp(k, "--rate") ) { 65 rate = atoi(argv[++i]); 66 #ifdef ROAR_HAVE_BIN_GNUPLOT 67 } else if ( !strcmp(k, "--gnuplot") ) { 68 do_gnuplot = 1; 69 #endif 70 } else if ( !strcmp(k, "--rmsout") ) { 71 rmsout = fopen(argv[++i], "w"); 72 } else { 73 kill_var = 0; 74 } 75 76 if ( kill_var ) 77 *k = 0; 78 } 79 80 #ifdef ROAR_HAVE_BIN_GNUPLOT 81 if ( do_gnuplot && rmsout == NULL ) { 82 if ( (rmsout = popen(ROAR_HAVE_BIN_GNUPLOT, "w")) != NULL ) { 83 fprintf(rmsout, "set grid\n"); 84 fprintf(rmsout, "set log x 10\n"); 85 fprintf(rmsout, "set log y 10\n"); 86 fprintf(rmsout, "plot \"-\" with lines title \"filter amplification\"\n"); 87 } 88 } 89 #endif 53 90 54 91 if ( roar_stream_new(stream, rate, channels, bits, codec) == -1 ) 55 92 return 2; 56 93 57 if ( roardsp_filter_init(filt, stream, ROARDSP_FILTER_ LOWP) == -1 ) {94 if ( roardsp_filter_init(filt, stream, ROARDSP_FILTER_DCBLOCK) == -1 ) { 58 95 ROAR_ERR("main(*): roardsp_filter_init() failed: errno=%s(%i)", strerror(errno), errno); 59 96 return 1; 60 97 } 61 98 99 /* 62 100 freq = 1000; 63 101 roardsp_filter_ctl(filt, ROARDSP_FCTL_FREQ, &freq); 102 */ 64 103 65 104 if ( roardsp_filter_init(filt+1, stream, ROARDSP_FILTER_HIGHP) == -1 ) { … … 89 128 fprintf(stderr, "Starting analysis in frequency domain...\n"); 90 129 91 for (freq = 1/* 2*exp(1) */; freq < (float)rate/2; freq *= (1+exp(1)/100), length /= (1+exp(1)/100)) {130 for (freq = 1/* 2*exp(1) */; freq < /* (float)rate/2 */ 100; freq *= (1+exp(1)/100), length /= (1+exp(1)/100)) { 92 131 step = M_PI*2*freq/rate; 93 132 maxval = -amp; … … 124 163 125 164 printf("%f: %f %u %f\n", freq, (float)maxval/maxval_in, sc, rms); 165 166 if ( rmsout != NULL ) 167 fprintf(rmsout, "%f: %f\n", freq, rms); 126 168 } 169 127 170 128 171 fprintf(stderr, "Finished analysis in frequency domain: done tests on a total of %u samples on %i frequencies\n", … … 130 173 131 174 roardsp_fchain_uninit(fc); 175 176 if ( rmsout != NULL ) 177 fclose(rmsout); 132 178 133 179 return 0;
Note: See TracChangeset
for help on using the changeset viewer.