1 /* GStreamer
2  *
3  * Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
4  *
5  * audiochebband.c: Unit test for the audiochebband element
6  *
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.
11  *
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.
16  *
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
20  * 02110-1301 USA
21  */
22 
23 #include <gst/gst.h>
24 #include <gst/base/gstbasetransform.h>
25 #include <gst/audio/audio.h>
26 #include <gst/check/gstcheck.h>
27 
28 #include <math.h>
29 
30 /* For ease of programming we use globals to keep refs for our floating
31  * src and sink pads we create; otherwise we always have to do get_pad,
32  * get_peer, and then remove references in every test function */
33 GstPad *mysrcpad, *mysinkpad;
34 
35 #define BUFFER_CAPS_STRING_32           \
36     "audio/x-raw, "                     \
37     "channels = (int) 1, "              \
38     "rate = (int) 44100, "              \
39     "layout = (string) interleaved, "   \
40     "format = (string) " GST_AUDIO_NE(F32)
41 
42 #define BUFFER_CAPS_STRING_64           \
43     "audio/x-raw, "                     \
44     "channels = (int) 1, "              \
45     "rate = (int) 44100, "              \
46     "layout = (string) interleaved, "   \
47     "format = (string) " GST_AUDIO_NE(F64)
48 
49 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
50     GST_PAD_SINK,
51     GST_PAD_ALWAYS,
52     GST_STATIC_CAPS ("audio/x-raw, "
53         "channels = (int) 1, "
54         "rate = (int) 44100, "
55         "layout = (string) interleaved, "
56         "format = (string) { "
57         GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (F64) " }"));
58 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
59     GST_PAD_SRC,
60     GST_PAD_ALWAYS,
61     GST_STATIC_CAPS ("audio/x-raw, "
62         "channels = (int) 1, "
63         "rate = (int) 44100, "
64         "layout = (string) interleaved, "
65         "format = (string) { "
66         GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (F64) " }"));
67 
68 static GstElement *
setup_audiochebband(void)69 setup_audiochebband (void)
70 {
71   GstElement *audiochebband;
72 
73   GST_DEBUG ("setup_audiochebband");
74   audiochebband = gst_check_setup_element ("audiochebband");
75   mysrcpad = gst_check_setup_src_pad (audiochebband, &srctemplate);
76   mysinkpad = gst_check_setup_sink_pad (audiochebband, &sinktemplate);
77   gst_pad_set_active (mysrcpad, TRUE);
78   gst_pad_set_active (mysinkpad, TRUE);
79 
80   return audiochebband;
81 }
82 
83 static void
cleanup_audiochebband(GstElement * audiochebband)84 cleanup_audiochebband (GstElement * audiochebband)
85 {
86   GST_DEBUG ("cleanup_audiochebband");
87 
88   g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
89   g_list_free (buffers);
90   buffers = NULL;
91 
92   gst_pad_set_active (mysrcpad, FALSE);
93   gst_pad_set_active (mysinkpad, FALSE);
94   gst_check_teardown_src_pad (audiochebband);
95   gst_check_teardown_sink_pad (audiochebband);
96   gst_check_teardown_element (audiochebband);
97 }
98 
99 /* Test if data containing only one frequency component
100  * at 0 is erased with bandpass mode and a
101  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_bp_0hz)102 GST_START_TEST (test_type1_32_bp_0hz)
103 {
104   GstElement *audiochebband;
105   GstBuffer *inbuffer, *outbuffer;
106   GstCaps *caps;
107   gfloat *in, *res, rms;
108   gint i;
109   GstMapInfo map;
110 
111   audiochebband = setup_audiochebband ();
112   /* Set to bandpass */
113   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
114   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
115   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
116   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
117 
118   fail_unless (gst_element_set_state (audiochebband,
119           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
120       "could not set to playing");
121 
122   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
123       44100 / 4.0 - 1000, NULL);
124   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
125       44100 / 4.0 + 1000, NULL);
126   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
127   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
128   in = (gfloat *) map.data;
129   for (i = 0; i < 1024; i++)
130     in[i] = 1.0;
131   gst_buffer_unmap (inbuffer, &map);
132 
133   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
134   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
135   gst_caps_unref (caps);
136   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
137 
138   /* pushing gives away my reference ... */
139   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
140   /* ... and puts a new buffer on the global list */
141   fail_unless_equals_int (g_list_length (buffers), 1);
142   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
143 
144   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
145   res = (gfloat *) map.data;
146 
147   rms = 0.0;
148   for (i = 0; i < 1024; i++)
149     rms += res[i] * res[i];
150   rms = sqrt (rms / 1024.0);
151   fail_unless (rms <= 0.1);
152 
153   gst_buffer_unmap (outbuffer, &map);
154 
155   /* cleanup */
156   cleanup_audiochebband (audiochebband);
157 }
158 
159 GST_END_TEST;
160 
161 /* Test if data containing only one frequency component
162  * at band center is preserved with bandpass mode and a
163  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_bp_11025hz)164 GST_START_TEST (test_type1_32_bp_11025hz)
165 {
166   GstElement *audiochebband;
167   GstBuffer *inbuffer, *outbuffer;
168   GstCaps *caps;
169   gfloat *in, *res, rms;
170   gint i;
171   GstMapInfo map;
172 
173   audiochebband = setup_audiochebband ();
174   /* Set to bandpass */
175   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
176   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
177   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
178   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
179 
180   fail_unless (gst_element_set_state (audiochebband,
181           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
182       "could not set to playing");
183 
184   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
185       44100 / 4.0 - 1000, NULL);
186   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
187       44100 / 4.0 + 1000, NULL);
188   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
189   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
190   in = (gfloat *) map.data;
191   for (i = 0; i < 1024; i += 4) {
192     in[i] = 0.0;
193     in[i + 1] = 1.0;
194     in[i + 2] = 0.0;
195     in[i + 3] = -1.0;
196   }
197   gst_buffer_unmap (inbuffer, &map);
198 
199   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
200   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
201   gst_caps_unref (caps);
202   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
203 
204   /* pushing gives away my reference ... */
205   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
206   /* ... and puts a new buffer on the global list */
207   fail_unless_equals_int (g_list_length (buffers), 1);
208   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
209 
210   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
211   res = (gfloat *) map.data;
212 
213   rms = 0.0;
214   for (i = 0; i < 1024; i++)
215     rms += res[i] * res[i];
216   rms = sqrt (rms / 1024.0);
217   fail_unless (rms >= 0.6);
218 
219   gst_buffer_unmap (outbuffer, &map);
220 
221   /* cleanup */
222   cleanup_audiochebband (audiochebband);
223 }
224 
225 GST_END_TEST;
226 
227 /* Test if data containing only one frequency component
228  * at rate/2 is erased with bandpass mode and a
229  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_bp_22050hz)230 GST_START_TEST (test_type1_32_bp_22050hz)
231 {
232   GstElement *audiochebband;
233   GstBuffer *inbuffer, *outbuffer;
234   GstCaps *caps;
235   gfloat *in, *res, rms;
236   gint i;
237   GstMapInfo map;
238 
239   audiochebband = setup_audiochebband ();
240   /* Set to bandpass */
241   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
242   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
243   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
244   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
245 
246   fail_unless (gst_element_set_state (audiochebband,
247           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
248       "could not set to playing");
249 
250   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
251       44100 / 4.0 - 1000, NULL);
252   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
253       44100 / 4.0 + 1000, NULL);
254   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
255   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
256   in = (gfloat *) map.data;
257   for (i = 0; i < 1024; i += 2) {
258     in[i] = 1.0;
259     in[i + 1] = -1.0;
260   }
261   gst_buffer_unmap (inbuffer, &map);
262 
263   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
264   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
265   gst_caps_unref (caps);
266   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
267 
268   /* pushing gives away my reference ... */
269   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
270   /* ... and puts a new buffer on the global list */
271   fail_unless_equals_int (g_list_length (buffers), 1);
272   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
273 
274   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
275   res = (gfloat *) map.data;
276 
277   rms = 0.0;
278   for (i = 0; i < 1024; i++)
279     rms += res[i] * res[i];
280   rms = sqrt (rms / 1024.0);
281   fail_unless (rms <= 0.1);
282 
283   gst_buffer_unmap (outbuffer, &map);
284 
285   /* cleanup */
286   cleanup_audiochebband (audiochebband);
287 }
288 
289 GST_END_TEST;
290 
291 /* Test if data containing only one frequency component
292  * at 0 is preserved with bandreject mode and a
293  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_br_0hz)294 GST_START_TEST (test_type1_32_br_0hz)
295 {
296   GstElement *audiochebband;
297   GstBuffer *inbuffer, *outbuffer;
298   GstCaps *caps;
299   gfloat *in, *res, rms;
300   gint i;
301   GstMapInfo map;
302 
303   audiochebband = setup_audiochebband ();
304   /* Set to bandreject */
305   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
306   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
307   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
308   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
309 
310   fail_unless (gst_element_set_state (audiochebband,
311           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
312       "could not set to playing");
313 
314   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
315       44100 / 4.0 - 1000, NULL);
316   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
317       44100 / 4.0 + 1000, NULL);
318   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
319   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
320   in = (gfloat *) map.data;
321   for (i = 0; i < 1024; i++)
322     in[i] = 1.0;
323   gst_buffer_unmap (inbuffer, &map);
324 
325   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
326   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
327   gst_caps_unref (caps);
328   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
329 
330   /* pushing gives away my reference ... */
331   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
332   /* ... and puts a new buffer on the global list */
333   fail_unless_equals_int (g_list_length (buffers), 1);
334   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
335 
336   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
337   res = (gfloat *) map.data;
338 
339   rms = 0.0;
340   for (i = 0; i < 1024; i++)
341     rms += res[i] * res[i];
342   rms = sqrt (rms / 1024.0);
343   fail_unless (rms >= 0.9);
344 
345   gst_buffer_unmap (outbuffer, &map);
346 
347   /* cleanup */
348   cleanup_audiochebband (audiochebband);
349 }
350 
351 GST_END_TEST;
352 
353 /* Test if data containing only one frequency component
354  * at band center is erased with bandreject mode and a
355  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_br_11025hz)356 GST_START_TEST (test_type1_32_br_11025hz)
357 {
358   GstElement *audiochebband;
359   GstBuffer *inbuffer, *outbuffer;
360   GstCaps *caps;
361   gfloat *in, *res, rms;
362   gint i;
363   GstMapInfo map;
364 
365   audiochebband = setup_audiochebband ();
366   /* Set to bandreject */
367   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
368   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
369   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
370   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
371 
372   fail_unless (gst_element_set_state (audiochebband,
373           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
374       "could not set to playing");
375 
376   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
377       44100 / 4.0 - 1000, NULL);
378   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
379       44100 / 4.0 + 1000, NULL);
380   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
381   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
382   in = (gfloat *) map.data;
383   for (i = 0; i < 1024; i += 4) {
384     in[i] = 0.0;
385     in[i + 1] = 1.0;
386     in[i + 2] = 0.0;
387     in[i + 3] = -1.0;
388   }
389   gst_buffer_unmap (inbuffer, &map);
390 
391   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
392   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
393   gst_caps_unref (caps);
394   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
395 
396   /* pushing gives away my reference ... */
397   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
398   /* ... and puts a new buffer on the global list */
399   fail_unless_equals_int (g_list_length (buffers), 1);
400   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
401 
402   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
403   res = (gfloat *) map.data;
404 
405   rms = 0.0;
406   for (i = 0; i < 1024; i++)
407     rms += res[i] * res[i];
408   rms = sqrt (rms / 1024.0);
409   fail_unless (rms <= 0.1);
410 
411   gst_buffer_unmap (outbuffer, &map);
412 
413   /* cleanup */
414   cleanup_audiochebband (audiochebband);
415 }
416 
417 GST_END_TEST;
418 
419 /* Test if data containing only one frequency component
420  * at rate/2 is preserved with bandreject mode and a
421  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_32_br_22050hz)422 GST_START_TEST (test_type1_32_br_22050hz)
423 {
424   GstElement *audiochebband;
425   GstBuffer *inbuffer, *outbuffer;
426   GstCaps *caps;
427   gfloat *in, *res, rms;
428   gint i;
429   GstMapInfo map;
430 
431   audiochebband = setup_audiochebband ();
432   /* Set to bandreject */
433   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
434   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
435   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
436   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
437 
438   fail_unless (gst_element_set_state (audiochebband,
439           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
440       "could not set to playing");
441 
442   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
443       44100 / 4.0 - 1000, NULL);
444   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
445       44100 / 4.0 + 1000, NULL);
446   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
447   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
448   in = (gfloat *) map.data;
449   for (i = 0; i < 1024; i += 2) {
450     in[i] = 1.0;
451     in[i + 1] = -1.0;
452   }
453   gst_buffer_unmap (inbuffer, &map);
454 
455   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
456   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
457   gst_caps_unref (caps);
458   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
459 
460   /* pushing gives away my reference ... */
461   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
462   /* ... and puts a new buffer on the global list */
463   fail_unless_equals_int (g_list_length (buffers), 1);
464   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
465 
466   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
467   res = (gfloat *) map.data;
468 
469   rms = 0.0;
470   for (i = 0; i < 1024; i++)
471     rms += res[i] * res[i];
472   rms = sqrt (rms / 1024.0);
473   fail_unless (rms >= 0.9);
474 
475   gst_buffer_unmap (outbuffer, &map);
476 
477   /* cleanup */
478   cleanup_audiochebband (audiochebband);
479 }
480 
481 GST_END_TEST;
482 
483 /* Test if data containing only one frequency component
484  * at 0 is erased with bandpass mode and a
485  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_bp_0hz)486 GST_START_TEST (test_type1_64_bp_0hz)
487 {
488   GstElement *audiochebband;
489   GstBuffer *inbuffer, *outbuffer;
490   GstCaps *caps;
491   gdouble *in, *res, rms;
492   gint i;
493   GstMapInfo map;
494 
495   audiochebband = setup_audiochebband ();
496   /* Set to bandpass */
497   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
498   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
499   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
500   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
501 
502   fail_unless (gst_element_set_state (audiochebband,
503           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
504       "could not set to playing");
505 
506   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
507       44100 / 4.0 - 1000, NULL);
508   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
509       44100 / 4.0 + 1000, NULL);
510   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
511   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
512   in = (gdouble *) map.data;
513   for (i = 0; i < 1024; i++)
514     in[i] = 1.0;
515   gst_buffer_unmap (inbuffer, &map);
516 
517   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
518   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
519   gst_caps_unref (caps);
520   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
521 
522   /* pushing gives away my reference ... */
523   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
524   /* ... and puts a new buffer on the global list */
525   fail_unless_equals_int (g_list_length (buffers), 1);
526   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
527 
528   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
529   res = (gdouble *) map.data;
530 
531   rms = 0.0;
532   for (i = 0; i < 1024; i++)
533     rms += res[i] * res[i];
534   rms = sqrt (rms / 1024.0);
535   fail_unless (rms <= 0.1);
536 
537   gst_buffer_unmap (outbuffer, &map);
538 
539   /* cleanup */
540   cleanup_audiochebband (audiochebband);
541 }
542 
543 GST_END_TEST;
544 
545 /* Test if data containing only one frequency component
546  * at band center is preserved with bandpass mode and a
547  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_bp_11025hz)548 GST_START_TEST (test_type1_64_bp_11025hz)
549 {
550   GstElement *audiochebband;
551   GstBuffer *inbuffer, *outbuffer;
552   GstCaps *caps;
553   gdouble *in, *res, rms;
554   gint i;
555   GstMapInfo map;
556 
557   audiochebband = setup_audiochebband ();
558   /* Set to bandpass */
559   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
560   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
561   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
562   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
563 
564   fail_unless (gst_element_set_state (audiochebband,
565           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
566       "could not set to playing");
567 
568   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
569       44100 / 4.0 - 1000, NULL);
570   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
571       44100 / 4.0 + 1000, NULL);
572   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
573   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
574   in = (gdouble *) map.data;
575   for (i = 0; i < 1024; i += 4) {
576     in[i] = 0.0;
577     in[i + 1] = 1.0;
578     in[i + 2] = 0.0;
579     in[i + 3] = -1.0;
580   }
581   gst_buffer_unmap (inbuffer, &map);
582 
583   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
584   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
585   gst_caps_unref (caps);
586   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
587 
588   /* pushing gives away my reference ... */
589   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
590   /* ... and puts a new buffer on the global list */
591   fail_unless_equals_int (g_list_length (buffers), 1);
592   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
593 
594   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
595   res = (gdouble *) map.data;
596 
597   rms = 0.0;
598   for (i = 0; i < 1024; i++)
599     rms += res[i] * res[i];
600   rms = sqrt (rms / 1024.0);
601   fail_unless (rms >= 0.6);
602 
603   gst_buffer_unmap (outbuffer, &map);
604 
605   /* cleanup */
606   cleanup_audiochebband (audiochebband);
607 }
608 
609 GST_END_TEST;
610 
611 /* Test if data containing only one frequency component
612  * at rate/2 is erased with bandpass mode and a
613  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_bp_22050hz)614 GST_START_TEST (test_type1_64_bp_22050hz)
615 {
616   GstElement *audiochebband;
617   GstBuffer *inbuffer, *outbuffer;
618   GstCaps *caps;
619   gdouble *in, *res, rms;
620   gint i;
621   GstMapInfo map;
622 
623   audiochebband = setup_audiochebband ();
624   /* Set to bandpass */
625   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
626   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
627   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
628   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
629 
630   fail_unless (gst_element_set_state (audiochebband,
631           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
632       "could not set to playing");
633 
634   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
635       44100 / 4.0 - 1000, NULL);
636   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
637       44100 / 4.0 + 1000, NULL);
638   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
639   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
640   in = (gdouble *) map.data;
641   for (i = 0; i < 1024; i += 2) {
642     in[i] = 1.0;
643     in[i + 1] = -1.0;
644   }
645   gst_buffer_unmap (inbuffer, &map);
646 
647   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
648   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
649   gst_caps_unref (caps);
650   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
651 
652   /* pushing gives away my reference ... */
653   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
654   /* ... and puts a new buffer on the global list */
655   fail_unless_equals_int (g_list_length (buffers), 1);
656   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
657 
658   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
659   res = (gdouble *) map.data;
660 
661   rms = 0.0;
662   for (i = 0; i < 1024; i++)
663     rms += res[i] * res[i];
664   rms = sqrt (rms / 1024.0);
665   fail_unless (rms <= 0.1);
666 
667   gst_buffer_unmap (outbuffer, &map);
668 
669   /* cleanup */
670   cleanup_audiochebband (audiochebband);
671 }
672 
673 GST_END_TEST;
674 
675 /* Test if data containing only one frequency component
676  * at 0 is preserved with bandreject mode and a
677  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_br_0hz)678 GST_START_TEST (test_type1_64_br_0hz)
679 {
680   GstElement *audiochebband;
681   GstBuffer *inbuffer, *outbuffer;
682   GstCaps *caps;
683   gdouble *in, *res, rms;
684   gint i;
685   GstMapInfo map;
686 
687   audiochebband = setup_audiochebband ();
688   /* Set to bandreject */
689   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
690   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
691   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
692   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
693 
694   fail_unless (gst_element_set_state (audiochebband,
695           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
696       "could not set to playing");
697 
698   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
699       44100 / 4.0 - 1000, NULL);
700   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
701       44100 / 4.0 + 1000, NULL);
702   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
703   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
704   in = (gdouble *) map.data;
705   for (i = 0; i < 1024; i++)
706     in[i] = 1.0;
707   gst_buffer_unmap (inbuffer, &map);
708 
709   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
710   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
711   gst_caps_unref (caps);
712   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
713 
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);
719 
720   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
721   res = (gdouble *) map.data;
722 
723   rms = 0.0;
724   for (i = 0; i < 1024; i++)
725     rms += res[i] * res[i];
726   rms = sqrt (rms / 1024.0);
727   fail_unless (rms >= 0.9);
728 
729   gst_buffer_unmap (outbuffer, &map);
730 
731   /* cleanup */
732   cleanup_audiochebband (audiochebband);
733 }
734 
735 GST_END_TEST;
736 
737 /* Test if data containing only one frequency component
738  * at band center is erased with bandreject mode and a
739  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_br_11025hz)740 GST_START_TEST (test_type1_64_br_11025hz)
741 {
742   GstElement *audiochebband;
743   GstBuffer *inbuffer, *outbuffer;
744   GstCaps *caps;
745   gdouble *in, *res, rms;
746   gint i;
747   GstMapInfo map;
748 
749   audiochebband = setup_audiochebband ();
750   /* Set to bandreject */
751   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
752   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
753   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
754   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
755 
756   fail_unless (gst_element_set_state (audiochebband,
757           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
758       "could not set to playing");
759 
760   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
761       44100 / 4.0 - 1000, NULL);
762   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
763       44100 / 4.0 + 1000, NULL);
764   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
765   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
766   in = (gdouble *) map.data;
767   for (i = 0; i < 1024; i += 4) {
768     in[i] = 0.0;
769     in[i + 1] = 1.0;
770     in[i + 2] = 0.0;
771     in[i + 3] = -1.0;
772   }
773   gst_buffer_unmap (inbuffer, &map);
774 
775   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
776   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
777   gst_caps_unref (caps);
778   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
779 
780   /* pushing gives away my reference ... */
781   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
782   /* ... and puts a new buffer on the global list */
783   fail_unless_equals_int (g_list_length (buffers), 1);
784   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
785 
786   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
787   res = (gdouble *) map.data;
788 
789   rms = 0.0;
790   for (i = 0; i < 1024; i++)
791     rms += res[i] * res[i];
792   rms = sqrt (rms / 1024.0);
793   fail_unless (rms <= 0.1);
794 
795   gst_buffer_unmap (outbuffer, &map);
796 
797   /* cleanup */
798   cleanup_audiochebband (audiochebband);
799 }
800 
801 GST_END_TEST;
802 
803 /* Test if data containing only one frequency component
804  * at rate/2 is preserved with bandreject mode and a
805  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type1_64_br_22050hz)806 GST_START_TEST (test_type1_64_br_22050hz)
807 {
808   GstElement *audiochebband;
809   GstBuffer *inbuffer, *outbuffer;
810   GstCaps *caps;
811   gdouble *in, *res, rms;
812   gint i;
813   GstMapInfo map;
814 
815   audiochebband = setup_audiochebband ();
816   /* Set to bandreject */
817   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
818   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
819   g_object_set (G_OBJECT (audiochebband), "type", 1, NULL);
820   g_object_set (G_OBJECT (audiochebband), "ripple", 0.25, NULL);
821 
822   fail_unless (gst_element_set_state (audiochebband,
823           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
824       "could not set to playing");
825 
826   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
827       44100 / 4.0 - 1000, NULL);
828   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
829       44100 / 4.0 + 1000, NULL);
830   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
831   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
832   in = (gdouble *) map.data;
833   for (i = 0; i < 1024; i += 2) {
834     in[i] = 1.0;
835     in[i + 1] = -1.0;
836   }
837   gst_buffer_unmap (inbuffer, &map);
838 
839   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
840   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
841   gst_caps_unref (caps);
842   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
843 
844   /* pushing gives away my reference ... */
845   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
846   /* ... and puts a new buffer on the global list */
847   fail_unless_equals_int (g_list_length (buffers), 1);
848   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
849 
850   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
851   res = (gdouble *) map.data;
852 
853   rms = 0.0;
854   for (i = 0; i < 1024; i++)
855     rms += res[i] * res[i];
856   rms = sqrt (rms / 1024.0);
857   fail_unless (rms >= 0.9);
858 
859   gst_buffer_unmap (outbuffer, &map);
860 
861   /* cleanup */
862   cleanup_audiochebband (audiochebband);
863 }
864 
865 GST_END_TEST;
866 
867 /* Test if data containing only one frequency component
868  * at 0 is erased with bandpass mode and a
869  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_bp_0hz)870 GST_START_TEST (test_type2_32_bp_0hz)
871 {
872   GstElement *audiochebband;
873   GstBuffer *inbuffer, *outbuffer;
874   GstCaps *caps;
875   gfloat *in, *res, rms;
876   gint i;
877   GstMapInfo map;
878 
879   audiochebband = setup_audiochebband ();
880   /* Set to bandpass */
881   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
882   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
883   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
884   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
885 
886   fail_unless (gst_element_set_state (audiochebband,
887           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
888       "could not set to playing");
889 
890   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
891       44100 / 4.0 - 1000, NULL);
892   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
893       44100 / 4.0 + 1000, NULL);
894   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
895   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
896   in = (gfloat *) map.data;
897   for (i = 0; i < 1024; i++)
898     in[i] = 1.0;
899   gst_buffer_unmap (inbuffer, &map);
900 
901   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
902   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
903   gst_caps_unref (caps);
904   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
905 
906   /* pushing gives away my reference ... */
907   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
908   /* ... and puts a new buffer on the global list */
909   fail_unless_equals_int (g_list_length (buffers), 1);
910   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
911 
912   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
913   res = (gfloat *) map.data;
914 
915   rms = 0.0;
916   for (i = 0; i < 1024; i++)
917     rms += res[i] * res[i];
918   rms = sqrt (rms / 1024.0);
919   fail_unless (rms <= 0.1);
920 
921   gst_buffer_unmap (outbuffer, &map);
922 
923   /* cleanup */
924   cleanup_audiochebband (audiochebband);
925 }
926 
927 GST_END_TEST;
928 
929 /* Test if data containing only one frequency component
930  * at band center is preserved with bandpass mode and a
931  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_bp_11025hz)932 GST_START_TEST (test_type2_32_bp_11025hz)
933 {
934   GstElement *audiochebband;
935   GstBuffer *inbuffer, *outbuffer;
936   GstCaps *caps;
937   gfloat *in, *res, rms;
938   gint i;
939   GstMapInfo map;
940 
941   audiochebband = setup_audiochebband ();
942   /* Set to bandpass */
943   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
944   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
945   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
946   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
947 
948   fail_unless (gst_element_set_state (audiochebband,
949           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
950       "could not set to playing");
951 
952   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
953       44100 / 4.0 - 1000, NULL);
954   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
955       44100 / 4.0 + 1000, NULL);
956   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
957   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
958   in = (gfloat *) map.data;
959   for (i = 0; i < 1024; i += 4) {
960     in[i] = 0.0;
961     in[i + 1] = 1.0;
962     in[i + 2] = 0.0;
963     in[i + 3] = -1.0;
964   }
965   gst_buffer_unmap (inbuffer, &map);
966 
967   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
968   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
969   gst_caps_unref (caps);
970   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
971 
972   /* pushing gives away my reference ... */
973   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
974   /* ... and puts a new buffer on the global list */
975   fail_unless_equals_int (g_list_length (buffers), 1);
976   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
977 
978   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
979   res = (gfloat *) map.data;
980 
981   rms = 0.0;
982   for (i = 0; i < 1024; i++)
983     rms += res[i] * res[i];
984   rms = sqrt (rms / 1024.0);
985   fail_unless (rms >= 0.6);
986 
987   gst_buffer_unmap (outbuffer, &map);
988 
989   /* cleanup */
990   cleanup_audiochebband (audiochebband);
991 }
992 
993 GST_END_TEST;
994 
995 /* Test if data containing only one frequency component
996  * at rate/2 is erased with bandpass mode and a
997  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_bp_22050hz)998 GST_START_TEST (test_type2_32_bp_22050hz)
999 {
1000   GstElement *audiochebband;
1001   GstBuffer *inbuffer, *outbuffer;
1002   GstCaps *caps;
1003   gfloat *in, *res, rms;
1004   gint i;
1005   GstMapInfo map;
1006 
1007   audiochebband = setup_audiochebband ();
1008   /* Set to bandpass */
1009   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1010   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1011   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1012   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1013 
1014   fail_unless (gst_element_set_state (audiochebband,
1015           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1016       "could not set to playing");
1017 
1018   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1019       44100 / 4.0 - 1000, NULL);
1020   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1021       44100 / 4.0 + 1000, NULL);
1022   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
1023   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1024   in = (gfloat *) map.data;
1025   for (i = 0; i < 1024; i += 2) {
1026     in[i] = 1.0;
1027     in[i + 1] = -1.0;
1028   }
1029   gst_buffer_unmap (inbuffer, &map);
1030 
1031   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1032   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1033   gst_caps_unref (caps);
1034   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1035 
1036   /* pushing gives away my reference ... */
1037   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1038   /* ... and puts a new buffer on the global list */
1039   fail_unless_equals_int (g_list_length (buffers), 1);
1040   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1041 
1042   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1043   res = (gfloat *) map.data;
1044 
1045   rms = 0.0;
1046   for (i = 0; i < 1024; i++)
1047     rms += res[i] * res[i];
1048   rms = sqrt (rms / 1024.0);
1049   fail_unless (rms <= 0.1);
1050 
1051   gst_buffer_unmap (outbuffer, &map);
1052 
1053   /* cleanup */
1054   cleanup_audiochebband (audiochebband);
1055 }
1056 
1057 GST_END_TEST;
1058 
1059 /* Test if data containing only one frequency component
1060  * at 0 is preserved with bandreject mode and a
1061  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_br_0hz)1062 GST_START_TEST (test_type2_32_br_0hz)
1063 {
1064   GstElement *audiochebband;
1065   GstBuffer *inbuffer, *outbuffer;
1066   GstCaps *caps;
1067   gfloat *in, *res, rms;
1068   gint i;
1069   GstMapInfo map;
1070 
1071   audiochebband = setup_audiochebband ();
1072   /* Set to bandreject */
1073   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1074   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1075   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1076   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1077 
1078   fail_unless (gst_element_set_state (audiochebband,
1079           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1080       "could not set to playing");
1081 
1082   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1083       44100 / 4.0 - 1000, NULL);
1084   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1085       44100 / 4.0 + 1000, NULL);
1086   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
1087   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1088   in = (gfloat *) map.data;
1089   for (i = 0; i < 1024; i++)
1090     in[i] = 1.0;
1091   gst_buffer_unmap (inbuffer, &map);
1092 
1093   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1094   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1095   gst_caps_unref (caps);
1096   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1097 
1098   /* pushing gives away my reference ... */
1099   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1100   /* ... and puts a new buffer on the global list */
1101   fail_unless_equals_int (g_list_length (buffers), 1);
1102   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1103 
1104   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1105   res = (gfloat *) map.data;
1106 
1107   rms = 0.0;
1108   for (i = 0; i < 1024; i++)
1109     rms += res[i] * res[i];
1110   rms = sqrt (rms / 1024.0);
1111   fail_unless (rms >= 0.9);
1112 
1113   gst_buffer_unmap (outbuffer, &map);
1114 
1115   /* cleanup */
1116   cleanup_audiochebband (audiochebband);
1117 }
1118 
1119 GST_END_TEST;
1120 
1121 /* Test if data containing only one frequency component
1122  * at band center is erased with bandreject mode and a
1123  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_br_11025hz)1124 GST_START_TEST (test_type2_32_br_11025hz)
1125 {
1126   GstElement *audiochebband;
1127   GstBuffer *inbuffer, *outbuffer;
1128   GstCaps *caps;
1129   gfloat *in, *res, rms;
1130   gint i;
1131   GstMapInfo map;
1132 
1133   audiochebband = setup_audiochebband ();
1134   /* Set to bandreject */
1135   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1136   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1137   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1138   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1139 
1140   fail_unless (gst_element_set_state (audiochebband,
1141           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1142       "could not set to playing");
1143 
1144   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1145       44100 / 4.0 - 1000, NULL);
1146   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1147       44100 / 4.0 + 1000, NULL);
1148   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
1149   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1150   in = (gfloat *) map.data;
1151   for (i = 0; i < 1024; i += 4) {
1152     in[i] = 0.0;
1153     in[i + 1] = 1.0;
1154     in[i + 2] = 0.0;
1155     in[i + 3] = -1.0;
1156   }
1157   gst_buffer_unmap (inbuffer, &map);
1158 
1159   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1160   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1161   gst_caps_unref (caps);
1162   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1163 
1164   /* pushing gives away my reference ... */
1165   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1166   /* ... and puts a new buffer on the global list */
1167   fail_unless_equals_int (g_list_length (buffers), 1);
1168   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1169 
1170   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1171   res = (gfloat *) map.data;
1172 
1173   rms = 0.0;
1174   for (i = 0; i < 1024; i++)
1175     rms += res[i] * res[i];
1176   rms = sqrt (rms / 1024.0);
1177   fail_unless (rms <= 0.1);
1178 
1179   gst_buffer_unmap (outbuffer, &map);
1180 
1181   /* cleanup */
1182   cleanup_audiochebband (audiochebband);
1183 }
1184 
1185 GST_END_TEST;
1186 
1187 /* Test if data containing only one frequency component
1188  * at rate/2 is preserved with bandreject mode and a
1189  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_32_br_22050hz)1190 GST_START_TEST (test_type2_32_br_22050hz)
1191 {
1192   GstElement *audiochebband;
1193   GstBuffer *inbuffer, *outbuffer;
1194   GstCaps *caps;
1195   gfloat *in, *res, rms;
1196   gint i;
1197   GstMapInfo map;
1198 
1199   audiochebband = setup_audiochebband ();
1200   /* Set to bandreject */
1201   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1202   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1203   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1204   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1205 
1206   fail_unless (gst_element_set_state (audiochebband,
1207           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1208       "could not set to playing");
1209 
1210   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1211       44100 / 4.0 - 1000, NULL);
1212   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1213       44100 / 4.0 + 1000, NULL);
1214   inbuffer = gst_buffer_new_allocate (NULL, 1024 * sizeof (gfloat), NULL);
1215   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1216   in = (gfloat *) map.data;
1217   for (i = 0; i < 1024; i += 2) {
1218     in[i] = 1.0;
1219     in[i + 1] = -1.0;
1220   }
1221   gst_buffer_unmap (inbuffer, &map);
1222 
1223   caps = gst_caps_from_string (BUFFER_CAPS_STRING_32);
1224   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1225   gst_caps_unref (caps);
1226   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1227 
1228   /* pushing gives away my reference ... */
1229   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1230   /* ... and puts a new buffer on the global list */
1231   fail_unless_equals_int (g_list_length (buffers), 1);
1232   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1233 
1234   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1235   res = (gfloat *) map.data;
1236 
1237   rms = 0.0;
1238   for (i = 0; i < 1024; i++)
1239     rms += res[i] * res[i];
1240   rms = sqrt (rms / 1024.0);
1241   fail_unless (rms >= 0.9);
1242 
1243   gst_buffer_unmap (outbuffer, &map);
1244 
1245   /* cleanup */
1246   cleanup_audiochebband (audiochebband);
1247 }
1248 
1249 GST_END_TEST;
1250 
1251 /* Test if data containing only one frequency component
1252  * at 0 is erased with bandpass mode and a
1253  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_bp_0hz)1254 GST_START_TEST (test_type2_64_bp_0hz)
1255 {
1256   GstElement *audiochebband;
1257   GstBuffer *inbuffer, *outbuffer;
1258   GstCaps *caps;
1259   gdouble *in, *res, rms;
1260   gint i;
1261   GstMapInfo map;
1262 
1263   audiochebband = setup_audiochebband ();
1264   /* Set to bandpass */
1265   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1266   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1267   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1268   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1269 
1270   fail_unless (gst_element_set_state (audiochebband,
1271           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1272       "could not set to playing");
1273 
1274   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1275       44100 / 4.0 - 1000, NULL);
1276   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1277       44100 / 4.0 + 1000, NULL);
1278   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1279   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1280   in = (gdouble *) map.data;
1281   for (i = 0; i < 1024; i++)
1282     in[i] = 1.0;
1283   gst_buffer_unmap (inbuffer, &map);
1284 
1285   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1286   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1287   gst_caps_unref (caps);
1288   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1289 
1290   /* pushing gives away my reference ... */
1291   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1292   /* ... and puts a new buffer on the global list */
1293   fail_unless_equals_int (g_list_length (buffers), 1);
1294   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1295 
1296   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1297   res = (gdouble *) map.data;
1298 
1299   rms = 0.0;
1300   for (i = 0; i < 1024; i++)
1301     rms += res[i] * res[i];
1302   rms = sqrt (rms / 1024.0);
1303   fail_unless (rms <= 0.1);
1304 
1305   gst_buffer_unmap (outbuffer, &map);
1306 
1307   /* cleanup */
1308   cleanup_audiochebband (audiochebband);
1309 }
1310 
1311 GST_END_TEST;
1312 
1313 /* Test if data containing only one frequency component
1314  * at band center is preserved with bandpass mode and a
1315  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_bp_11025hz)1316 GST_START_TEST (test_type2_64_bp_11025hz)
1317 {
1318   GstElement *audiochebband;
1319   GstBuffer *inbuffer, *outbuffer;
1320   GstCaps *caps;
1321   gdouble *in, *res, rms;
1322   gint i;
1323   GstMapInfo map;
1324 
1325   audiochebband = setup_audiochebband ();
1326   /* Set to bandpass */
1327   g_object_set (G_OBJECT (audiochebband), "mode", 0, 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);
1331 
1332   fail_unless (gst_element_set_state (audiochebband,
1333           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1334       "could not set to playing");
1335 
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   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1342   in = (gdouble *) map.data;
1343   for (i = 0; i < 1024; i += 4) {
1344     in[i] = 0.0;
1345     in[i + 1] = 1.0;
1346     in[i + 2] = 0.0;
1347     in[i + 3] = -1.0;
1348   }
1349   gst_buffer_unmap (inbuffer, &map);
1350 
1351   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1352   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1353   gst_caps_unref (caps);
1354   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1355 
1356   /* pushing gives away my reference ... */
1357   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1358   /* ... and puts a new buffer on the global list */
1359   fail_unless_equals_int (g_list_length (buffers), 1);
1360   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1361 
1362   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1363   res = (gdouble *) map.data;
1364 
1365   rms = 0.0;
1366   for (i = 0; i < 1024; i++)
1367     rms += res[i] * res[i];
1368   rms = sqrt (rms / 1024.0);
1369   fail_unless (rms >= 0.6);
1370 
1371   gst_buffer_unmap (outbuffer, &map);
1372 
1373   /* cleanup */
1374   cleanup_audiochebband (audiochebband);
1375 }
1376 
1377 GST_END_TEST;
1378 
1379 /* Test if data containing only one frequency component
1380  * at rate/2 is erased with bandpass mode and a
1381  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_bp_22050hz)1382 GST_START_TEST (test_type2_64_bp_22050hz)
1383 {
1384   GstElement *audiochebband;
1385   GstBuffer *inbuffer, *outbuffer;
1386   GstCaps *caps;
1387   gdouble *in, *res, rms;
1388   gint i;
1389   GstMapInfo map;
1390 
1391   audiochebband = setup_audiochebband ();
1392   /* Set to bandpass */
1393   g_object_set (G_OBJECT (audiochebband), "mode", 0, NULL);
1394   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1395   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1396   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1397 
1398   fail_unless (gst_element_set_state (audiochebband,
1399           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1400       "could not set to playing");
1401 
1402   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1403       44100 / 4.0 - 1000, NULL);
1404   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1405       44100 / 4.0 + 1000, NULL);
1406   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1407   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1408   in = (gdouble *) map.data;
1409   for (i = 0; i < 1024; i += 2) {
1410     in[i] = 1.0;
1411     in[i + 1] = -1.0;
1412   }
1413   gst_buffer_unmap (inbuffer, &map);
1414 
1415   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1416   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1417   gst_caps_unref (caps);
1418   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1419 
1420   /* pushing gives away my reference ... */
1421   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1422   /* ... and puts a new buffer on the global list */
1423   fail_unless_equals_int (g_list_length (buffers), 1);
1424   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1425 
1426   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1427   res = (gdouble *) map.data;
1428 
1429   rms = 0.0;
1430   for (i = 0; i < 1024; i++)
1431     rms += res[i] * res[i];
1432   rms = sqrt (rms / 1024.0);
1433   fail_unless (rms <= 0.1);
1434 
1435   gst_buffer_unmap (outbuffer, &map);
1436 
1437   /* cleanup */
1438   cleanup_audiochebband (audiochebband);
1439 }
1440 
1441 GST_END_TEST;
1442 
1443 /* Test if data containing only one frequency component
1444  * at 0 is preserved with bandreject mode and a
1445  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_br_0hz)1446 GST_START_TEST (test_type2_64_br_0hz)
1447 {
1448   GstElement *audiochebband;
1449   GstBuffer *inbuffer, *outbuffer;
1450   GstCaps *caps;
1451   gdouble *in, *res, rms;
1452   gint i;
1453   GstMapInfo map;
1454 
1455   audiochebband = setup_audiochebband ();
1456   /* Set to bandreject */
1457   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1458   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1459   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1460   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1461 
1462   fail_unless (gst_element_set_state (audiochebband,
1463           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1464       "could not set to playing");
1465 
1466   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1467       44100 / 4.0 - 1000, NULL);
1468   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1469       44100 / 4.0 + 1000, NULL);
1470   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1471   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1472   in = (gdouble *) map.data;
1473   for (i = 0; i < 1024; i++)
1474     in[i] = 1.0;
1475   gst_buffer_unmap (inbuffer, &map);
1476 
1477   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1478   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1479   gst_caps_unref (caps);
1480   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1481 
1482   /* pushing gives away my reference ... */
1483   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1484   /* ... and puts a new buffer on the global list */
1485   fail_unless_equals_int (g_list_length (buffers), 1);
1486   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1487 
1488   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1489   res = (gdouble *) map.data;
1490 
1491   rms = 0.0;
1492   for (i = 0; i < 1024; i++)
1493     rms += res[i] * res[i];
1494   rms = sqrt (rms / 1024.0);
1495   fail_unless (rms >= 0.9);
1496 
1497   gst_buffer_unmap (outbuffer, &map);
1498 
1499   /* cleanup */
1500   cleanup_audiochebband (audiochebband);
1501 }
1502 
1503 GST_END_TEST;
1504 
1505 /* Test if data containing only one frequency component
1506  * at band center is erased with bandreject mode and a
1507  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_br_11025hz)1508 GST_START_TEST (test_type2_64_br_11025hz)
1509 {
1510   GstElement *audiochebband;
1511   GstBuffer *inbuffer, *outbuffer;
1512   GstCaps *caps;
1513   gdouble *in, *res, rms;
1514   gint i;
1515   GstMapInfo map;
1516 
1517   audiochebband = setup_audiochebband ();
1518   /* Set to bandreject */
1519   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1520   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1521   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1522   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1523 
1524   fail_unless (gst_element_set_state (audiochebband,
1525           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1526       "could not set to playing");
1527 
1528   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1529       44100 / 4.0 - 1000, NULL);
1530   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1531       44100 / 4.0 + 1000, NULL);
1532   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1533   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1534   in = (gdouble *) map.data;
1535   for (i = 0; i < 1024; i += 4) {
1536     in[i] = 0.0;
1537     in[i + 1] = 1.0;
1538     in[i + 2] = 0.0;
1539     in[i + 3] = -1.0;
1540   }
1541   gst_buffer_unmap (inbuffer, &map);
1542 
1543   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1544   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1545   gst_caps_unref (caps);
1546   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1547 
1548   /* pushing gives away my reference ... */
1549   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1550   /* ... and puts a new buffer on the global list */
1551   fail_unless_equals_int (g_list_length (buffers), 1);
1552   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1553 
1554   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1555   res = (gdouble *) map.data;
1556 
1557   rms = 0.0;
1558   for (i = 0; i < 1024; i++)
1559     rms += res[i] * res[i];
1560   rms = sqrt (rms / 1024.0);
1561   fail_unless (rms <= 0.1);
1562 
1563   gst_buffer_unmap (outbuffer, &map);
1564 
1565   /* cleanup */
1566   cleanup_audiochebband (audiochebband);
1567 }
1568 
1569 GST_END_TEST;
1570 
1571 /* Test if data containing only one frequency component
1572  * at rate/2 is preserved with bandreject mode and a
1573  * 2000Hz frequency band around rate/4 */
GST_START_TEST(test_type2_64_br_22050hz)1574 GST_START_TEST (test_type2_64_br_22050hz)
1575 {
1576   GstElement *audiochebband;
1577   GstBuffer *inbuffer, *outbuffer;
1578   GstCaps *caps;
1579   gdouble *in, *res, rms;
1580   gint i;
1581   GstMapInfo map;
1582 
1583   audiochebband = setup_audiochebband ();
1584   /* Set to bandreject */
1585   g_object_set (G_OBJECT (audiochebband), "mode", 1, NULL);
1586   g_object_set (G_OBJECT (audiochebband), "poles", 8, NULL);
1587   g_object_set (G_OBJECT (audiochebband), "type", 2, NULL);
1588   g_object_set (G_OBJECT (audiochebband), "ripple", 40.0, NULL);
1589 
1590   fail_unless (gst_element_set_state (audiochebband,
1591           GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
1592       "could not set to playing");
1593 
1594   g_object_set (G_OBJECT (audiochebband), "lower-frequency",
1595       44100 / 4.0 - 1000, NULL);
1596   g_object_set (G_OBJECT (audiochebband), "upper-frequency",
1597       44100 / 4.0 + 1000, NULL);
1598   inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
1599   gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
1600   in = (gdouble *) map.data;
1601   for (i = 0; i < 1024; i += 2) {
1602     in[i] = 1.0;
1603     in[i + 1] = -1.0;
1604   }
1605   gst_buffer_unmap (inbuffer, &map);
1606 
1607   caps = gst_caps_from_string (BUFFER_CAPS_STRING_64);
1608   gst_check_setup_events (mysrcpad, audiochebband, caps, GST_FORMAT_TIME);
1609   gst_caps_unref (caps);
1610   ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
1611 
1612   /* pushing gives away my reference ... */
1613   fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
1614   /* ... and puts a new buffer on the global list */
1615   fail_unless_equals_int (g_list_length (buffers), 1);
1616   fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
1617 
1618   gst_buffer_map (outbuffer, &map, GST_MAP_READ);
1619   res = (gdouble *) map.data;
1620 
1621   rms = 0.0;
1622   for (i = 0; i < 1024; i++)
1623     rms += res[i] * res[i];
1624   rms = sqrt (rms / 1024.0);
1625   fail_unless (rms >= 0.9);
1626 
1627   gst_buffer_unmap (outbuffer, &map);
1628 
1629   /* cleanup */
1630   cleanup_audiochebband (audiochebband);
1631 }
1632 
1633 GST_END_TEST;
1634 
1635 static Suite *
audiochebband_suite(void)1636 audiochebband_suite (void)
1637 {
1638   Suite *s = suite_create ("audiochebband");
1639   TCase *tc_chain = tcase_create ("general");
1640 
1641   suite_add_tcase (s, tc_chain);
1642   tcase_add_test (tc_chain, test_type1_32_bp_0hz);
1643   tcase_add_test (tc_chain, test_type1_32_bp_11025hz);
1644   tcase_add_test (tc_chain, test_type1_32_bp_22050hz);
1645   tcase_add_test (tc_chain, test_type1_32_br_0hz);
1646   tcase_add_test (tc_chain, test_type1_32_br_11025hz);
1647   tcase_add_test (tc_chain, test_type1_32_br_22050hz);
1648   tcase_add_test (tc_chain, test_type1_64_bp_0hz);
1649   tcase_add_test (tc_chain, test_type1_64_bp_11025hz);
1650   tcase_add_test (tc_chain, test_type1_64_bp_22050hz);
1651   tcase_add_test (tc_chain, test_type1_64_br_0hz);
1652   tcase_add_test (tc_chain, test_type1_64_br_11025hz);
1653   tcase_add_test (tc_chain, test_type1_64_br_22050hz);
1654   tcase_add_test (tc_chain, test_type2_32_bp_0hz);
1655   tcase_add_test (tc_chain, test_type2_32_bp_11025hz);
1656   tcase_add_test (tc_chain, test_type2_32_bp_22050hz);
1657   tcase_add_test (tc_chain, test_type2_32_br_0hz);
1658   tcase_add_test (tc_chain, test_type2_32_br_11025hz);
1659   tcase_add_test (tc_chain, test_type2_32_br_22050hz);
1660   tcase_add_test (tc_chain, test_type2_64_bp_0hz);
1661   tcase_add_test (tc_chain, test_type2_64_bp_11025hz);
1662   tcase_add_test (tc_chain, test_type2_64_bp_22050hz);
1663   tcase_add_test (tc_chain, test_type2_64_br_0hz);
1664   tcase_add_test (tc_chain, test_type2_64_br_11025hz);
1665   tcase_add_test (tc_chain, test_type2_64_br_22050hz);
1666 
1667   return s;
1668 }
1669 
1670 GST_CHECK_MAIN (audiochebband);
1671