Changeset 1133:902afe9f9028 in roaraudio
- Timestamp:
- 01/20/09 20:40:42 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarfctest.c
r1132 r1133 39 39 float step; // = M_PI*2*freq/rate; /* how much time per sample we have to encode ... */ 40 40 float t = 0; /* current time */ 41 float length = 5; /* 5 sec */41 float length; 42 42 int16_t amp = 32767; 43 43 int i; … … 49 49 int count = 0; 50 50 float rms, rms_in = amp/sqrt(2); 51 float worklen; 52 float sfreq = 1, efreq = -1; 53 float engage = 0; 54 float tmax = 1024; 51 55 struct roardsp_filterchain fc[1]; 52 56 struct roardsp_filter filt[3]; … … 64 68 if ( !strcmp(k, "--rate") ) { 65 69 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]); 66 78 #ifdef ROAR_HAVE_BIN_GNUPLOT 67 79 } else if ( !strcmp(k, "--gnuplot") ) { … … 128 140 fprintf(stderr, "Starting analysis in frequency domain...\n"); 129 141 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)) { 131 148 step = M_PI*2*freq/rate; 132 149 maxval = -amp; … … 134 151 sc = 0; 135 152 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) { 139 170 for (i = 0; i < 1024; i++) { 140 171 out[i] = amp*sin(t); … … 146 177 roardsp_fchain_calc(fc, out, 1024); 147 178 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; 153 188 } 154 189 }
Note: See TracChangeset
for help on using the changeset viewer.