Lines Matching refs:silence
69 priv_t * silence = (priv_t *) effp->priv; in clear_rms() local
71 memset(silence->window, 0, in clear_rms()
72 silence->window_size * sizeof(double)); in clear_rms()
74 silence->window_current = silence->window; in clear_rms()
75 silence->window_end = silence->window + silence->window_size; in clear_rms()
76 silence->rms_sum = 0; in clear_rms()
81 priv_t * silence = (priv_t *) effp->priv; in sox_silence_getopts() local
88 silence->leave_silence = sox_false; in sox_silence_getopts()
93 silence->leave_silence = sox_true; in sox_silence_getopts()
101 silence->start = sox_false; in sox_silence_getopts()
102 if (sscanf(argv[0], "%d", &silence->start_periods) != 1) in sox_silence_getopts()
104 if (silence->start_periods < 0) in sox_silence_getopts()
112 if (silence->start_periods > 0) in sox_silence_getopts()
114 silence->start = sox_true; in sox_silence_getopts()
122 silence->start_duration_str = lsx_strdup(argv[0]); in sox_silence_getopts()
124 n = lsx_parsesamples(0.,silence->start_duration_str,&temp,'s'); in sox_silence_getopts()
127 silence->start_duration = temp; in sox_silence_getopts()
129 parse_count = sscanf(argv[1], "%lf%c", &silence->start_threshold, in sox_silence_getopts()
130 &silence->start_unit); in sox_silence_getopts()
134 silence->start_unit = '%'; in sox_silence_getopts()
140 silence->stop = sox_false; in sox_silence_getopts()
146 if (sscanf(argv[0], "%d", &silence->stop_periods) != 1) in sox_silence_getopts()
148 if (silence->stop_periods < 0) in sox_silence_getopts()
150 silence->stop_periods = -silence->stop_periods; in sox_silence_getopts()
151 silence->restart = 1; in sox_silence_getopts()
154 silence->restart = 0; in sox_silence_getopts()
155 silence->stop = sox_true; in sox_silence_getopts()
163 silence->stop_duration_str = lsx_strdup(argv[0]); in sox_silence_getopts()
165 n = lsx_parsesamples(0.,silence->stop_duration_str,&temp,'s'); in sox_silence_getopts()
168 silence->stop_duration = temp; in sox_silence_getopts()
170 parse_count = sscanf(argv[1], "%lf%c", &silence->stop_threshold, in sox_silence_getopts()
171 &silence->stop_unit); in sox_silence_getopts()
175 silence->stop_unit = '%'; in sox_silence_getopts()
182 if (silence->start) in sox_silence_getopts()
184 if ((silence->start_unit != '%') && (silence->start_unit != 'd')) in sox_silence_getopts()
189 if ((silence->start_unit == '%') && ((silence->start_threshold < 0.0) in sox_silence_getopts()
190 || (silence->start_threshold > 100.0))) in sox_silence_getopts()
195 if ((silence->start_unit == 'd') && (silence->start_threshold >= 0.0)) in sox_silence_getopts()
202 if (silence->stop) in sox_silence_getopts()
204 if ((silence->stop_unit != '%') && (silence->stop_unit != 'd')) in sox_silence_getopts()
209 if ((silence->stop_unit == '%') && ((silence->stop_threshold < 0.0) || in sox_silence_getopts()
210 (silence->stop_threshold > 100.0))) in sox_silence_getopts()
215 if ((silence->stop_unit == 'd') && (silence->stop_threshold >= 0.0)) in sox_silence_getopts()
226 priv_t *silence = (priv_t *)effp->priv; in sox_silence_start() local
233 silence->window_size = (effp->in_signal.rate / 50) * in sox_silence_start()
235 silence->window = lsx_malloc(silence->window_size * sizeof(double)); in sox_silence_start()
240 if (silence->start) in sox_silence_start()
242 if (lsx_parsesamples(effp->in_signal.rate, silence->start_duration_str, in sox_silence_start()
245 silence->start_duration = temp * effp->in_signal.channels; in sox_silence_start()
247 if (silence->stop) in sox_silence_start()
249 if (lsx_parsesamples(effp->in_signal.rate,silence->stop_duration_str, in sox_silence_start()
252 silence->stop_duration = temp * effp->in_signal.channels; in sox_silence_start()
255 if (silence->start) in sox_silence_start()
256 silence->mode = SILENCE_TRIM; in sox_silence_start()
258 silence->mode = SILENCE_COPY; in sox_silence_start()
260 silence->start_holdoff = lsx_malloc(sizeof(sox_sample_t)*silence->start_duration); in sox_silence_start()
261 silence->start_holdoff_offset = 0; in sox_silence_start()
262 silence->start_holdoff_end = 0; in sox_silence_start()
263 silence->start_found_periods = 0; in sox_silence_start()
265 silence->stop_holdoff = lsx_malloc(sizeof(sox_sample_t)*silence->stop_duration); in sox_silence_start()
266 silence->stop_holdoff_offset = 0; in sox_silence_start()
267 silence->stop_holdoff_end = 0; in sox_silence_start()
268 silence->stop_found_periods = 0; in sox_silence_start()
294 priv_t * silence = (priv_t *) effp->priv; in compute_rms() local
298 new_sum = silence->rms_sum; in compute_rms()
299 new_sum -= *silence->window_current; in compute_rms()
302 rms = sqrt(new_sum / silence->window_size); in compute_rms()
309 priv_t * silence = (priv_t *) effp->priv; in update_rms() local
311 silence->rms_sum -= *silence->window_current; in update_rms()
312 *silence->window_current = ((double)sample * (double)sample); in update_rms()
313 silence->rms_sum += *silence->window_current; in update_rms()
315 silence->window_current++; in update_rms()
316 if (silence->window_current >= silence->window_end) in update_rms()
317 silence->window_current = silence->window; in update_rms()
325 priv_t * silence = (priv_t *) effp->priv; in sox_silence_flow() local
334 switch (silence->mode) in sox_silence_flow()
355 silence->start_threshold, in sox_silence_flow()
356 silence->start_unit); in sox_silence_flow()
365 silence->start_holdoff[ in sox_silence_flow()
366 silence->start_holdoff_end++] = *ibuf++; in sox_silence_flow()
370 if (silence->start_holdoff_end >= in sox_silence_flow()
371 silence->start_duration) in sox_silence_flow()
373 if (++silence->start_found_periods >= in sox_silence_flow()
374 silence->start_periods) in sox_silence_flow()
376 silence->mode = SILENCE_TRIM_FLUSH; in sox_silence_flow()
382 silence->start_holdoff_offset = 0; in sox_silence_flow()
383 silence->start_holdoff_end = 0; in sox_silence_flow()
388 silence->start_holdoff_end = 0; in sox_silence_flow()
402 nrOfTicks = min((silence->start_holdoff_end - in sox_silence_flow()
403 silence->start_holdoff_offset), in sox_silence_flow()
408 *obuf++ = silence->start_holdoff[silence->start_holdoff_offset++]; in sox_silence_flow()
413 if (silence->start_holdoff_offset == silence->start_holdoff_end) in sox_silence_flow()
415 silence->start_holdoff_offset = 0; in sox_silence_flow()
416 silence->start_holdoff_end = 0; in sox_silence_flow()
417 silence->mode = SILENCE_COPY; in sox_silence_flow()
466 if (silence->stop) in sox_silence_flow()
476 silence->stop_threshold, in sox_silence_flow()
477 silence->stop_unit); in sox_silence_flow()
491 if (threshold && silence->stop_holdoff_end in sox_silence_flow()
492 && !silence->leave_silence) in sox_silence_flow()
494 silence->mode = SILENCE_COPY_FLUSH; in sox_silence_flow()
516 if (silence->leave_silence) { in sox_silence_flow()
520 silence->stop_holdoff[ in sox_silence_flow()
521 silence->stop_holdoff_end++] = *ibuf++; in sox_silence_flow()
527 if (silence->stop_holdoff_end >= in sox_silence_flow()
528 silence->stop_duration) in sox_silence_flow()
533 if (++silence->stop_found_periods >= in sox_silence_flow()
534 silence->stop_periods) in sox_silence_flow()
536 silence->stop_holdoff_offset = 0; in sox_silence_flow()
537 silence->stop_holdoff_end = 0; in sox_silence_flow()
538 if (!silence->restart) in sox_silence_flow()
542 silence->mode = SILENCE_STOP; in sox_silence_flow()
548 silence->stop_found_periods = 0; in sox_silence_flow()
549 silence->start_found_periods = 0; in sox_silence_flow()
550 silence->start_holdoff_offset = 0; in sox_silence_flow()
551 silence->start_holdoff_end = 0; in sox_silence_flow()
553 silence->mode = SILENCE_TRIM; in sox_silence_flow()
563 silence->mode = SILENCE_COPY_FLUSH; in sox_silence_flow()
584 nrOfTicks = min((silence->stop_holdoff_end - in sox_silence_flow()
585 silence->stop_holdoff_offset), in sox_silence_flow()
591 *obuf++ = silence->stop_holdoff[silence->stop_holdoff_offset++]; in sox_silence_flow()
596 if (silence->stop_holdoff_offset == silence->stop_holdoff_end) in sox_silence_flow()
598 silence->stop_holdoff_offset = 0; in sox_silence_flow()
599 silence->stop_holdoff_end = 0; in sox_silence_flow()
600 silence->mode = SILENCE_COPY; in sox_silence_flow()
619 priv_t * silence = (priv_t *) effp->priv; in sox_silence_drain() local
626 if (silence->mode == SILENCE_COPY_FLUSH || in sox_silence_drain()
627 silence->mode == SILENCE_COPY) in sox_silence_drain()
629 nrOfTicks = min((silence->stop_holdoff_end - in sox_silence_drain()
630 silence->stop_holdoff_offset), *osamp); in sox_silence_drain()
634 *obuf++ = silence->stop_holdoff[silence->stop_holdoff_offset++]; in sox_silence_drain()
639 if (silence->stop_holdoff_offset == silence->stop_holdoff_end) in sox_silence_drain()
641 silence->stop_holdoff_offset = 0; in sox_silence_drain()
642 silence->stop_holdoff_end = 0; in sox_silence_drain()
643 silence->mode = SILENCE_STOP; in sox_silence_drain()
648 if (silence->mode == SILENCE_STOP || *osamp == 0) in sox_silence_drain()
656 priv_t * silence = (priv_t *) effp->priv; in sox_silence_stop() local
658 free(silence->window); in sox_silence_stop()
659 free(silence->start_holdoff); in sox_silence_stop()
660 free(silence->stop_holdoff); in sox_silence_stop()
667 priv_t * silence = (priv_t *) effp->priv; in lsx_kill() local
669 free(silence->start_duration_str); in lsx_kill()
670 free(silence->stop_duration_str); in lsx_kill()