Changeset 1132:0e464c838627 in roaraudio


Ignore:
Timestamp:
01/20/09 17:57:54 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

do a bit to get roarfctest a useable tool

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarfctest.c

    r1103 r1132  
    3131#include <libroardsp/libroardsp.h> 
    3232 
    33 int main (void) { 
     33int main (int argc, char * argv[]) { 
    3434 int rate     = ROAR_RATE_DEFAULT; 
    3535 int bits     = 16; 
     
    4242 int16_t amp  = 32767; 
    4343 int      i; 
     44 char   * k; 
    4445 int32_t  tmp; 
    4546 int16_t  out[1024]; 
     
    5152 struct roardsp_filter      filt[3]; 
    5253 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 
    5390 
    5491 if ( roar_stream_new(stream, rate, channels, bits, codec) == -1 ) 
    5592  return 2; 
    5693 
    57  if ( roardsp_filter_init(filt, stream, ROARDSP_FILTER_LOWP) == -1 ) { 
     94 if ( roardsp_filter_init(filt, stream, ROARDSP_FILTER_DCBLOCK) == -1 ) { 
    5895  ROAR_ERR("main(*): roardsp_filter_init() failed: errno=%s(%i)", strerror(errno), errno); 
    5996  return 1; 
    6097 } 
    6198 
     99/* 
    62100 freq = 1000; 
    63101 roardsp_filter_ctl(filt, ROARDSP_FCTL_FREQ, &freq); 
     102*/ 
    64103 
    65104 if ( roardsp_filter_init(filt+1, stream, ROARDSP_FILTER_HIGHP) == -1 ) { 
     
    89128 fprintf(stderr, "Starting analysis in frequency domain...\n"); 
    90129 
    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)) { 
    92131  step      = M_PI*2*freq/rate; 
    93132  maxval    = -amp; 
     
    124163 
    125164  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); 
    126168 } 
     169 
    127170 
    128171 fprintf(stderr, "Finished analysis in frequency domain: done tests on a total of %u samples on %i frequencies\n", 
     
    130173 
    131174 roardsp_fchain_uninit(fc); 
     175 
     176 if ( rmsout != NULL ) 
     177  fclose(rmsout); 
    132178 
    133179 return 0; 
Note: See TracChangeset for help on using the changeset viewer.