summaryrefslogtreecommitdiffstats
path: root/gst/level
diff options
context:
space:
mode:
authorThomas Vander Stichele <thomas@apestaart.org>2005-09-01 20:23:22 +0000
committerThomas Vander Stichele <thomas@apestaart.org>2005-09-01 20:23:22 +0000
commit423df73380779bfc30d9f87cd876dcea71b75af0 (patch)
treed98478e6845da82b2df350fa0eba99e4943775fe /gst/level
parent63efb534b9dadf2215e1175d0641d17c6437176a (diff)
Andrewio Patrickoforus Wingonymus - 5 additional tests for your sins
Original commit message from CVS: Andrewio Patrickoforus Wingonymus - 5 additional tests for your sins Add a regression test for level and fix a casting bug that made the additional channels turn out wrong
Diffstat (limited to 'gst/level')
-rw-r--r--gst/level/gstlevel.c26
-rw-r--r--gst/level/gstlevel.h10
2 files changed, 16 insertions, 20 deletions
diff --git a/gst/level/gstlevel.c b/gst/level/gstlevel.c
index e4fa86c0..8f1210f1 100644
--- a/gst/level/gstlevel.c
+++ b/gst/level/gstlevel.c
@@ -1,8 +1,6 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * gstlevel.c: signals RMS, peak and decaying peak levels
- * Copyright (C) 2000,2001,2002,2003
+ * Copyright (C) 2000,2001,2002,2003,2005
* Thomas Vander Stichele <thomas at apestaart dot org>
*
* This library is free software; you can redistribute it and/or
@@ -34,7 +32,7 @@ GST_DEBUG_CATEGORY (level_debug);
static GstElementDetails level_details = {
"Level",
"Filter/Analyzer/Audio",
- "RMS/Peak/Decaying Peak Level signaller for audio/raw",
+ "RMS/Peak/Decaying Peak Level messager for audio/raw",
"Thomas <thomas@apestaart.org>"
};
@@ -113,11 +111,11 @@ gst_level_class_init (GstLevelClass * klass)
gobject_class->get_property = gst_level_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SIGNAL_LEVEL,
- g_param_spec_boolean ("signal", "Signal",
- "Emit level signals for each interval", TRUE, G_PARAM_READWRITE));
+ g_param_spec_boolean ("message", "mesage",
+ "Post a level message for each interval", TRUE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SIGNAL_INTERVAL,
g_param_spec_double ("interval", "Interval",
- "Interval between emissions (in seconds)",
+ "Interval between posts (in seconds)",
0.01, 100.0, 0.1, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PEAK_TTL,
g_param_spec_double ("peak_ttl", "Peak TTL",
@@ -158,7 +156,7 @@ gst_level_set_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_SIGNAL_LEVEL:
- filter->signal = g_value_get_boolean (value);
+ filter->message = g_value_get_boolean (value);
break;
case PROP_SIGNAL_INTERVAL:
filter->interval = g_value_get_double (value);
@@ -182,7 +180,7 @@ gst_level_get_property (GObject * object, guint prop_id,
switch (prop_id) {
case PROP_SIGNAL_LEVEL:
- g_value_set_boolean (value, filter->signal);
+ g_value_set_boolean (value, filter->message);
break;
case PROP_SIGNAL_INTERVAL:
g_value_set_double (value, filter->interval);
@@ -356,7 +354,7 @@ gst_level_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
CS = 0.0;
switch (filter->width) {
case 16:
- gst_level_calculate_gint16 (in_data + i, num_int_samples,
+ gst_level_calculate_gint16 (((gint16 *) in_data) + i, num_int_samples,
filter->channels, filter->width - 1, &CS, &filter->peak[i]);
break;
case 8:
@@ -365,7 +363,7 @@ gst_level_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
break;
}
GST_LOG_OBJECT (filter,
- "channel %d, cumulative sum %f, peak %f, over %d channels/%d samples",
+ "channel %d, cumulative sum %f, peak %f, over %d samples/%d channels",
i, CS, filter->peak[i], num_int_samples, filter->channels);
filter->CS[i] += CS;
}
@@ -413,8 +411,8 @@ gst_level_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
/* do we need to emit ? */
- if (filter->num_samples >= filter->interval * (gdouble) filter->rate) {
- if (filter->signal) {
+ if (filter->num_samples >= (gint) (filter->interval * filter->rate)) {
+ if (filter->message) {
GstMessage *m;
double endtime, RMS;
double RMSdB, lastdB, decaydB;
@@ -428,7 +426,7 @@ gst_level_transform (GstBaseTransform * trans, GstBuffer * in, GstBuffer * out)
for (i = 0; i < filter->channels; ++i) {
RMS = sqrt (filter->CS[i] / filter->num_samples);
GST_LOG_OBJECT (filter,
- "CS: %f, num_samples %f, channel %d, RMS %f",
+ "CS: %f, num_samples %d, channel %d, RMS %f",
filter->CS[i], filter->num_samples, i, RMS);
/* RMS values are calculated in amplitude, so 20 * log 10 */
RMSdB = 20 * log10 (RMS);
diff --git a/gst/level/gstlevel.h b/gst/level/gstlevel.h
index 5a9a1042..ecd10a87 100644
--- a/gst/level/gstlevel.h
+++ b/gst/level/gstlevel.h
@@ -1,8 +1,6 @@
/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * gstlevel.c: signals RMS, peak and decaying peak levels
- * Copyright (C) 2000,2001,2002,2003
+ * Copyright (C) 1999 Erik Walthinsen <omega@cse.ogi.edu>
+ * Copyright (C) 2000,2001,2002,2003,2005
* Thomas Vander Stichele <thomas at apestaart dot org>
*
* This library is free software; you can redistribute it and/or
@@ -52,7 +50,7 @@ typedef struct _GstLevelClass GstLevelClass;
struct _GstLevel {
GstBaseTransform element;
- gboolean signal; /* whether or not to emit signals */
+ gboolean message; /* whether or not to post messages */
gdouble interval; /* how many seconds between emits */
gint rate; /* caps variables */
@@ -61,7 +59,7 @@ struct _GstLevel {
gdouble decay_peak_ttl; /* time to live for peak in seconds */
gdouble decay_peak_falloff; /* falloff in dB/sec */
- gdouble num_samples; /* one-channel sample count since last emit */
+ gint num_samples; /* one-channel sample count since last emit */
/* per-channel arrays for intermediate values */
gdouble *CS; /* normalized Cumulative Square */