Changeset 1133:902afe9f9028 in roaraudio


Ignore:
Timestamp:
01/20/09 20:40:42 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

done some very basic improvments: added --sfreq, --efreq, --engage, --tmax

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarfctest.c

    r1132 r1133  
    3939 float step; //   = M_PI*2*freq/rate; /* how much time per sample we have to encode ... */ 
    4040 float t      = 0; /* current time */ 
    41  float length = 5; /* 5 sec */ 
     41 float length; 
    4242 int16_t amp  = 32767; 
    4343 int      i; 
     
    4949 int      count = 0; 
    5050 float    rms, rms_in = amp/sqrt(2); 
     51 float    worklen; 
     52 float    sfreq  = 1, efreq = -1; 
     53 float    engage = 0; 
     54 float    tmax   = 1024; 
    5155 struct roardsp_filterchain fc[1]; 
    5256 struct roardsp_filter      filt[3]; 
     
    6468  if ( !strcmp(k, "--rate") ) { 
    6569   rate = atoi(argv[++i]); 
     70  } else if ( !strcmp(k, "--sfreq") ) { 
     71   sfreq = atof(argv[++i]); 
     72  } else if ( !strcmp(k, "--efreq") ) { 
     73   efreq = atof(argv[++i]); 
     74  } else if ( !strcmp(k, "--engage") ) { 
     75   engage = atof(argv[++i]); 
     76  } else if ( !strcmp(k, "--tmax") ) { 
     77   tmax = atof(argv[++i]); 
    6678#ifdef ROAR_HAVE_BIN_GNUPLOT 
    6779  } else if ( !strcmp(k, "--gnuplot") ) { 
     
    128140 fprintf(stderr, "Starting analysis in frequency domain...\n"); 
    129141 
    130  for (freq = 1/* 2*exp(1) */; freq < /* (float)rate/2 */ 100; freq *= (1+exp(1)/100), length /= (1+exp(1)/100)) { 
     142 if ( efreq == -1 ) 
     143  efreq = (float)rate/2; 
     144 
     145 length = 5/sfreq; 
     146 
     147 for (freq = sfreq; freq < efreq; freq *= (1+exp(1)/100), length /= (1+exp(1)/100)) { 
    131148  step      = M_PI*2*freq/rate; 
    132149  maxval    = -amp; 
     
    134151  sc        = 0; 
    135152  rms       = 0; 
    136   t         = 0; 
    137  
    138   while (t < 2*M_PI*freq*length) { 
     153  t         = -engage; 
     154 
     155  if ( roardsp_fchain_reset(fc, ROARDSP_RESET_STATE) == -1 ) { 
     156   ROAR_ERR("Can not reset filterchain."); 
     157   return 8; 
     158  } 
     159 
     160 
     161  worklen = length; 
     162 
     163  if ( worklen > tmax ) 
     164   worklen = tmax; 
     165 
     166  worklen = 2*M_PI*freq*worklen; 
     167 
     168 
     169  while (t < worklen) { 
    139170   for (i = 0; i < 1024; i++) { 
    140171    out[i] = amp*sin(t); 
     
    146177   roardsp_fchain_calc(fc, out, 1024); 
    147178 
    148    for (i = 0; i < 1024; i++) { 
    149     sc++; 
    150     rms += out[i] * out[i]; 
    151     if ( out[i] > maxval ) 
    152      maxval = out[i]; 
     179   if ( t >= 0 ) { 
     180    for (i = 0; i < 1024; i++) { 
     181     rms += out[i] * out[i]; 
     182     if ( out[i] > maxval ) 
     183      maxval = out[i]; 
     184    } 
     185    sc += 1024; 
     186   } else { 
     187    sc_tot += 1024; 
    153188   } 
    154189  } 
Note: See TracChangeset for help on using the changeset viewer.