summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2007-08-19 18:47:19 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2007-08-19 18:47:19 +0000
commitfcd9f18e1bf3cd362c34a30cf32f882574738d77 (patch)
tree551906078a8a68335a9c94603470aa6e10e0e548 /tests
parent60bf53248bce179062aac71455bf7cff9ca62636 (diff)
tests/check/elements/: Also test 32 bit float mode and the type 2 variants of the filters.
Original commit message from CVS: * tests/check/elements/audiochebyshevfreqband.c: (GST_START_TEST), (audiochebyshevfreqband_suite): * tests/check/elements/audiochebyshevfreqlimit.c: (GST_START_TEST), (audiochebyshevfreqlimit_suite): Also test 32 bit float mode and the type 2 variants of the filters.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/audiochebband.c1111
-rw-r--r--tests/check/elements/audiocheblimit.c711
-rw-r--r--tests/check/elements/audiochebyshevfreqband.c1111
-rw-r--r--tests/check/elements/audiochebyshevfreqlimit.c711
4 files changed, 3570 insertions, 74 deletions
diff --git a/tests/check/elements/audiochebband.c b/tests/check/elements/audiochebband.c
index ecacbd2b..f4602e2c 100644
--- a/tests/check/elements/audiochebband.c
+++ b/tests/check/elements/audiochebband.c
@@ -31,7 +31,14 @@
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
-#define CAPS_STRING \
+#define BUFFER_CAPS_STRING_32 \
+ "audio/x-raw-float, " \
+ "channels = (int) 1, " \
+ "rate = (int) 44100, " \
+ "endianness = (int) BYTE_ORDER, " \
+ "width = (int) 32" \
+
+#define BUFFER_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
@@ -44,7 +51,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -52,7 +59,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
GstElement *
@@ -91,7 +98,355 @@ cleanup_audiochebyshevfreqband (GstElement * audiochebyshevfreqband)
/* Test if data containing only one frequency component
* at 0 is erased with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_0hz)
+GST_START_TEST (test_type1_32_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_64_bp_0hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -119,7 +474,7 @@ GST_START_TEST (test_bp_0hz)
for (i = 0; i < 1024; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -147,7 +502,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at band center is preserved with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_11025hz)
+GST_START_TEST (test_type1_64_bp_11025hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -179,7 +534,7 @@ GST_START_TEST (test_bp_11025hz)
in[i + 3] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -207,7 +562,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is erased with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_22050hz)
+GST_START_TEST (test_type1_64_bp_22050hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -237,7 +592,7 @@ GST_START_TEST (test_bp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -265,7 +620,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at 0 is preserved with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_0hz)
+GST_START_TEST (test_type1_64_br_0hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -293,7 +648,7 @@ GST_START_TEST (test_br_0hz)
for (i = 0; i < 1024; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -321,7 +676,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at band center is erased with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_11025hz)
+GST_START_TEST (test_type1_64_br_11025hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -353,7 +708,7 @@ GST_START_TEST (test_br_11025hz)
in[i + 3] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -381,7 +736,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is preserved with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_22050hz)
+GST_START_TEST (test_type1_64_br_22050hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -411,7 +766,703 @@ GST_START_TEST (test_br_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -443,12 +1494,30 @@ audiochebyshevfreqband_suite (void)
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_bp_0hz);
- tcase_add_test (tc_chain, test_bp_11025hz);
- tcase_add_test (tc_chain, test_bp_22050hz);
- tcase_add_test (tc_chain, test_br_0hz);
- tcase_add_test (tc_chain, test_br_11025hz);
- tcase_add_test (tc_chain, test_br_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_11025hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_br_0hz);
+ tcase_add_test (tc_chain, test_type1_32_br_11025hz);
+ tcase_add_test (tc_chain, test_type1_32_br_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_11025hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_br_0hz);
+ tcase_add_test (tc_chain, test_type1_64_br_11025hz);
+ tcase_add_test (tc_chain, test_type1_64_br_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_11025hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_br_0hz);
+ tcase_add_test (tc_chain, test_type2_32_br_11025hz);
+ tcase_add_test (tc_chain, test_type2_32_br_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_11025hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_br_0hz);
+ tcase_add_test (tc_chain, test_type2_64_br_11025hz);
+ tcase_add_test (tc_chain, test_type2_64_br_22050hz);
return s;
}
diff --git a/tests/check/elements/audiocheblimit.c b/tests/check/elements/audiocheblimit.c
index 35a21e51..bf7ad09e 100644
--- a/tests/check/elements/audiocheblimit.c
+++ b/tests/check/elements/audiocheblimit.c
@@ -31,7 +31,14 @@
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
-#define CAPS_STRING \
+#define BUFFER_CAPS_STRING_32 \
+ "audio/x-raw-float, " \
+ "channels = (int) 1, " \
+ "rate = (int) 44100, " \
+ "endianness = (int) BYTE_ORDER, " \
+ "width = (int) 32" \
+
+#define BUFFER_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
@@ -44,7 +51,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -52,7 +59,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
GstElement *
@@ -91,7 +98,227 @@ cleanup_audiochebyshevfreqlimit (GstElement * audiochebyshevfreqlimit)
/* Test if data containing only one frequency component
* at 0 is preserved with lowpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_lp_0hz)
+GST_START_TEST (test_type1_32_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_64_lp_0hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -117,7 +344,7 @@ GST_START_TEST (test_lp_0hz)
for (i = 0; i < 128; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -145,7 +372,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is erased with lowpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_lp_22050hz)
+GST_START_TEST (test_type1_64_lp_22050hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -173,7 +400,7 @@ GST_START_TEST (test_lp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -201,7 +428,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at 0 is erased with highpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_hp_0hz)
+GST_START_TEST (test_type1_64_hp_0hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -227,7 +454,7 @@ GST_START_TEST (test_hp_0hz)
for (i = 0; i < 128; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -255,7 +482,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is preserved with highpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_hp_22050hz)
+GST_START_TEST (test_type1_64_hp_22050hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -283,7 +510,7 @@ GST_START_TEST (test_hp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -308,6 +535,447 @@ GST_START_TEST (test_hp_22050hz)
GST_END_TEST;
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+
Suite *
audiochebyshevfreqlimit_suite (void)
{
@@ -315,11 +983,22 @@ audiochebyshevfreqlimit_suite (void)
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_lp_0hz);
- tcase_add_test (tc_chain, test_lp_22050hz);
- tcase_add_test (tc_chain, test_hp_0hz);
- tcase_add_test (tc_chain, test_hp_22050hz);
-
+ tcase_add_test (tc_chain, test_type1_32_lp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_lp_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_hp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_hp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_lp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_lp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_hp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_hp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_lp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_lp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_hp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_hp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_lp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_lp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_hp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_hp_22050hz);
return s;
}
diff --git a/tests/check/elements/audiochebyshevfreqband.c b/tests/check/elements/audiochebyshevfreqband.c
index ecacbd2b..f4602e2c 100644
--- a/tests/check/elements/audiochebyshevfreqband.c
+++ b/tests/check/elements/audiochebyshevfreqband.c
@@ -31,7 +31,14 @@
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
-#define CAPS_STRING \
+#define BUFFER_CAPS_STRING_32 \
+ "audio/x-raw-float, " \
+ "channels = (int) 1, " \
+ "rate = (int) 44100, " \
+ "endianness = (int) BYTE_ORDER, " \
+ "width = (int) 32" \
+
+#define BUFFER_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
@@ -44,7 +51,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -52,7 +59,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
GstElement *
@@ -91,7 +98,355 @@ cleanup_audiochebyshevfreqband (GstElement * audiochebyshevfreqband)
/* Test if data containing only one frequency component
* at 0 is erased with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_0hz)
+GST_START_TEST (test_type1_32_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_32_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type1_64_bp_0hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -119,7 +474,7 @@ GST_START_TEST (test_bp_0hz)
for (i = 0; i < 1024; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -147,7 +502,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at band center is preserved with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_11025hz)
+GST_START_TEST (test_type1_64_bp_11025hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -179,7 +534,7 @@ GST_START_TEST (test_bp_11025hz)
in[i + 3] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -207,7 +562,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is erased with bandpass mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_bp_22050hz)
+GST_START_TEST (test_type1_64_bp_22050hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -237,7 +592,7 @@ GST_START_TEST (test_bp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -265,7 +620,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at 0 is preserved with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_0hz)
+GST_START_TEST (test_type1_64_br_0hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -293,7 +648,7 @@ GST_START_TEST (test_br_0hz)
for (i = 0; i < 1024; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -321,7 +676,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at band center is erased with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_11025hz)
+GST_START_TEST (test_type1_64_br_11025hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -353,7 +708,7 @@ GST_START_TEST (test_br_11025hz)
in[i + 3] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -381,7 +736,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is preserved with bandreject mode and a
* 2000Hz frequency band around rate/4 */
-GST_START_TEST (test_br_22050hz)
+GST_START_TEST (test_type1_64_br_22050hz)
{
GstElement *audiochebyshevfreqband;
GstBuffer *inbuffer, *outbuffer;
@@ -411,7 +766,703 @@ GST_START_TEST (test_br_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_32_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is preserved with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.6);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with bandpass mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_bp_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_0hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at band center is erased with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_11025hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 4) {
+ in[i] = 0.0;
+ in[i + 1] = 1.0;
+ in[i + 2] = 0.0;
+ in[i + 3] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 1024; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 1024.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqband (audiochebyshevfreqband);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with bandreject mode and a
+ * 2000Hz frequency band around rate/4 */
+GST_START_TEST (test_type2_64_br_22050hz)
+{
+ GstElement *audiochebyshevfreqband;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqband = setup_audiochebyshevfreqband ();
+ /* Set to bandreject */
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqband,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "lower-frequency",
+ 44100 / 4.0 - 1000, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqband), "upper-frequency",
+ 44100 / 4.0 + 1000, NULL);
+ inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 1024; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -443,12 +1494,30 @@ audiochebyshevfreqband_suite (void)
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_bp_0hz);
- tcase_add_test (tc_chain, test_bp_11025hz);
- tcase_add_test (tc_chain, test_bp_22050hz);
- tcase_add_test (tc_chain, test_br_0hz);
- tcase_add_test (tc_chain, test_br_11025hz);
- tcase_add_test (tc_chain, test_br_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_11025hz);
+ tcase_add_test (tc_chain, test_type1_32_bp_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_br_0hz);
+ tcase_add_test (tc_chain, test_type1_32_br_11025hz);
+ tcase_add_test (tc_chain, test_type1_32_br_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_11025hz);
+ tcase_add_test (tc_chain, test_type1_64_bp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_br_0hz);
+ tcase_add_test (tc_chain, test_type1_64_br_11025hz);
+ tcase_add_test (tc_chain, test_type1_64_br_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_11025hz);
+ tcase_add_test (tc_chain, test_type2_32_bp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_br_0hz);
+ tcase_add_test (tc_chain, test_type2_32_br_11025hz);
+ tcase_add_test (tc_chain, test_type2_32_br_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_11025hz);
+ tcase_add_test (tc_chain, test_type2_64_bp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_br_0hz);
+ tcase_add_test (tc_chain, test_type2_64_br_11025hz);
+ tcase_add_test (tc_chain, test_type2_64_br_22050hz);
return s;
}
diff --git a/tests/check/elements/audiochebyshevfreqlimit.c b/tests/check/elements/audiochebyshevfreqlimit.c
index 35a21e51..bf7ad09e 100644
--- a/tests/check/elements/audiochebyshevfreqlimit.c
+++ b/tests/check/elements/audiochebyshevfreqlimit.c
@@ -31,7 +31,14 @@
* get_peer, and then remove references in every test function */
GstPad *mysrcpad, *mysinkpad;
-#define CAPS_STRING \
+#define BUFFER_CAPS_STRING_32 \
+ "audio/x-raw-float, " \
+ "channels = (int) 1, " \
+ "rate = (int) 44100, " \
+ "endianness = (int) BYTE_ORDER, " \
+ "width = (int) 32" \
+
+#define BUFFER_CAPS_STRING_64 \
"audio/x-raw-float, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
@@ -44,7 +51,7 @@ static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
@@ -52,7 +59,7 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_STATIC_CAPS ("audio/x-raw-float, "
"channels = (int) 1, "
"rate = (int) 44100, "
- "endianness = (int) BYTE_ORDER, " "width = (int) 64")
+ "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
);
GstElement *
@@ -91,7 +98,227 @@ cleanup_audiochebyshevfreqlimit (GstElement * audiochebyshevfreqlimit)
/* Test if data containing only one frequency component
* at 0 is preserved with lowpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_lp_0hz)
+GST_START_TEST (test_type1_32_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_32_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 0.25, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type1_64_lp_0hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -117,7 +344,7 @@ GST_START_TEST (test_lp_0hz)
for (i = 0; i < 128; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -145,7 +372,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is erased with lowpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_lp_22050hz)
+GST_START_TEST (test_type1_64_lp_22050hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -173,7 +400,7 @@ GST_START_TEST (test_lp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -201,7 +428,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at 0 is erased with highpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_hp_0hz)
+GST_START_TEST (test_type1_64_hp_0hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -227,7 +454,7 @@ GST_START_TEST (test_hp_0hz)
for (i = 0; i < 128; i++)
in[i] = 1.0;
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -255,7 +482,7 @@ GST_END_TEST;
/* Test if data containing only one frequency component
* at rate/2 is preserved with highpass mode and a cutoff
* at rate/4 */
-GST_START_TEST (test_hp_22050hz)
+GST_START_TEST (test_type1_64_hp_22050hz)
{
GstElement *audiochebyshevfreqlimit;
GstBuffer *inbuffer, *outbuffer;
@@ -283,7 +510,7 @@ GST_START_TEST (test_hp_22050hz)
in[i + 1] = -1.0;
}
- caps = gst_caps_from_string (CAPS_STRING);
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
gst_buffer_set_caps (inbuffer, caps);
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
@@ -308,6 +535,447 @@ GST_START_TEST (test_hp_22050hz)
GST_END_TEST;
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_32_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gfloat *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gfloat));
+ in = (gfloat *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gfloat *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is preserved with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_lp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is erased with lowpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_lp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to lowpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 0, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at 0 is erased with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_hp_0hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i++)
+ in[i] = 1.0;
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms <= 0.1);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+/* Test if data containing only one frequency component
+ * at rate/2 is preserved with highpass mode and a cutoff
+ * at rate/4 */
+GST_START_TEST (test_type2_64_hp_22050hz)
+{
+ GstElement *audiochebyshevfreqlimit;
+ GstBuffer *inbuffer, *outbuffer;
+ GstCaps *caps;
+ gdouble *in, *res, rms;
+ gint i;
+
+ audiochebyshevfreqlimit = setup_audiochebyshevfreqlimit ();
+ /* Set to highpass */
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "mode", 1, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "poles", 8, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "type", 2, NULL);
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "ripple", 40.0, NULL);
+
+ fail_unless (gst_element_set_state (audiochebyshevfreqlimit,
+ GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+ "could not set to playing");
+
+ g_object_set (G_OBJECT (audiochebyshevfreqlimit), "cutoff", 44100 / 4.0,
+ NULL);
+ inbuffer = gst_buffer_new_and_alloc (128 * sizeof (gdouble));
+ in = (gdouble *) GST_BUFFER_DATA (inbuffer);
+ for (i = 0; i < 128; i += 2) {
+ in[i] = 1.0;
+ in[i + 1] = -1.0;
+ }
+
+ caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
+ gst_buffer_set_caps (inbuffer, caps);
+ gst_caps_unref (caps);
+ ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
+
+ /* pushing gives away my reference ... */
+ fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
+ /* ... and puts a new buffer on the global list */
+ fail_unless_equals_int (g_list_length (buffers), 1);
+ fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
+
+ res = (gdouble *) GST_BUFFER_DATA (outbuffer);
+
+ rms = 0.0;
+ for (i = 0; i < 128; i++)
+ rms += res[i] * res[i];
+ rms = sqrt (rms / 128.0);
+ fail_unless (rms >= 0.9);
+
+ /* cleanup */
+ cleanup_audiochebyshevfreqlimit (audiochebyshevfreqlimit);
+}
+
+GST_END_TEST;
+
+
Suite *
audiochebyshevfreqlimit_suite (void)
{
@@ -315,11 +983,22 @@ audiochebyshevfreqlimit_suite (void)
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
- tcase_add_test (tc_chain, test_lp_0hz);
- tcase_add_test (tc_chain, test_lp_22050hz);
- tcase_add_test (tc_chain, test_hp_0hz);
- tcase_add_test (tc_chain, test_hp_22050hz);
-
+ tcase_add_test (tc_chain, test_type1_32_lp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_lp_22050hz);
+ tcase_add_test (tc_chain, test_type1_32_hp_0hz);
+ tcase_add_test (tc_chain, test_type1_32_hp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_lp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_lp_22050hz);
+ tcase_add_test (tc_chain, test_type1_64_hp_0hz);
+ tcase_add_test (tc_chain, test_type1_64_hp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_lp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_lp_22050hz);
+ tcase_add_test (tc_chain, test_type2_32_hp_0hz);
+ tcase_add_test (tc_chain, test_type2_32_hp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_lp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_lp_22050hz);
+ tcase_add_test (tc_chain, test_type2_64_hp_0hz);
+ tcase_add_test (tc_chain, test_type2_64_hp_22050hz);
return s;
}