Lines Matching full:stat
19 /* Private data for stat effect */
45 priv_t * stat = (priv_t *) effp->priv; in sox_stat_getopts() local
47 stat->scale = SOX_SAMPLE_MAX; in sox_stat_getopts()
48 stat->volume = 0; in sox_stat_getopts()
49 stat->srms = 0; in sox_stat_getopts()
50 stat->fft = 0; in sox_stat_getopts()
55 stat->volume = 1; in sox_stat_getopts()
62 if (!sscanf(*argv, "%lf", &stat->scale)) { in sox_stat_getopts()
67 stat->srms = 1; in sox_stat_getopts()
69 stat->fft = 1; in sox_stat_getopts()
71 stat->volume = 2; in sox_stat_getopts()
86 priv_t * stat = (priv_t *) effp->priv; in sox_stat_start() local
89 stat->min = stat->max = stat->mid = 0; in sox_stat_start()
90 stat->asum = 0; in sox_stat_start()
91 stat->sum1 = stat->sum2 = 0; in sox_stat_start()
93 stat->dmin = stat->dmax = 0; in sox_stat_start()
94 stat->dsum1 = stat->dsum2 = 0; in sox_stat_start()
96 stat->last = 0; in sox_stat_start()
97 stat->read = 0; in sox_stat_start()
100 stat->bin[i] = 0; in sox_stat_start()
102 stat->fft_size = 4096; in sox_stat_start()
103 stat->re_in = stat->re_out = NULL; in sox_stat_start()
105 if (stat->fft) { in sox_stat_start()
106 stat->fft_offset = 0; in sox_stat_start()
107 stat->re_in = lsx_malloc(sizeof(float) * stat->fft_size); in sox_stat_start()
108 stat->re_out = lsx_malloc(sizeof(float) * (stat->fft_size / 2 + 1)); in sox_stat_start()
134 priv_t * stat = (priv_t *) effp->priv; in sox_stat_flow() local
139 if (stat->read == 0) /* 1st sample */ in sox_stat_flow()
140 stat->min = stat->max = stat->mid = stat->last = (*ibuf)/stat->scale; in sox_stat_flow()
142 if (stat->fft) { in sox_stat_flow()
145 stat->re_in[stat->fft_offset++] = SOX_SAMPLE_TO_FLOAT_32BIT(ibuf[x], effp->clips); in sox_stat_flow()
147 if (stat->fft_offset >= stat->fft_size) { in sox_stat_flow()
148 stat->fft_offset = 0; in sox_stat_flow()
149 … print_power_spectrum((unsigned) stat->fft_size, effp->in_signal.rate, stat->re_in, stat->re_out); in sox_stat_flow()
157 double delta, samp = (double)lsamp / stat->scale; in sox_stat_flow()
159 stat->bin[(lsamp >> 30) + 2]++; in sox_stat_flow()
162 if (stat->volume == 2) { in sox_stat_flow()
171 if (stat->min > samp) in sox_stat_flow()
172 stat->min = samp; in sox_stat_flow()
173 else if (stat->max < samp) in sox_stat_flow()
174 stat->max = samp; in sox_stat_flow()
175 stat->mid = stat->min / 2 + stat->max / 2; in sox_stat_flow()
177 stat->sum1 += samp; in sox_stat_flow()
178 stat->sum2 += samp*samp; in sox_stat_flow()
179 stat->asum += fabs(samp); in sox_stat_flow()
181 delta = fabs(samp - stat->last); in sox_stat_flow()
182 if (delta < stat->dmin) in sox_stat_flow()
183 stat->dmin = delta; in sox_stat_flow()
184 else if (delta > stat->dmax) in sox_stat_flow()
185 stat->dmax = delta; in sox_stat_flow()
187 stat->dsum1 += delta; in sox_stat_flow()
188 stat->dsum2 += delta*delta; in sox_stat_flow()
190 stat->last = samp; in sox_stat_flow()
192 stat->read += len; in sox_stat_flow()
206 priv_t * stat = (priv_t *) effp->priv; in sox_stat_drain() local
212 if (stat->fft && stat->fft_offset) { in sox_stat_drain()
215 for (x = stat->fft_offset; x < stat->fft_size; x++) in sox_stat_drain()
216 stat->re_in[x] = 0; in sox_stat_drain()
218 … print_power_spectrum((unsigned) stat->fft_size, effp->in_signal.rate, stat->re_in, stat->re_out); in sox_stat_drain()
231 priv_t * stat = (priv_t *) effp->priv; in sox_stat_stop() local
235 ct = stat->read; in sox_stat_stop()
237 if (stat->srms) { /* adjust results to units of rms */ in sox_stat_stop()
239 rms = sqrt(stat->sum2/ct); in sox_stat_stop()
241 stat->max *= f; in sox_stat_stop()
242 stat->min *= f; in sox_stat_stop()
243 stat->mid *= f; in sox_stat_stop()
244 stat->asum *= f; in sox_stat_stop()
245 stat->sum1 *= f; in sox_stat_stop()
246 stat->sum2 *= f*f; in sox_stat_stop()
247 stat->dmax *= f; in sox_stat_stop()
248 stat->dmin *= f; in sox_stat_stop()
249 stat->dsum1 *= f; in sox_stat_stop()
250 stat->dsum2 *= f*f; in sox_stat_stop()
251 stat->scale *= rms; in sox_stat_stop()
254 scale = stat->scale; in sox_stat_stop()
256 amp = -stat->min; in sox_stat_stop()
257 if (amp < stat->max) in sox_stat_stop()
258 amp = stat->max; in sox_stat_stop()
261 if (stat->volume == 1 && amp > 0) { in sox_stat_stop()
265 if (stat->volume == 2) in sox_stat_stop()
268 fprintf(stderr, "Samples read: %12" PRIu64 "\n", stat->read); in sox_stat_stop()
269 …fprintf(stderr, "Length (seconds): %12.6f\n", (double)stat->read/effp->in_signal.rate/effp->in_si… in sox_stat_stop()
270 if (stat->srms) in sox_stat_stop()
274 fprintf(stderr, "Maximum amplitude: %12.6f\n", stat->max); in sox_stat_stop()
275 fprintf(stderr, "Minimum amplitude: %12.6f\n", stat->min); in sox_stat_stop()
276 fprintf(stderr, "Midline amplitude: %12.6f\n", stat->mid); in sox_stat_stop()
277 fprintf(stderr, "Mean norm: %12.6f\n", stat->asum/ct); in sox_stat_stop()
278 fprintf(stderr, "Mean amplitude: %12.6f\n", stat->sum1/ct); in sox_stat_stop()
279 fprintf(stderr, "RMS amplitude: %12.6f\n", sqrt(stat->sum2/ct)); in sox_stat_stop()
281 fprintf(stderr, "Maximum delta: %12.6f\n", stat->dmax); in sox_stat_stop()
282 fprintf(stderr, "Minimum delta: %12.6f\n", stat->dmin); in sox_stat_stop()
283 fprintf(stderr, "Mean delta: %12.6f\n", stat->dsum1/(ct-1)); in sox_stat_stop()
284 fprintf(stderr, "RMS delta: %12.6f\n", sqrt(stat->dsum2/(ct-1))); in sox_stat_stop()
285 freq = sqrt(stat->dsum2/stat->sum2)*effp->in_signal.rate/(M_PI*2); in sox_stat_stop()
291 if (stat->bin[2] == 0 && stat->bin[3] == 0) in sox_stat_stop()
295 x = (float)(stat->bin[0] + stat->bin[3]) / (float)(stat->bin[1] + stat->bin[2]); in sox_stat_stop()
314 free(stat->re_in); in sox_stat_stop()
315 free(stat->re_out); in sox_stat_stop()
322 "stat",