2007-08-12 20:53:11 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Sebastian Dröge <slomo@circular-chaos.org>
|
|
|
|
*
|
2008-02-07 21:57:54 +00:00
|
|
|
* audiowsincband.c: Unit test for the audiowsincband element
|
2007-08-12 20:53:11 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2.1 of
|
|
|
|
* the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/gst.h>
|
2012-01-03 09:26:48 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2007-08-12 20:53:11 +00:00
|
|
|
#include <gst/base/gstbasetransform.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
/* For ease of programming we use globals to keep refs for our floating
|
|
|
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
|
|
|
* get_peer, and then remove references in every test function */
|
|
|
|
GstPad *mysrcpad, *mysinkpad;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
#define AUDIO_WSINC_BAND_CAPS_STRING_32 \
|
2012-01-03 09:26:48 +00:00
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) " GST_AUDIO_NE (F32) ", " \
|
|
|
|
"channels = (int) 1, " \
|
|
|
|
"rate = (int) 44100"
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
#define AUDIO_WSINC_BAND_CAPS_STRING_64 \
|
2012-01-03 09:26:48 +00:00
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) " GST_AUDIO_NE (F64) ", " \
|
|
|
|
"channels = (int) 1, " \
|
|
|
|
"rate = (int) 44100"
|
|
|
|
|
|
|
|
#define FORMATS "{ "GST_AUDIO_NE (F32)","GST_AUDIO_NE (F64)" }"
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-01-03 09:26:48 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw, "
|
|
|
|
"format = (string) " FORMATS ", "
|
|
|
|
"channels = (int) 1, " "rate = (int) 44100")
|
2007-08-12 20:53:11 +00:00
|
|
|
);
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-01-03 09:26:48 +00:00
|
|
|
GST_STATIC_CAPS ("audio/x-raw, "
|
|
|
|
"format = (string) " FORMATS ", "
|
|
|
|
"channels = (int) 1, " "rate = (int) 44100")
|
2007-08-12 20:53:11 +00:00
|
|
|
);
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
static GstElement *
|
|
|
|
setup_audiowsincband (void)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
GST_DEBUG ("setup_audiowsincband");
|
|
|
|
audiowsincband = gst_check_setup_element ("audiowsincband");
|
2011-11-24 20:41:03 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (audiowsincband, &srctemplate);
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (audiowsincband, &sinktemplate);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
return audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
static void
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (GstElement * audiowsincband)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GST_DEBUG ("cleanup_audiowsincband");
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
|
|
|
|
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
2008-02-07 21:57:54 +00:00
|
|
|
gst_check_teardown_src_pad (audiowsincband);
|
|
|
|
gst_check_teardown_sink_pad (audiowsincband);
|
|
|
|
gst_check_teardown_element (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is erased with bandpass mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_32_bp_0hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
|
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
|
|
|
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at the band center is preserved with bandreject mode
|
|
|
|
* and a 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_32_bp_11025hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 1024; i += 4) {
|
|
|
|
in[i] = 0.0;
|
|
|
|
in[i + 1] = 1.0;
|
|
|
|
in[i + 2] = 0.0;
|
|
|
|
in[i + 3] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is erased with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_32_bp_22050hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 1024; i += 2) {
|
|
|
|
in[i] = 1.0;
|
|
|
|
in[i + 1] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.3);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is preserved with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_32_br_0hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.9);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at the band center is erased with bandreject mode
|
|
|
|
* and a 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_32_br_11025hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 1024; i += 4) {
|
|
|
|
in[i] = 0.0;
|
|
|
|
in[i + 1] = 1.0;
|
|
|
|
in[i + 2] = 0.0;
|
|
|
|
in[i + 3] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.35);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is preserved with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_32_br_22050hz)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in, *res, rms;
|
|
|
|
gint i;
|
|
|
|
GList *node;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 1024; i += 2) {
|
|
|
|
in[i] = 1.0;
|
|
|
|
in[i + 1] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-19 19:01:45 +00:00
|
|
|
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
2007-08-19 19:01:45 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.9);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if buffers smaller than the kernel size are handled
|
|
|
|
* correctly without accessing wrong memory areas */
|
|
|
|
GST_START_TEST (test_32_small_buffer)
|
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
|
|
|
GstBuffer *inbuffer;
|
2007-08-19 19:01:45 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
gfloat *in;
|
|
|
|
gint i;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-19 19:01:45 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 101, NULL);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
2007-08-19 19:01:45 +00:00
|
|
|
44100 / 4.0 - 44100 / 16.0, NULL);
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
2007-08-19 19:01:45 +00:00
|
|
|
44100 / 4.0 + 44100 / 16.0, NULL);
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gfloat));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-19 19:01:45 +00:00
|
|
|
for (i = 0; i < 20; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-19 19:01:45 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_32);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-19 19:01:45 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
|
|
|
/* ... and puts a new buffer on the global list */
|
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-19 19:01:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is erased with bandpass mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
|
|
|
GST_START_TEST (test_64_bp_0hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.1);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at the band center is preserved with bandreject mode
|
|
|
|
* and a 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_bp_11025hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 1024; i += 4) {
|
|
|
|
in[i] = 0.0;
|
|
|
|
in[i + 1] = 1.0;
|
|
|
|
in[i + 2] = 0.0;
|
|
|
|
in[i + 3] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.4);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is erased with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_bp_22050hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 1024; i += 2) {
|
|
|
|
in[i] = 1.0;
|
|
|
|
in[i + 1] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.3);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is preserved with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_br_0hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 1024; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.9);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at the band center is erased with bandreject mode
|
|
|
|
* and a 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_br_11025hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 1024; i += 4) {
|
|
|
|
in[i] = 0.0;
|
|
|
|
in[i + 1] = 1.0;
|
|
|
|
in[i + 2] = 0.0;
|
|
|
|
in[i + 3] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms <= 0.35);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
|
|
|
/* Test if data containing only one frequency component
|
|
|
|
* at rate/2 is preserved with bandreject mode and a
|
|
|
|
* 2000Hz frequency band around rate/4 */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_br_22050hz)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in, *res, rms;
|
|
|
|
gint i;
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
GList *node;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandreject */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 1, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 31, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
|
|
|
44100 / 4.0 - 1000, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
|
|
|
44100 / 4.0 + 1000, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 1024; i += 2) {
|
|
|
|
in[i] = 1.0;
|
|
|
|
in[i + 1] = -1.0;
|
|
|
|
}
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
for (node = buffers; node; node = node->next) {
|
|
|
|
gint buffer_length;
|
2012-01-03 09:26:48 +00:00
|
|
|
gsize size;
|
2007-08-12 20:53:11 +00:00
|
|
|
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) node->data) == NULL);
|
|
|
|
|
2012-01-03 09:26:48 +00:00
|
|
|
res = gst_buffer_map (outbuffer, &size, NULL, GST_MAP_READ);
|
|
|
|
buffer_length = size / sizeof (gfloat);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
rms = 0.0;
|
|
|
|
for (i = 0; i < buffer_length; i++)
|
|
|
|
rms += res[i] * res[i];
|
|
|
|
rms = sqrt (rms / buffer_length);
|
|
|
|
fail_unless (rms >= 0.9);
|
|
|
|
}
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
/* Test if buffers smaller than the kernel size are handled
|
|
|
|
* correctly without accessing wrong memory areas */
|
2007-08-19 19:01:45 +00:00
|
|
|
GST_START_TEST (test_64_small_buffer)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
GstElement *audiowsincband;
|
|
|
|
GstBuffer *inbuffer;
|
2007-08-12 20:53:11 +00:00
|
|
|
GstCaps *caps;
|
|
|
|
gdouble *in;
|
|
|
|
gint i;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband = setup_audiowsincband ();
|
2007-08-12 20:53:11 +00:00
|
|
|
/* Set to bandpass */
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "mode", 0, NULL);
|
|
|
|
g_object_set (G_OBJECT (audiowsincband), "length", 101, NULL);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
fail_unless (gst_element_set_state (audiowsincband,
|
2007-08-12 20:53:11 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "lower-frequency",
|
2007-08-12 20:53:11 +00:00
|
|
|
44100 / 4.0 - 44100 / 16.0, NULL);
|
2008-02-07 21:57:54 +00:00
|
|
|
g_object_set (G_OBJECT (audiowsincband), "upper-frequency",
|
2007-08-12 20:53:11 +00:00
|
|
|
44100 / 4.0 + 44100 / 16.0, NULL);
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (20 * sizeof (gdouble));
|
gst/audiofx/: Implement a base class for generic audio FIR filters.
Original commit message from CVS:
* gst/audiofx/Makefile.am:
* gst/audiofx/audiofxbasefirfilter.c:
(gst_audio_fx_base_fir_filter_dispose),
(gst_audio_fx_base_fir_filter_base_init),
(gst_audio_fx_base_fir_filter_class_init),
(gst_audio_fx_base_fir_filter_init),
(gst_audio_fx_base_fir_filter_push_residue),
(gst_audio_fx_base_fir_filter_setup),
(gst_audio_fx_base_fir_filter_transform),
(gst_audio_fx_base_fir_filter_start),
(gst_audio_fx_base_fir_filter_stop),
(gst_audio_fx_base_fir_filter_query),
(gst_audio_fx_base_fir_filter_query_type),
(gst_audio_fx_base_fir_filter_event),
(gst_audio_fx_base_fir_filter_set_kernel):
* gst/audiofx/audiofxbasefirfilter.h:
* gst/audiofx/audiofxbaseiirfilter.c:
Implement a base class for generic audio FIR filters.
* gst/audiofx/audiowsincband.c:
(gst_gst_audio_wsincband_mode_get_type),
(gst_gst_audio_wsincband_window_get_type),
(gst_audio_wsincband_base_init), (gst_audio_wsincband_class_init),
(gst_audio_wsincband_init), (gst_audio_wsincband_build_kernel),
(gst_audio_wsincband_setup), (gst_audio_wsincband_set_property),
(gst_audio_wsincband_get_property):
* gst/audiofx/audiowsincband.h:
* gst/audiofx/audiowsinclimit.c:
(gst_audio_wsinclimit_mode_get_type),
(gst_audio_wsinclimit_window_get_type),
(gst_audio_wsinclimit_base_init),
(gst_audio_wsinclimit_class_init), (gst_audio_wsinclimit_init),
(gst_audio_wsinclimit_build_kernel), (gst_audio_wsinclimit_setup),
(gst_audio_wsinclimit_set_property),
(gst_audio_wsinclimit_get_property):
* gst/audiofx/audiowsinclimit.h:
* tests/check/elements/audiowsincband.c: (GST_START_TEST):
* tests/check/elements/audiowsinclimit.c: (GST_START_TEST):
Use this new base class for audiowsincband and audiowsinclimit.
Also cleanup both elements.
2009-01-11 19:03:38 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
2012-01-03 09:26:48 +00:00
|
|
|
in = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
|
2007-08-12 20:53:11 +00:00
|
|
|
for (i = 0; i < 20; i++)
|
|
|
|
in[i] = 1.0;
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_buffer_unmap (inbuffer, in, -1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
caps = gst_caps_from_string (AUDIO_WSINC_BAND_CAPS_STRING_64);
|
2012-01-03 09:26:48 +00:00
|
|
|
gst_pad_set_caps (mysrcpad, caps);
|
2007-08-12 20:53:11 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ()));
|
2007-08-12 20:53:11 +00:00
|
|
|
/* ... and puts a new buffer on the global list */
|
gst/filter/gstbpwsinc.*: Implement latency query and only forward those samples downstream that actually contain the ...
Original commit message from CVS:
* gst/filter/gstbpwsinc.c: (gst_bpwsinc_class_init),
(gst_bpwsinc_init), (process_32), (process_64),
(bpwsinc_build_kernel), (bpwsinc_push_residue),
(bpwsinc_transform), (bpwsinc_start), (bpwsinc_query),
(bpwsinc_query_type), (bpwsinc_event), (bpwsinc_set_property):
* gst/filter/gstbpwsinc.h:
Implement latency query and only forward those samples downstream
that actually contain the data we want, i.e. drop kernel_length/2
in the beginning and append kernel_length/2 (created by convolving
the filter kernel with zeroes) to the end.
* tests/check/elements/bpwsinc.c: (GST_START_TEST):
Adjust the unit test for this slightly changed behaviour.
* gst/filter/gstlpwsinc.c: (lpwsinc_build_kernel):
Reset residue length only when actually creating a residue.
2007-08-16 19:22:48 +00:00
|
|
|
fail_unless (g_list_length (buffers) >= 1);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
2008-02-07 21:57:54 +00:00
|
|
|
cleanup_audiowsincband (audiowsincband);
|
2007-08-12 20:53:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
static Suite *
|
2008-02-07 21:57:54 +00:00
|
|
|
audiowsincband_suite (void)
|
2007-08-12 20:53:11 +00:00
|
|
|
{
|
2008-02-07 21:57:54 +00:00
|
|
|
Suite *s = suite_create ("audiowsincband");
|
2007-08-12 20:53:11 +00:00
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2007-08-19 19:01:45 +00:00
|
|
|
tcase_add_test (tc_chain, test_32_bp_0hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_bp_11025hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_bp_22050hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_br_0hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_br_11025hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_br_22050hz);
|
|
|
|
tcase_add_test (tc_chain, test_32_small_buffer);
|
|
|
|
tcase_add_test (tc_chain, test_64_bp_0hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_bp_11025hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_bp_22050hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_br_0hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_br_11025hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_br_22050hz);
|
|
|
|
tcase_add_test (tc_chain, test_64_small_buffer);
|
2007-08-12 20:53:11 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int nf;
|
|
|
|
|
2008-02-07 21:57:54 +00:00
|
|
|
Suite *s = audiowsincband_suite ();
|
2007-08-12 20:53:11 +00:00
|
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
|
|
nf = srunner_ntests_failed (sr);
|
|
|
|
srunner_free (sr);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|