3 * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
5 * audiochebband.c: Unit test for the audiochebband element
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <gst/base/gstbasetransform.h>
25 #include <gst/check/gstcheck.h>
29 /* For ease of programming we use globals to keep refs for our floating
30 * src and sink pads we create; otherwise we always have to do get_pad,
31 * get_peer, and then remove references in every test function */
32 GstPad *mysrcpad, *mysinkpad;
34 #define BUFFER_CAPS_STRING_32 \
35 "audio/x-raw-float, " \
36 "channels = (int) 1, " \
37 "rate = (int) 44100, " \
38 "endianness = (int) BYTE_ORDER, " \
41 #define BUFFER_CAPS_STRING_64 \
42 "audio/x-raw-float, " \
43 "channels = (int) 1, " \
44 "rate = (int) 44100, " \
45 "endianness = (int) BYTE_ORDER, " \
48 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
51 GST_STATIC_CAPS ("audio/x-raw-float, "
52 "channels = (int) 1, "
53 "rate = (int) 44100, "
54 "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
56 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
59 GST_STATIC_CAPS ("audio/x-raw-float, "
60 "channels = (int) 1, "
61 "rate = (int) 44100, "
62 "endianness = (int) BYTE_ORDER, " "width = (int) { 32, 64 }")
66 setup_audiochebband (void)
68 GstElement *audiochebband;
70 GST_DEBUG ("setup_audiochebband");
71 audiochebband = gst_check_setup_element ("audiochebband");
72 mysrcpad = gst_check_setup_src_pad (audiochebband, &srctemplate, NULL);
73 mysinkpad = gst_check_setup_sink_pad (audiochebband, &sinktemplate, NULL);
74 gst_pad_set_active (mysrcpad, TRUE);
75 gst_pad_set_active (mysinkpad, TRUE);
81 cleanup_audiochebband (GstElement * audiochebband)
83 GST_DEBUG ("cleanup_audiochebband");
85 g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
86 g_list_free (buffers);
89 gst_pad_set_active (mysrcpad, FALSE);
90 gst_pad_set_active (mysinkpad, FALSE);
91 gst_check_teardown_src_pad (audiochebband);
92 gst_check_teardown_sink_pad (audiochebband);
93 gst_check_teardown_element (audiochebband);
96 /* Test if data containing only one frequency component
97 * at 0 is erased with bandpass mode and a
98 * 2000Hz frequency band around rate/4 */
99 GST_START_TEST (test_type1_32_bp_0hz)
101 GstElement *audiochebband;
102 GstBuffer *inbuffer, *outbuffer;
104 gfloat *in, *res, rms;
107 audiochebband = setup_audiochebband ();
108 /* Set to bandpass */
109 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
110 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
111 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
112 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
114 fail_unless (gst_element_set_state (audiochebband,
115 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
116 "could not set to playing");
118 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
119 44100 / 4.0 - 1000, NULL);
120 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
121 44100 / 4.0 + 1000, NULL);
122 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
123 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
124 for (i = 0; i < 1024; i++)
127 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
128 gst_buffer_set_caps (inbuffer, caps);
129 gst_caps_unref (caps);
130 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
132 /* pushing gives away my reference ... */
133 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
134 /* ... and puts a new buffer on the global list */
135 fail_unless_equals_int (g_list_length (buffers), 1);
136 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
138 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
141 for (i = 0; i < 1024; i++)
142 rms += res[i] * res[i];
143 rms = sqrt (rms / 1024.0);
144 fail_unless (rms <= 0.1);
147 cleanup_audiochebband (audiochebband);
152 /* Test if data containing only one frequency component
153 * at band center is preserved with bandpass mode and a
154 * 2000Hz frequency band around rate/4 */
155 GST_START_TEST (test_type1_32_bp_11025hz)
157 GstElement *audiochebband;
158 GstBuffer *inbuffer, *outbuffer;
160 gfloat *in, *res, rms;
163 audiochebband = setup_audiochebband ();
164 /* Set to bandpass */
165 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
166 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
167 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
168 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
170 fail_unless (gst_element_set_state (audiochebband,
171 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
172 "could not set to playing");
174 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
175 44100 / 4.0 - 1000, NULL);
176 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
177 44100 / 4.0 + 1000, NULL);
178 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
179 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
180 for (i = 0; i < 1024; i += 4) {
187 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
188 gst_buffer_set_caps (inbuffer, caps);
189 gst_caps_unref (caps);
190 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
192 /* pushing gives away my reference ... */
193 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
194 /* ... and puts a new buffer on the global list */
195 fail_unless_equals_int (g_list_length (buffers), 1);
196 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
198 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
201 for (i = 0; i < 1024; i++)
202 rms += res[i] * res[i];
203 rms = sqrt (rms / 1024.0);
204 fail_unless (rms >= 0.6);
207 cleanup_audiochebband (audiochebband);
212 /* Test if data containing only one frequency component
213 * at rate/2 is erased with bandpass mode and a
214 * 2000Hz frequency band around rate/4 */
215 GST_START_TEST (test_type1_32_bp_22050hz)
217 GstElement *audiochebband;
218 GstBuffer *inbuffer, *outbuffer;
220 gfloat *in, *res, rms;
223 audiochebband = setup_audiochebband ();
224 /* Set to bandpass */
225 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
226 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
227 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
228 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
230 fail_unless (gst_element_set_state (audiochebband,
231 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
232 "could not set to playing");
234 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
235 44100 / 4.0 - 1000, NULL);
236 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
237 44100 / 4.0 + 1000, NULL);
238 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
239 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
240 for (i = 0; i < 1024; i += 2) {
245 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
246 gst_buffer_set_caps (inbuffer, caps);
247 gst_caps_unref (caps);
248 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
250 /* pushing gives away my reference ... */
251 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
252 /* ... and puts a new buffer on the global list */
253 fail_unless_equals_int (g_list_length (buffers), 1);
254 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
256 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
259 for (i = 0; i < 1024; i++)
260 rms += res[i] * res[i];
261 rms = sqrt (rms / 1024.0);
262 fail_unless (rms <= 0.1);
265 cleanup_audiochebband (audiochebband);
270 /* Test if data containing only one frequency component
271 * at 0 is preserved with bandreject mode and a
272 * 2000Hz frequency band around rate/4 */
273 GST_START_TEST (test_type1_32_br_0hz)
275 GstElement *audiochebband;
276 GstBuffer *inbuffer, *outbuffer;
278 gfloat *in, *res, rms;
281 audiochebband = setup_audiochebband ();
282 /* Set to bandreject */
283 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
284 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
285 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
286 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
288 fail_unless (gst_element_set_state (audiochebband,
289 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
290 "could not set to playing");
292 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
293 44100 / 4.0 - 1000, NULL);
294 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
295 44100 / 4.0 + 1000, NULL);
296 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
297 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
298 for (i = 0; i < 1024; i++)
301 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
302 gst_buffer_set_caps (inbuffer, caps);
303 gst_caps_unref (caps);
304 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
306 /* pushing gives away my reference ... */
307 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
308 /* ... and puts a new buffer on the global list */
309 fail_unless_equals_int (g_list_length (buffers), 1);
310 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
312 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
315 for (i = 0; i < 1024; i++)
316 rms += res[i] * res[i];
317 rms = sqrt (rms / 1024.0);
318 fail_unless (rms >= 0.9);
321 cleanup_audiochebband (audiochebband);
326 /* Test if data containing only one frequency component
327 * at band center is erased with bandreject mode and a
328 * 2000Hz frequency band around rate/4 */
329 GST_START_TEST (test_type1_32_br_11025hz)
331 GstElement *audiochebband;
332 GstBuffer *inbuffer, *outbuffer;
334 gfloat *in, *res, rms;
337 audiochebband = setup_audiochebband ();
338 /* Set to bandreject */
339 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
340 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
341 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
342 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
344 fail_unless (gst_element_set_state (audiochebband,
345 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
346 "could not set to playing");
348 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
349 44100 / 4.0 - 1000, NULL);
350 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
351 44100 / 4.0 + 1000, NULL);
352 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
353 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
354 for (i = 0; i < 1024; i += 4) {
361 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
362 gst_buffer_set_caps (inbuffer, caps);
363 gst_caps_unref (caps);
364 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
366 /* pushing gives away my reference ... */
367 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
368 /* ... and puts a new buffer on the global list */
369 fail_unless_equals_int (g_list_length (buffers), 1);
370 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
372 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
375 for (i = 0; i < 1024; i++)
376 rms += res[i] * res[i];
377 rms = sqrt (rms / 1024.0);
378 fail_unless (rms <= 0.1);
381 cleanup_audiochebband (audiochebband);
386 /* Test if data containing only one frequency component
387 * at rate/2 is preserved with bandreject mode and a
388 * 2000Hz frequency band around rate/4 */
389 GST_START_TEST (test_type1_32_br_22050hz)
391 GstElement *audiochebband;
392 GstBuffer *inbuffer, *outbuffer;
394 gfloat *in, *res, rms;
397 audiochebband = setup_audiochebband ();
398 /* Set to bandreject */
399 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
400 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
401 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
402 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
404 fail_unless (gst_element_set_state (audiochebband,
405 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
406 "could not set to playing");
408 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
409 44100 / 4.0 - 1000, NULL);
410 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
411 44100 / 4.0 + 1000, NULL);
412 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
413 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
414 for (i = 0; i < 1024; i += 2) {
419 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
420 gst_buffer_set_caps (inbuffer, caps);
421 gst_caps_unref (caps);
422 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
424 /* pushing gives away my reference ... */
425 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
426 /* ... and puts a new buffer on the global list */
427 fail_unless_equals_int (g_list_length (buffers), 1);
428 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
430 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
433 for (i = 0; i < 1024; i++)
434 rms += res[i] * res[i];
435 rms = sqrt (rms / 1024.0);
436 fail_unless (rms >= 0.9);
439 cleanup_audiochebband (audiochebband);
444 /* Test if data containing only one frequency component
445 * at 0 is erased with bandpass mode and a
446 * 2000Hz frequency band around rate/4 */
447 GST_START_TEST (test_type1_64_bp_0hz)
449 GstElement *audiochebband;
450 GstBuffer *inbuffer, *outbuffer;
452 gdouble *in, *res, rms;
455 audiochebband = setup_audiochebband ();
456 /* Set to bandpass */
457 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
458 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
459 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
460 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
462 fail_unless (gst_element_set_state (audiochebband,
463 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
464 "could not set to playing");
466 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
467 44100 / 4.0 - 1000, NULL);
468 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
469 44100 / 4.0 + 1000, NULL);
470 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
471 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
472 for (i = 0; i < 1024; i++)
475 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
476 gst_buffer_set_caps (inbuffer, caps);
477 gst_caps_unref (caps);
478 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
480 /* pushing gives away my reference ... */
481 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
482 /* ... and puts a new buffer on the global list */
483 fail_unless_equals_int (g_list_length (buffers), 1);
484 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
486 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
489 for (i = 0; i < 1024; i++)
490 rms += res[i] * res[i];
491 rms = sqrt (rms / 1024.0);
492 fail_unless (rms <= 0.1);
495 cleanup_audiochebband (audiochebband);
500 /* Test if data containing only one frequency component
501 * at band center is preserved with bandpass mode and a
502 * 2000Hz frequency band around rate/4 */
503 GST_START_TEST (test_type1_64_bp_11025hz)
505 GstElement *audiochebband;
506 GstBuffer *inbuffer, *outbuffer;
508 gdouble *in, *res, rms;
511 audiochebband = setup_audiochebband ();
512 /* Set to bandpass */
513 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
514 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
515 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
516 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
518 fail_unless (gst_element_set_state (audiochebband,
519 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
520 "could not set to playing");
522 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
523 44100 / 4.0 - 1000, NULL);
524 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
525 44100 / 4.0 + 1000, NULL);
526 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
527 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
528 for (i = 0; i < 1024; i += 4) {
535 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
536 gst_buffer_set_caps (inbuffer, caps);
537 gst_caps_unref (caps);
538 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
540 /* pushing gives away my reference ... */
541 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
542 /* ... and puts a new buffer on the global list */
543 fail_unless_equals_int (g_list_length (buffers), 1);
544 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
546 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
549 for (i = 0; i < 1024; i++)
550 rms += res[i] * res[i];
551 rms = sqrt (rms / 1024.0);
552 fail_unless (rms >= 0.6);
555 cleanup_audiochebband (audiochebband);
560 /* Test if data containing only one frequency component
561 * at rate/2 is erased with bandpass mode and a
562 * 2000Hz frequency band around rate/4 */
563 GST_START_TEST (test_type1_64_bp_22050hz)
565 GstElement *audiochebband;
566 GstBuffer *inbuffer, *outbuffer;
568 gdouble *in, *res, rms;
571 audiochebband = setup_audiochebband ();
572 /* Set to bandpass */
573 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
574 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
575 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
576 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
578 fail_unless (gst_element_set_state (audiochebband,
579 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
580 "could not set to playing");
582 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
583 44100 / 4.0 - 1000, NULL);
584 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
585 44100 / 4.0 + 1000, NULL);
586 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
587 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
588 for (i = 0; i < 1024; i += 2) {
593 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
594 gst_buffer_set_caps (inbuffer, caps);
595 gst_caps_unref (caps);
596 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
598 /* pushing gives away my reference ... */
599 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
600 /* ... and puts a new buffer on the global list */
601 fail_unless_equals_int (g_list_length (buffers), 1);
602 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
604 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
607 for (i = 0; i < 1024; i++)
608 rms += res[i] * res[i];
609 rms = sqrt (rms / 1024.0);
610 fail_unless (rms <= 0.1);
613 cleanup_audiochebband (audiochebband);
618 /* Test if data containing only one frequency component
619 * at 0 is preserved with bandreject mode and a
620 * 2000Hz frequency band around rate/4 */
621 GST_START_TEST (test_type1_64_br_0hz)
623 GstElement *audiochebband;
624 GstBuffer *inbuffer, *outbuffer;
626 gdouble *in, *res, rms;
629 audiochebband = setup_audiochebband ();
630 /* Set to bandreject */
631 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
632 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
633 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
634 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
636 fail_unless (gst_element_set_state (audiochebband,
637 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
638 "could not set to playing");
640 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
641 44100 / 4.0 - 1000, NULL);
642 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
643 44100 / 4.0 + 1000, NULL);
644 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
645 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
646 for (i = 0; i < 1024; i++)
649 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
650 gst_buffer_set_caps (inbuffer, caps);
651 gst_caps_unref (caps);
652 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
654 /* pushing gives away my reference ... */
655 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
656 /* ... and puts a new buffer on the global list */
657 fail_unless_equals_int (g_list_length (buffers), 1);
658 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
660 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
663 for (i = 0; i < 1024; i++)
664 rms += res[i] * res[i];
665 rms = sqrt (rms / 1024.0);
666 fail_unless (rms >= 0.9);
669 cleanup_audiochebband (audiochebband);
674 /* Test if data containing only one frequency component
675 * at band center is erased with bandreject mode and a
676 * 2000Hz frequency band around rate/4 */
677 GST_START_TEST (test_type1_64_br_11025hz)
679 GstElement *audiochebband;
680 GstBuffer *inbuffer, *outbuffer;
682 gdouble *in, *res, rms;
685 audiochebband = setup_audiochebband ();
686 /* Set to bandreject */
687 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
688 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
689 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
690 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
692 fail_unless (gst_element_set_state (audiochebband,
693 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
694 "could not set to playing");
696 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
697 44100 / 4.0 - 1000, NULL);
698 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
699 44100 / 4.0 + 1000, NULL);
700 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
701 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
702 for (i = 0; i < 1024; i += 4) {
709 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
710 gst_buffer_set_caps (inbuffer, caps);
711 gst_caps_unref (caps);
712 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
714 /* pushing gives away my reference ... */
715 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
716 /* ... and puts a new buffer on the global list */
717 fail_unless_equals_int (g_list_length (buffers), 1);
718 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
720 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
723 for (i = 0; i < 1024; i++)
724 rms += res[i] * res[i];
725 rms = sqrt (rms / 1024.0);
726 fail_unless (rms <= 0.1);
729 cleanup_audiochebband (audiochebband);
734 /* Test if data containing only one frequency component
735 * at rate/2 is preserved with bandreject mode and a
736 * 2000Hz frequency band around rate/4 */
737 GST_START_TEST (test_type1_64_br_22050hz)
739 GstElement *audiochebband;
740 GstBuffer *inbuffer, *outbuffer;
742 gdouble *in, *res, rms;
745 audiochebband = setup_audiochebband ();
746 /* Set to bandreject */
747 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
748 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
749 g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
750 g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
752 fail_unless (gst_element_set_state (audiochebband,
753 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
754 "could not set to playing");
756 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
757 44100 / 4.0 - 1000, NULL);
758 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
759 44100 / 4.0 + 1000, NULL);
760 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
761 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
762 for (i = 0; i < 1024; i += 2) {
767 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
768 gst_buffer_set_caps (inbuffer, caps);
769 gst_caps_unref (caps);
770 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
772 /* pushing gives away my reference ... */
773 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
774 /* ... and puts a new buffer on the global list */
775 fail_unless_equals_int (g_list_length (buffers), 1);
776 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
778 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
781 for (i = 0; i < 1024; i++)
782 rms += res[i] * res[i];
783 rms = sqrt (rms / 1024.0);
784 fail_unless (rms >= 0.9);
787 cleanup_audiochebband (audiochebband);
792 /* Test if data containing only one frequency component
793 * at 0 is erased with bandpass mode and a
794 * 2000Hz frequency band around rate/4 */
795 GST_START_TEST (test_type2_32_bp_0hz)
797 GstElement *audiochebband;
798 GstBuffer *inbuffer, *outbuffer;
800 gfloat *in, *res, rms;
803 audiochebband = setup_audiochebband ();
804 /* Set to bandpass */
805 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
806 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
807 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
808 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
810 fail_unless (gst_element_set_state (audiochebband,
811 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
812 "could not set to playing");
814 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
815 44100 / 4.0 - 1000, NULL);
816 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
817 44100 / 4.0 + 1000, NULL);
818 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
819 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
820 for (i = 0; i < 1024; i++)
823 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
824 gst_buffer_set_caps (inbuffer, caps);
825 gst_caps_unref (caps);
826 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
828 /* pushing gives away my reference ... */
829 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
830 /* ... and puts a new buffer on the global list */
831 fail_unless_equals_int (g_list_length (buffers), 1);
832 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
834 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
837 for (i = 0; i < 1024; i++)
838 rms += res[i] * res[i];
839 rms = sqrt (rms / 1024.0);
840 fail_unless (rms <= 0.1);
843 cleanup_audiochebband (audiochebband);
848 /* Test if data containing only one frequency component
849 * at band center is preserved with bandpass mode and a
850 * 2000Hz frequency band around rate/4 */
851 GST_START_TEST (test_type2_32_bp_11025hz)
853 GstElement *audiochebband;
854 GstBuffer *inbuffer, *outbuffer;
856 gfloat *in, *res, rms;
859 audiochebband = setup_audiochebband ();
860 /* Set to bandpass */
861 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
862 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
863 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
864 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
866 fail_unless (gst_element_set_state (audiochebband,
867 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
868 "could not set to playing");
870 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
871 44100 / 4.0 - 1000, NULL);
872 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
873 44100 / 4.0 + 1000, NULL);
874 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
875 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
876 for (i = 0; i < 1024; i += 4) {
883 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
884 gst_buffer_set_caps (inbuffer, caps);
885 gst_caps_unref (caps);
886 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
888 /* pushing gives away my reference ... */
889 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
890 /* ... and puts a new buffer on the global list */
891 fail_unless_equals_int (g_list_length (buffers), 1);
892 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
894 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
897 for (i = 0; i < 1024; i++)
898 rms += res[i] * res[i];
899 rms = sqrt (rms / 1024.0);
900 fail_unless (rms >= 0.6);
903 cleanup_audiochebband (audiochebband);
908 /* Test if data containing only one frequency component
909 * at rate/2 is erased with bandpass mode and a
910 * 2000Hz frequency band around rate/4 */
911 GST_START_TEST (test_type2_32_bp_22050hz)
913 GstElement *audiochebband;
914 GstBuffer *inbuffer, *outbuffer;
916 gfloat *in, *res, rms;
919 audiochebband = setup_audiochebband ();
920 /* Set to bandpass */
921 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
922 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
923 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
924 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
926 fail_unless (gst_element_set_state (audiochebband,
927 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
928 "could not set to playing");
930 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
931 44100 / 4.0 - 1000, NULL);
932 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
933 44100 / 4.0 + 1000, NULL);
934 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
935 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
936 for (i = 0; i < 1024; i += 2) {
941 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
942 gst_buffer_set_caps (inbuffer, caps);
943 gst_caps_unref (caps);
944 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
946 /* pushing gives away my reference ... */
947 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
948 /* ... and puts a new buffer on the global list */
949 fail_unless_equals_int (g_list_length (buffers), 1);
950 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
952 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
955 for (i = 0; i < 1024; i++)
956 rms += res[i] * res[i];
957 rms = sqrt (rms / 1024.0);
958 fail_unless (rms <= 0.1);
961 cleanup_audiochebband (audiochebband);
966 /* Test if data containing only one frequency component
967 * at 0 is preserved with bandreject mode and a
968 * 2000Hz frequency band around rate/4 */
969 GST_START_TEST (test_type2_32_br_0hz)
971 GstElement *audiochebband;
972 GstBuffer *inbuffer, *outbuffer;
974 gfloat *in, *res, rms;
977 audiochebband = setup_audiochebband ();
978 /* Set to bandreject */
979 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
980 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
981 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
982 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
984 fail_unless (gst_element_set_state (audiochebband,
985 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
986 "could not set to playing");
988 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
989 44100 / 4.0 - 1000, NULL);
990 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
991 44100 / 4.0 + 1000, NULL);
992 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
993 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
994 for (i = 0; i < 1024; i++)
997 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
998 gst_buffer_set_caps (inbuffer, caps);
999 gst_caps_unref (caps);
1000 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1002 /* pushing gives away my reference ... */
1003 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1004 /* ... and puts a new buffer on the global list */
1005 fail_unless_equals_int (g_list_length (buffers), 1);
1006 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1008 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
1011 for (i = 0; i < 1024; i++)
1012 rms += res[i] * res[i];
1013 rms = sqrt (rms / 1024.0);
1014 fail_unless (rms >= 0.9);
1017 cleanup_audiochebband (audiochebband);
1022 /* Test if data containing only one frequency component
1023 * at band center is erased with bandreject mode and a
1024 * 2000Hz frequency band around rate/4 */
1025 GST_START_TEST (test_type2_32_br_11025hz)
1027 GstElement *audiochebband;
1028 GstBuffer *inbuffer, *outbuffer;
1030 gfloat *in, *res, rms;
1033 audiochebband = setup_audiochebband ();
1034 /* Set to bandreject */
1035 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1036 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1037 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1038 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1040 fail_unless (gst_element_set_state (audiochebband,
1041 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1042 "could not set to playing");
1044 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1045 44100 / 4.0 - 1000, NULL);
1046 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1047 44100 / 4.0 + 1000, NULL);
1048 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
1049 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
1050 for (i = 0; i < 1024; i += 4) {
1057 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1058 gst_buffer_set_caps (inbuffer, caps);
1059 gst_caps_unref (caps);
1060 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1062 /* pushing gives away my reference ... */
1063 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1064 /* ... and puts a new buffer on the global list */
1065 fail_unless_equals_int (g_list_length (buffers), 1);
1066 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1068 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
1071 for (i = 0; i < 1024; i++)
1072 rms += res[i] * res[i];
1073 rms = sqrt (rms / 1024.0);
1074 fail_unless (rms <= 0.1);
1077 cleanup_audiochebband (audiochebband);
1082 /* Test if data containing only one frequency component
1083 * at rate/2 is preserved with bandreject mode and a
1084 * 2000Hz frequency band around rate/4 */
1085 GST_START_TEST (test_type2_32_br_22050hz)
1087 GstElement *audiochebband;
1088 GstBuffer *inbuffer, *outbuffer;
1090 gfloat *in, *res, rms;
1093 audiochebband = setup_audiochebband ();
1094 /* Set to bandreject */
1095 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1096 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1097 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1098 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1100 fail_unless (gst_element_set_state (audiochebband,
1101 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1102 "could not set to playing");
1104 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1105 44100 / 4.0 - 1000, NULL);
1106 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1107 44100 / 4.0 + 1000, NULL);
1108 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
1109 in = (gfloat *) GST_BUFFER_DATA (inbuffer);
1110 for (i = 0; i < 1024; i += 2) {
1115 caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1116 gst_buffer_set_caps (inbuffer, caps);
1117 gst_caps_unref (caps);
1118 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1120 /* pushing gives away my reference ... */
1121 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1122 /* ... and puts a new buffer on the global list */
1123 fail_unless_equals_int (g_list_length (buffers), 1);
1124 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1126 res = (gfloat *) GST_BUFFER_DATA (outbuffer);
1129 for (i = 0; i < 1024; i++)
1130 rms += res[i] * res[i];
1131 rms = sqrt (rms / 1024.0);
1132 fail_unless (rms >= 0.9);
1135 cleanup_audiochebband (audiochebband);
1140 /* Test if data containing only one frequency component
1141 * at 0 is erased with bandpass mode and a
1142 * 2000Hz frequency band around rate/4 */
1143 GST_START_TEST (test_type2_64_bp_0hz)
1145 GstElement *audiochebband;
1146 GstBuffer *inbuffer, *outbuffer;
1148 gdouble *in, *res, rms;
1151 audiochebband = setup_audiochebband ();
1152 /* Set to bandpass */
1153 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1154 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1155 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1156 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1158 fail_unless (gst_element_set_state (audiochebband,
1159 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1160 "could not set to playing");
1162 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1163 44100 / 4.0 - 1000, NULL);
1164 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1165 44100 / 4.0 + 1000, NULL);
1166 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1167 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1168 for (i = 0; i < 1024; i++)
1171 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1172 gst_buffer_set_caps (inbuffer, caps);
1173 gst_caps_unref (caps);
1174 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1176 /* pushing gives away my reference ... */
1177 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1178 /* ... and puts a new buffer on the global list */
1179 fail_unless_equals_int (g_list_length (buffers), 1);
1180 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1182 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1185 for (i = 0; i < 1024; i++)
1186 rms += res[i] * res[i];
1187 rms = sqrt (rms / 1024.0);
1188 fail_unless (rms <= 0.1);
1191 cleanup_audiochebband (audiochebband);
1196 /* Test if data containing only one frequency component
1197 * at band center is preserved with bandpass mode and a
1198 * 2000Hz frequency band around rate/4 */
1199 GST_START_TEST (test_type2_64_bp_11025hz)
1201 GstElement *audiochebband;
1202 GstBuffer *inbuffer, *outbuffer;
1204 gdouble *in, *res, rms;
1207 audiochebband = setup_audiochebband ();
1208 /* Set to bandpass */
1209 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1210 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1211 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1212 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1214 fail_unless (gst_element_set_state (audiochebband,
1215 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1216 "could not set to playing");
1218 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1219 44100 / 4.0 - 1000, NULL);
1220 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1221 44100 / 4.0 + 1000, NULL);
1222 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1223 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1224 for (i = 0; i < 1024; i += 4) {
1231 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1232 gst_buffer_set_caps (inbuffer, caps);
1233 gst_caps_unref (caps);
1234 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1236 /* pushing gives away my reference ... */
1237 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1238 /* ... and puts a new buffer on the global list */
1239 fail_unless_equals_int (g_list_length (buffers), 1);
1240 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1242 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1245 for (i = 0; i < 1024; i++)
1246 rms += res[i] * res[i];
1247 rms = sqrt (rms / 1024.0);
1248 fail_unless (rms >= 0.6);
1251 cleanup_audiochebband (audiochebband);
1256 /* Test if data containing only one frequency component
1257 * at rate/2 is erased with bandpass mode and a
1258 * 2000Hz frequency band around rate/4 */
1259 GST_START_TEST (test_type2_64_bp_22050hz)
1261 GstElement *audiochebband;
1262 GstBuffer *inbuffer, *outbuffer;
1264 gdouble *in, *res, rms;
1267 audiochebband = setup_audiochebband ();
1268 /* Set to bandpass */
1269 g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1270 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1271 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1272 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1274 fail_unless (gst_element_set_state (audiochebband,
1275 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1276 "could not set to playing");
1278 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1279 44100 / 4.0 - 1000, NULL);
1280 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1281 44100 / 4.0 + 1000, NULL);
1282 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1283 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1284 for (i = 0; i < 1024; i += 2) {
1289 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1290 gst_buffer_set_caps (inbuffer, caps);
1291 gst_caps_unref (caps);
1292 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1294 /* pushing gives away my reference ... */
1295 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1296 /* ... and puts a new buffer on the global list */
1297 fail_unless_equals_int (g_list_length (buffers), 1);
1298 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1300 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1303 for (i = 0; i < 1024; i++)
1304 rms += res[i] * res[i];
1305 rms = sqrt (rms / 1024.0);
1306 fail_unless (rms <= 0.1);
1309 cleanup_audiochebband (audiochebband);
1314 /* Test if data containing only one frequency component
1315 * at 0 is preserved with bandreject mode and a
1316 * 2000Hz frequency band around rate/4 */
1317 GST_START_TEST (test_type2_64_br_0hz)
1319 GstElement *audiochebband;
1320 GstBuffer *inbuffer, *outbuffer;
1322 gdouble *in, *res, rms;
1325 audiochebband = setup_audiochebband ();
1326 /* Set to bandreject */
1327 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1328 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1329 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1330 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1332 fail_unless (gst_element_set_state (audiochebband,
1333 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1334 "could not set to playing");
1336 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1337 44100 / 4.0 - 1000, NULL);
1338 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1339 44100 / 4.0 + 1000, NULL);
1340 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1341 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1342 for (i = 0; i < 1024; i++)
1345 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1346 gst_buffer_set_caps (inbuffer, caps);
1347 gst_caps_unref (caps);
1348 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1350 /* pushing gives away my reference ... */
1351 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1352 /* ... and puts a new buffer on the global list */
1353 fail_unless_equals_int (g_list_length (buffers), 1);
1354 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1356 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1359 for (i = 0; i < 1024; i++)
1360 rms += res[i] * res[i];
1361 rms = sqrt (rms / 1024.0);
1362 fail_unless (rms >= 0.9);
1365 cleanup_audiochebband (audiochebband);
1370 /* Test if data containing only one frequency component
1371 * at band center is erased with bandreject mode and a
1372 * 2000Hz frequency band around rate/4 */
1373 GST_START_TEST (test_type2_64_br_11025hz)
1375 GstElement *audiochebband;
1376 GstBuffer *inbuffer, *outbuffer;
1378 gdouble *in, *res, rms;
1381 audiochebband = setup_audiochebband ();
1382 /* Set to bandreject */
1383 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1384 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1385 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1386 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1388 fail_unless (gst_element_set_state (audiochebband,
1389 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1390 "could not set to playing");
1392 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1393 44100 / 4.0 - 1000, NULL);
1394 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1395 44100 / 4.0 + 1000, NULL);
1396 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1397 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1398 for (i = 0; i < 1024; i += 4) {
1405 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1406 gst_buffer_set_caps (inbuffer, caps);
1407 gst_caps_unref (caps);
1408 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1410 /* pushing gives away my reference ... */
1411 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1412 /* ... and puts a new buffer on the global list */
1413 fail_unless_equals_int (g_list_length (buffers), 1);
1414 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1416 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1419 for (i = 0; i < 1024; i++)
1420 rms += res[i] * res[i];
1421 rms = sqrt (rms / 1024.0);
1422 fail_unless (rms <= 0.1);
1425 cleanup_audiochebband (audiochebband);
1430 /* Test if data containing only one frequency component
1431 * at rate/2 is preserved with bandreject mode and a
1432 * 2000Hz frequency band around rate/4 */
1433 GST_START_TEST (test_type2_64_br_22050hz)
1435 GstElement *audiochebband;
1436 GstBuffer *inbuffer, *outbuffer;
1438 gdouble *in, *res, rms;
1441 audiochebband = setup_audiochebband ();
1442 /* Set to bandreject */
1443 g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1444 g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1445 g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1446 g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1448 fail_unless (gst_element_set_state (audiochebband,
1449 GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1450 "could not set to playing");
1452 g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1453 44100 / 4.0 - 1000, NULL);
1454 g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1455 44100 / 4.0 + 1000, NULL);
1456 inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1457 in = (gdouble *) GST_BUFFER_DATA (inbuffer);
1458 for (i = 0; i < 1024; i += 2) {
1463 caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1464 gst_buffer_set_caps (inbuffer, caps);
1465 gst_caps_unref (caps);
1466 ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1468 /* pushing gives away my reference ... */
1469 fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1470 /* ... and puts a new buffer on the global list */
1471 fail_unless_equals_int (g_list_length (buffers), 1);
1472 fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1474 res = (gdouble *) GST_BUFFER_DATA (outbuffer);
1477 for (i = 0; i < 1024; i++)
1478 rms += res[i] * res[i];
1479 rms = sqrt (rms / 1024.0);
1480 fail_unless (rms >= 0.9);
1483 cleanup_audiochebband (audiochebband);
1489 audiochebband_suite (void)
1491 Suite *s = suite_create ("audiochebband");
1492 TCase *tc_chain = tcase_create ("general");
1494 suite_add_tcase (s, tc_chain);
1495 tcase_add_test (tc_chain, test_type1_32_bp_0hz);
1496 tcase_add_test (tc_chain, test_type1_32_bp_11025hz);
1497 tcase_add_test (tc_chain, test_type1_32_bp_22050hz);
1498 tcase_add_test (tc_chain, test_type1_32_br_0hz);
1499 tcase_add_test (tc_chain, test_type1_32_br_11025hz);
1500 tcase_add_test (tc_chain, test_type1_32_br_22050hz);
1501 tcase_add_test (tc_chain, test_type1_64_bp_0hz);
1502 tcase_add_test (tc_chain, test_type1_64_bp_11025hz);
1503 tcase_add_test (tc_chain, test_type1_64_bp_22050hz);
1504 tcase_add_test (tc_chain, test_type1_64_br_0hz);
1505 tcase_add_test (tc_chain, test_type1_64_br_11025hz);
1506 tcase_add_test (tc_chain, test_type1_64_br_22050hz);
1507 tcase_add_test (tc_chain, test_type2_32_bp_0hz);
1508 tcase_add_test (tc_chain, test_type2_32_bp_11025hz);
1509 tcase_add_test (tc_chain, test_type2_32_bp_22050hz);
1510 tcase_add_test (tc_chain, test_type2_32_br_0hz);
1511 tcase_add_test (tc_chain, test_type2_32_br_11025hz);
1512 tcase_add_test (tc_chain, test_type2_32_br_22050hz);
1513 tcase_add_test (tc_chain, test_type2_64_bp_0hz);
1514 tcase_add_test (tc_chain, test_type2_64_bp_11025hz);
1515 tcase_add_test (tc_chain, test_type2_64_bp_22050hz);
1516 tcase_add_test (tc_chain, test_type2_64_br_0hz);
1517 tcase_add_test (tc_chain, test_type2_64_br_11025hz);
1518 tcase_add_test (tc_chain, test_type2_64_br_22050hz);
1524 main (int argc, char **argv)
1528 Suite *s = audiochebband_suite ();
1529 SRunner *sr = srunner_create (s);
1531 gst_check_init (&argc, &argv);
1533 srunner_run_all (sr, CK_NORMAL);
1534 nf = srunner_ntests_failed (sr);