2007-06-20 08:56:17 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for spectrum
|
|
|
|
*
|
|
|
|
* Copyright (C) <2007> Stefan Kost <ensonic@users.sf.net>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2007-06-20 08:56:17 +00:00
|
|
|
*/
|
|
|
|
|
2011-10-27 22:24:14 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2007-06-20 08:56:17 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
gboolean have_eos = FALSE;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
|
|
|
#define SPECT_CAPS_TEMPLATE_STRING \
|
2011-10-27 22:24:14 +00:00
|
|
|
"audio/x-raw, " \
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
" rate = (int) [ 1, MAX ], " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" channels = (int) [ 1, MAX ], " \
|
2012-02-06 17:35:01 +00:00
|
|
|
" layout = (string) interleaved, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" format = (string) { " \
|
|
|
|
GST_AUDIO_NE(S16) ", " \
|
|
|
|
GST_AUDIO_NE(S32) ", " \
|
|
|
|
GST_AUDIO_NE(F32) ", " \
|
|
|
|
GST_AUDIO_NE(F64) " }"
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
|
|
|
|
#define SPECT_CAPS_STRING_S16 \
|
2011-10-27 22:24:14 +00:00
|
|
|
"audio/x-raw, " \
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
"rate = (int) 44100, " \
|
|
|
|
"channels = (int) 1, " \
|
2012-02-06 17:35:01 +00:00
|
|
|
"layout = (string) interleaved, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
"format = (string) " GST_AUDIO_NE(S16)
|
2007-06-20 08:56:17 +00:00
|
|
|
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
#define SPECT_CAPS_STRING_S32 \
|
2011-10-27 22:24:14 +00:00
|
|
|
"audio/x-raw, " \
|
2007-06-20 08:56:17 +00:00
|
|
|
"rate = (int) 44100, " \
|
|
|
|
"channels = (int) 1, " \
|
2012-02-06 17:35:01 +00:00
|
|
|
"layout = (string) interleaved, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
"format = (string) " GST_AUDIO_NE(S32)
|
2007-06-20 08:56:17 +00:00
|
|
|
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
#define SPECT_CAPS_STRING_F32 \
|
2011-10-27 22:24:14 +00:00
|
|
|
"audio/x-raw, " \
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
" rate = (int) 44100, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" channels = (int) 1, " \
|
2012-02-06 17:35:01 +00:00
|
|
|
" layout = (string) interleaved, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" format = (string) " GST_AUDIO_NE(F32)
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
|
|
|
|
#define SPECT_CAPS_STRING_F64 \
|
2011-10-27 22:24:14 +00:00
|
|
|
"audio/x-raw, " \
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
" rate = (int) 44100, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" channels = (int) 1, " \
|
2012-02-06 17:35:01 +00:00
|
|
|
" layout = (string) interleaved, " \
|
2011-10-27 22:24:14 +00:00
|
|
|
" format = (string) " GST_AUDIO_NE(F64)
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
|
|
|
|
#define SPECT_BANDS 256
|
2007-06-20 08:56:17 +00:00
|
|
|
|
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (SPECT_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (SPECT_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
|
|
|
|
|
|
|
/* takes over reference for outcaps */
|
2010-03-17 17:23:00 +00:00
|
|
|
static GstElement *
|
2013-05-09 22:32:23 +00:00
|
|
|
setup_spectrum (const gchar * caps_str)
|
2007-06-20 08:56:17 +00:00
|
|
|
{
|
|
|
|
GstElement *spectrum;
|
2013-05-09 22:32:23 +00:00
|
|
|
GstCaps *caps;
|
2007-06-20 08:56:17 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("setup_spectrum");
|
|
|
|
spectrum = gst_check_setup_element ("spectrum");
|
2011-11-24 20:41:03 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (spectrum, &srctemplate);
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (spectrum, &sinktemplate);
|
2007-06-20 08:56:17 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
2013-05-09 22:32:23 +00:00
|
|
|
caps = gst_caps_from_string (caps_str);
|
|
|
|
gst_check_setup_events (mysrcpad, spectrum, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
2007-06-20 08:56:17 +00:00
|
|
|
return spectrum;
|
|
|
|
}
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
static void
|
2007-06-20 08:56:17 +00:00
|
|
|
cleanup_spectrum (GstElement * spectrum)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("cleanup_spectrum");
|
|
|
|
|
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
|
|
|
gst_check_teardown_src_pad (spectrum);
|
|
|
|
gst_check_teardown_sink_pad (spectrum);
|
|
|
|
gst_check_teardown_element (spectrum);
|
2008-02-09 00:15:25 +00:00
|
|
|
|
|
|
|
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
2007-06-20 08:56:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GST_START_TEST (test_int16)
|
|
|
|
{
|
|
|
|
GstElement *spectrum;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
|
|
|
const GstStructure *structure;
|
|
|
|
int i, j;
|
2012-01-31 14:39:09 +00:00
|
|
|
gint16 *data;
|
|
|
|
GstMapInfo map;
|
2007-06-20 08:56:17 +00:00
|
|
|
const GValue *list, *value;
|
|
|
|
GstClockTime endtime;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
gfloat level;
|
2007-06-20 08:56:17 +00:00
|
|
|
|
2013-05-09 22:32:23 +00:00
|
|
|
spectrum = setup_spectrum (SPECT_CAPS_STRING_S16);
|
2011-10-27 22:24:14 +00:00
|
|
|
g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
|
2007-06-20 08:56:17 +00:00
|
|
|
"bands", SPECT_BANDS, "threshold", -80, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
2011-10-27 22:24:14 +00:00
|
|
|
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint16), 0);
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
data = (gint16 *) map.data;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
for (j = 0; j < 44100; j += 4) {
|
|
|
|
*data = 0;
|
|
|
|
++data;
|
|
|
|
*data = 32767;
|
|
|
|
++data;
|
|
|
|
*data = 0;
|
|
|
|
++data;
|
|
|
|
*data = -32767;
|
|
|
|
++data;
|
|
|
|
}
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* create a bus to get the spectrum message on */
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_element_set_bus (spectrum, bus);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (message, "message", 1);
|
|
|
|
|
|
|
|
fail_unless (message != NULL);
|
|
|
|
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
|
|
|
|
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
|
|
|
|
structure = gst_message_get_structure (message);
|
|
|
|
fail_if (structure == NULL);
|
|
|
|
fail_unless_equals_string ((char *) gst_structure_get_name (structure),
|
|
|
|
"spectrum");
|
|
|
|
fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));
|
|
|
|
|
|
|
|
list = gst_structure_get_value (structure, "magnitude");
|
|
|
|
for (i = 0; i < SPECT_BANDS; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
|
|
|
level = g_value_get_float (value);
|
|
|
|
GST_DEBUG ("band[%3d] is %.2f", i, level);
|
|
|
|
/* Only the bands in the middle should have a level above 60 */
|
|
|
|
fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level < -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level > -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
}
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
/* flush current messages,and future state change messages */
|
|
|
|
gst_bus_set_flushing (bus, TRUE);
|
|
|
|
|
|
|
|
/* message has a ref to the element */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
|
|
|
|
gst_message_unref (message);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
|
|
|
|
gst_element_set_bus (spectrum, NULL);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
cleanup_spectrum (spectrum);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_int32)
|
|
|
|
{
|
|
|
|
GstElement *spectrum;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
|
|
|
const GstStructure *structure;
|
|
|
|
int i, j;
|
2012-01-31 14:39:09 +00:00
|
|
|
gint32 *data;
|
|
|
|
GstMapInfo map;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
const GValue *list, *value;
|
|
|
|
GstClockTime endtime;
|
|
|
|
gfloat level;
|
|
|
|
|
2013-05-09 22:32:23 +00:00
|
|
|
spectrum = setup_spectrum (SPECT_CAPS_STRING_S32);
|
2011-10-27 22:24:14 +00:00
|
|
|
g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
"bands", SPECT_BANDS, "threshold", -80, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
2011-10-27 22:24:14 +00:00
|
|
|
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gint32), 0);
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
data = (gint32 *) map.data;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
for (j = 0; j < 44100; j += 4) {
|
|
|
|
*data = 0;
|
|
|
|
++data;
|
|
|
|
*data = 2147483647;
|
|
|
|
++data;
|
|
|
|
*data = 0;
|
|
|
|
++data;
|
|
|
|
*data = -2147483647;
|
|
|
|
++data;
|
|
|
|
}
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* create a bus to get the spectrum message on */
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_element_set_bus (spectrum, bus);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (message, "message", 1);
|
|
|
|
|
|
|
|
fail_unless (message != NULL);
|
|
|
|
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
|
|
|
|
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
|
|
|
|
structure = gst_message_get_structure (message);
|
|
|
|
fail_if (structure == NULL);
|
|
|
|
fail_unless_equals_string ((char *) gst_structure_get_name (structure),
|
|
|
|
"spectrum");
|
|
|
|
fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));
|
|
|
|
|
|
|
|
list = gst_structure_get_value (structure, "magnitude");
|
|
|
|
for (i = 0; i < SPECT_BANDS; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
|
|
|
level = g_value_get_float (value);
|
|
|
|
GST_DEBUG ("band[%3d] is %.2f", i, level);
|
|
|
|
/* Only the bands in the middle should have a level above 60 */
|
|
|
|
fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level < -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level > -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
}
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
/* flush current messages,and future state change messages */
|
|
|
|
gst_bus_set_flushing (bus, TRUE);
|
|
|
|
|
|
|
|
/* message has a ref to the element */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
|
|
|
|
gst_message_unref (message);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
|
|
|
|
gst_element_set_bus (spectrum, NULL);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
cleanup_spectrum (spectrum);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_float32)
|
|
|
|
{
|
|
|
|
GstElement *spectrum;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
|
|
|
const GstStructure *structure;
|
|
|
|
int i, j;
|
2012-01-31 14:39:09 +00:00
|
|
|
gfloat *data;
|
|
|
|
GstMapInfo map;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
const GValue *list, *value;
|
|
|
|
GstClockTime endtime;
|
|
|
|
gfloat level;
|
|
|
|
|
2013-05-09 22:32:23 +00:00
|
|
|
spectrum = setup_spectrum (SPECT_CAPS_STRING_F32);
|
2011-10-27 22:24:14 +00:00
|
|
|
g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
"bands", SPECT_BANDS, "threshold", -80, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
2011-10-27 22:24:14 +00:00
|
|
|
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gfloat), 0);
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
data = (gfloat *) map.data;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
for (j = 0; j < 44100; j += 4) {
|
|
|
|
*data = 0.0;
|
|
|
|
++data;
|
|
|
|
*data = 1.0;
|
|
|
|
++data;
|
|
|
|
*data = 0.0;
|
|
|
|
++data;
|
|
|
|
*data = -1.0;
|
|
|
|
++data;
|
|
|
|
}
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* create a bus to get the spectrum message on */
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_element_set_bus (spectrum, bus);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (message, "message", 1);
|
|
|
|
|
|
|
|
fail_unless (message != NULL);
|
|
|
|
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
|
|
|
|
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
|
|
|
|
structure = gst_message_get_structure (message);
|
|
|
|
fail_if (structure == NULL);
|
|
|
|
fail_unless_equals_string ((char *) gst_structure_get_name (structure),
|
|
|
|
"spectrum");
|
|
|
|
fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));
|
|
|
|
|
|
|
|
list = gst_structure_get_value (structure, "magnitude");
|
|
|
|
for (i = 0; i < SPECT_BANDS; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
|
|
|
level = g_value_get_float (value);
|
|
|
|
GST_DEBUG ("band[%3d] is %.2f", i, level);
|
|
|
|
/* Only the bands in the middle should have a level above 60 */
|
|
|
|
fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level < -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level > -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
}
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
/* flush current messages,and future state change messages */
|
|
|
|
gst_bus_set_flushing (bus, TRUE);
|
|
|
|
|
|
|
|
/* message has a ref to the element */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
|
|
|
|
gst_message_unref (message);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
|
|
|
|
gst_element_set_bus (spectrum, NULL);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
cleanup_spectrum (spectrum);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_float64)
|
|
|
|
{
|
|
|
|
GstElement *spectrum;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
|
|
|
const GstStructure *structure;
|
|
|
|
int i, j;
|
2012-01-31 14:39:09 +00:00
|
|
|
gdouble *data;
|
|
|
|
GstMapInfo map;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
const GValue *list, *value;
|
|
|
|
GstClockTime endtime;
|
|
|
|
gfloat level;
|
|
|
|
|
2013-05-09 22:32:23 +00:00
|
|
|
spectrum = setup_spectrum (SPECT_CAPS_STRING_F64);
|
2011-10-27 22:24:14 +00:00
|
|
|
g_object_set (spectrum, "post-messages", TRUE, "interval", GST_SECOND / 100,
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
"bands", SPECT_BANDS, "threshold", -80, NULL);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
/* create a 1 sec buffer with an 11025 Hz sine wave */
|
2011-10-27 22:24:14 +00:00
|
|
|
inbuffer = gst_buffer_new_allocate (NULL, 44100 * sizeof (gdouble), 0);
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_map (inbuffer, &map, GST_MAP_WRITE);
|
|
|
|
data = (gdouble *) map.data;
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
for (j = 0; j < 44100; j += 4) {
|
|
|
|
*data = 0.0;
|
|
|
|
++data;
|
|
|
|
*data = 1.0;
|
|
|
|
++data;
|
|
|
|
*data = 0.0;
|
|
|
|
++data;
|
|
|
|
*data = -1.0;
|
2007-06-20 08:56:17 +00:00
|
|
|
++data;
|
|
|
|
}
|
2012-01-31 14:39:09 +00:00
|
|
|
gst_buffer_unmap (inbuffer, &map);
|
2007-06-20 08:56:17 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* create a bus to get the spectrum message on */
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_element_set_bus (spectrum, bus);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
message = gst_bus_poll (bus, GST_MESSAGE_ELEMENT, -1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (message, "message", 1);
|
|
|
|
|
|
|
|
fail_unless (message != NULL);
|
|
|
|
fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (spectrum));
|
|
|
|
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ELEMENT);
|
|
|
|
structure = gst_message_get_structure (message);
|
|
|
|
fail_if (structure == NULL);
|
|
|
|
fail_unless_equals_string ((char *) gst_structure_get_name (structure),
|
|
|
|
"spectrum");
|
|
|
|
fail_unless (gst_structure_get_clock_time (structure, "endtime", &endtime));
|
|
|
|
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
list = gst_structure_get_value (structure, "magnitude");
|
2007-06-20 08:56:17 +00:00
|
|
|
for (i = 0; i < SPECT_BANDS; ++i) {
|
|
|
|
value = gst_value_list_get_value (list, i);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
level = g_value_get_float (value);
|
|
|
|
GST_DEBUG ("band[%3d] is %.2f", i, level);
|
|
|
|
/* Only the bands in the middle should have a level above 60 */
|
|
|
|
fail_if ((i == SPECT_BANDS / 2 || i == SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level < -20.0);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
|
2007-11-14 17:03:18 +00:00
|
|
|
&& level > -20.0);
|
2007-06-20 08:56:17 +00:00
|
|
|
}
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
/* clean up */
|
|
|
|
/* flush current messages,and future state change messages */
|
|
|
|
gst_bus_set_flushing (bus, TRUE);
|
|
|
|
|
|
|
|
/* message has a ref to the element */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 2);
|
|
|
|
gst_message_unref (message);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
|
|
|
|
gst_element_set_bus (spectrum, NULL);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
|
|
|
gst_object_unref (bus);
|
|
|
|
fail_unless (gst_element_set_state (spectrum,
|
|
|
|
GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
|
|
|
|
ASSERT_OBJECT_REFCOUNT (spectrum, "spectrum", 1);
|
|
|
|
cleanup_spectrum (spectrum);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
|
2010-03-17 17:23:00 +00:00
|
|
|
static Suite *
|
2007-06-20 08:56:17 +00:00
|
|
|
spectrum_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("spectrum");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
tcase_add_test (tc_chain, test_int16);
|
Port GstSpectrum to GstAudioFilter and libgstfft, add support for int32, float and double, use floats for the message...
Original commit message from CVS:
* configure.ac:
* gst/spectrum/Makefile.am:
* gst/spectrum/demo-audiotest.c: (draw_spectrum),
(message_handler), (main):
* gst/spectrum/demo-osssrc.c: (draw_spectrum), (message_handler):
* gst/spectrum/gstspectrum.c: (gst_spectrum_base_init),
(gst_spectrum_class_init), (gst_spectrum_init),
(gst_spectrum_dispose), (gst_spectrum_set_property),
(gst_spectrum_get_property), (gst_spectrum_start),
(gst_spectrum_setup), (gst_spectrum_message_new),
(gst_spectrum_transform_ip):
* gst/spectrum/gstspectrum.h:
Port GstSpectrum to GstAudioFilter and libgstfft, add support
for int32, float and double, use floats for the message contents,
average all FFTs done in one interval for better results, use
a better windowing function, allow posting the phase in the message
and actually do an FFT with the requested number of bands instead
of interpolating.
* tests/check/elements/spectrum.c: (GST_START_TEST),
(spectrum_suite):
Improve the units tests by checking for a 11025Hz sine wave
and add unit tests for all 4 supported sample types.
2007-09-06 07:21:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_int32);
|
|
|
|
tcase_add_test (tc_chain, test_float32);
|
|
|
|
tcase_add_test (tc_chain, test_float64);
|
2007-06-20 08:56:17 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2015-06-02 14:27:24 +00:00
|
|
|
GST_CHECK_MAIN (spectrum);
|