ref: 6bae11ebb8908f2836f82b52c2b3b117ffaa5191
parent: 62d0c55dd226c26994e3d404e571cfaa40b625f9
author: cbagwell <cbagwell>
date: Mon Dec 3 22:37:15 EST 2001
Correctly store RMS value.
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -30,7 +30,7 @@
# Build macros.
-CFLAGS = @CFLAGS@ @DEFS@ -I$(srcdir)
+CFLAGS = @CFLAGS@ -I. -I$(srcdir)
LDFLAGS = -L. -Lgsm @LDFLAGS@
LIBS = -lst @LIBS@
@@ -127,8 +127,8 @@
$(srcdir)/mkinstalldirs $(includedir)
$(INSTALL) -c -m 644 libst.a $(libdir)
$(RANLIB) $(libdir)/libst.a
- $(INSTALL) -c -m 644 libst.3 $(mandir)/man3
- $(INSTALL) -c -m 644 st.h $(includedir)
+ $(INSTALL) -c -m 644 $(srcdir)/libst.3 $(mandir)/man3
+ $(INSTALL) -c -m 644 $(srcdir)/st.h $(includedir)
$(INSTALL) -c -m 644 ststdint.h $(includedir)
PLAY_UNINSTALL_0 =
@@ -148,7 +148,7 @@
uninstall-lib:
$(RM) $(libdir)/libst.a
- $(RM)$(mandir)/man3/libst.3
+ $(RM) $(mandir)/man3/libst.3
$(RM) $(includedir)/st.h
$(RM) $(includedir)/ststdint.h
--- a/src/silence.c
+++ b/src/silence.c
@@ -62,9 +62,9 @@
st_size_t stop_holdoff_end;
int stop_found_periods;
- int64_t *window;
- int64_t *window_current;
- int64_t *window_end;
+ double *window;
+ double *window_current;
+ double *window_end;
st_size_t window_size;
double rms_sum;
@@ -249,8 +249,8 @@
silence_t silence = (silence_t) effp->priv;
silence->window_size = (effp->ininfo.rate / 10) * effp->ininfo.channels;
- silence->window = (int64_t *)malloc(silence->window_size *
- sizeof(int64_t));
+ silence->window = (double *)malloc(silence->window_size *
+ sizeof(double));
if (!silence->window)
{
@@ -259,7 +259,7 @@
}
memset(silence->window, 0,
- silence->window_size * sizeof(int64_t));
+ silence->window_size * sizeof(double));
silence->window_current = silence->window;
silence->window_end = silence->window + silence->window_size;
@@ -367,6 +367,10 @@
void update_rms(eff_t effp, st_sample_t sample)
{
silence_t silence = (silence_t) effp->priv;
+
+ silence->rms_sum -= *silence->window_current;
+ *silence->window_current = ((double)sample * (double)sample);
+ silence->rms_sum += *silence->window_current;
silence->window_current++;
if (silence->window_current >= silence->window_end)