summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Schmidt <thaytan@mad.scientist.com>2008-02-08 03:27:14 +0000
committerJan Schmidt <thaytan@mad.scientist.com>2008-02-08 03:27:14 +0000
commit819b139e4e36f8ce3d70acdbcaaec770365de669 (patch)
tree60fc4ce018037df7a947fb73e9887e3594fda2cd
parent4de96f3a8e58fa385f72bbf7c88941e4e4942692 (diff)
downloadgst-plugins-bad-819b139e4e36f8ce3d70acdbcaaec770365de669.tar.gz
gst-plugins-bad-819b139e4e36f8ce3d70acdbcaaec770365de669.tar.bz2
gst-plugins-bad-819b139e4e36f8ce3d70acdbcaaec770365de669.zip
Remove spectrum plugin, which has moved to -good
Original commit message from CVS: * configure.ac: * docs/plugins/Makefile.am: * docs/plugins/gst-plugins-bad-plugins-docs.sgml: * docs/plugins/gst-plugins-bad-plugins-sections.txt: * docs/plugins/gst-plugins-bad-plugins.args: * docs/plugins/gst-plugins-bad-plugins.hierarchy: * docs/plugins/inspect/plugin-spectrum.xml: * gst/spectrum/.cvsignore: * gst/spectrum/Makefile.am: * gst/spectrum/README: * gst/spectrum/demo-audiotest.c: * gst/spectrum/demo-osssrc.c: * gst/spectrum/gstspectrum.c: * gst/spectrum/gstspectrum.h: * gst/spectrum/spectrum.vcproj: * tests/check/Makefile.am: * tests/check/elements/spectrum.c: Remove spectrum plugin, which has moved to -good
-rw-r--r--ChangeLog22
-rw-r--r--configure.ac2
-rw-r--r--docs/plugins/Makefile.am1
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-docs.sgml2
-rw-r--r--docs/plugins/gst-plugins-bad-plugins-sections.txt16
-rw-r--r--docs/plugins/gst-plugins-bad-plugins.args60
-rw-r--r--docs/plugins/gst-plugins-bad-plugins.hierarchy1
-rw-r--r--docs/plugins/inspect/plugin-spectrum.xml34
-rw-r--r--gst/spectrum/.gitignore9
-rw-r--r--gst/spectrum/Makefile.am24
-rw-r--r--gst/spectrum/README5
-rw-r--r--gst/spectrum/demo-audiotest.c178
-rw-r--r--gst/spectrum/demo-osssrc.c153
-rw-r--r--gst/spectrum/gstspectrum.c693
-rw-r--r--gst/spectrum/gstspectrum.h86
-rw-r--r--gst/spectrum/spectrum.vcproj151
-rw-r--r--tests/check/Makefile.am3
-rw-r--r--tests/check/elements/spectrum.c571
18 files changed, 23 insertions, 1988 deletions
diff --git a/ChangeLog b/ChangeLog
index efbfcc3b..e4fdcc8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
2008-02-08 Jan Schmidt <jan.schmidt@sun.com>
+ * configure.ac:
+ * docs/plugins/Makefile.am:
+ * docs/plugins/gst-plugins-bad-plugins-docs.sgml:
+ * docs/plugins/gst-plugins-bad-plugins-sections.txt:
+ * docs/plugins/gst-plugins-bad-plugins.args:
+ * docs/plugins/gst-plugins-bad-plugins.hierarchy:
+ * docs/plugins/inspect/plugin-spectrum.xml:
+ * gst/spectrum/.cvsignore:
+ * gst/spectrum/Makefile.am:
+ * gst/spectrum/README:
+ * gst/spectrum/demo-audiotest.c:
+ * gst/spectrum/demo-osssrc.c:
+ * gst/spectrum/gstspectrum.c:
+ * gst/spectrum/gstspectrum.h:
+ * gst/spectrum/spectrum.vcproj:
+ * tests/check/Makefile.am:
+ * tests/check/elements/spectrum.c:
+
+ Remove spectrum plugin, which has moved to -good
+
+2008-02-08 Jan Schmidt <jan.schmidt@sun.com>
+
* docs/plugins/gst-plugins-bad-plugins.args:
* docs/plugins/gst-plugins-bad-plugins.hierarchy:
* docs/plugins/gst-plugins-bad-plugins.interfaces:
diff --git a/configure.ac b/configure.ac
index f30421c4..70cafc21 100644
--- a/configure.ac
+++ b/configure.ac
@@ -105,7 +105,6 @@ GST_PLUGINS_ALL="\
rtpmanager \
sdp \
selector \
- spectrum \
speexresample \
speed \
stereo \
@@ -1065,7 +1064,6 @@ gst/replaygain/Makefile
gst/rtpmanager/Makefile
gst/sdp/Makefile
gst/selector/Makefile
-gst/spectrum/Makefile
gst/speed/Makefile
gst/speexresample/Makefile
gst/stereo/Makefile
diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am
index d899af20..9dc5cb61 100644
--- a/docs/plugins/Makefile.am
+++ b/docs/plugins/Makefile.am
@@ -132,7 +132,6 @@ EXTRA_HFILES = \
$(top_srcdir)/gst/sdp/gstsdpdemux.h \
$(top_srcdir)/gst/selector/gstinputselector.h \
$(top_srcdir)/gst/selector/gstoutputselector.h \
- $(top_srcdir)/gst/spectrum/gstspectrum.h \
$(top_srcdir)/gst/speed/gstspeed.h \
$(top_srcdir)/gst/speexresample/gstspeexresample.h \
$(top_srcdir)/gst/videosignal/gstvideoanalyse.h \
diff --git a/docs/plugins/gst-plugins-bad-plugins-docs.sgml b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
index 087f02b4..5dcfc540 100644
--- a/docs/plugins/gst-plugins-bad-plugins-docs.sgml
+++ b/docs/plugins/gst-plugins-bad-plugins-docs.sgml
@@ -49,7 +49,6 @@
<xi:include href="xml/element-sdlvideosink.xml" />
<xi:include href="xml/element-sdpdemux.xml" />
<xi:include href="xml/element-souphttpsrc.xml" />
- <xi:include href="xml/element-spectrum.xml" />
<xi:include href="xml/element-speed.xml" />
<xi:include href="xml/element-speexresample.xml" />
<!--xi:include href="xml/element-theoradecexp.xml" /-->
@@ -119,7 +118,6 @@
<xi:include href="xml/plugin-soundtouch.xml" />
<xi:include href="xml/plugin-soup.xml" />
<xi:include href="xml/plugin-spcdec.xml" />
- <xi:include href="xml/plugin-spectrum.xml" />
<xi:include href="xml/plugin-speed.xml" />
<xi:include href="xml/plugin-speexresample.xml" />
<xi:include href="xml/plugin-stereo.xml" />
diff --git a/docs/plugins/gst-plugins-bad-plugins-sections.txt b/docs/plugins/gst-plugins-bad-plugins-sections.txt
index c0910d0c..fd48bba1 100644
--- a/docs/plugins/gst-plugins-bad-plugins-sections.txt
+++ b/docs/plugins/gst-plugins-bad-plugins-sections.txt
@@ -592,22 +592,6 @@ GST_SDP_STREAM_UNLOCK
</SECTION>
<SECTION>
-<FILE>element-spectrum</FILE>
-<TITLE>spectrum</TITLE>
-GstSpectrum
-<SUBSECTION Standard>
-GstSpectrumClass
-GstSpectrumFFTFreeFunc
-GstSpectrumProcessFunc
-GST_SPECTRUM
-GST_SPECTRUM_CLASS
-GST_IS_SPECTRUM
-GST_IS_SPECTRUM_CLASS
-GST_TYPE_SPECTRUM
-gst_spectrum_get_type
-</SECTION>
-
-<SECTION>
<FILE>element-speed</FILE>
<TITLE>speed</TITLE>
GstSpeed
diff --git a/docs/plugins/gst-plugins-bad-plugins.args b/docs/plugins/gst-plugins-bad-plugins.args
index dd3505a0..855d9ed6 100644
--- a/docs/plugins/gst-plugins-bad-plugins.args
+++ b/docs/plugins/gst-plugins-bad-plugins.args
@@ -1339,66 +1339,6 @@
</ARG>
<ARG>
-<NAME>GstSpectrum::bands</NAME>
-<TYPE>guint</TYPE>
-<RANGE></RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Bands</NICK>
-<BLURB>number of frequency bands.</BLURB>
-<DEFAULT>128</DEFAULT>
-</ARG>
-
-<ARG>
-<NAME>GstSpectrum::interval</NAME>
-<TYPE>guint64</TYPE>
-<RANGE>>= 1</RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Interval</NICK>
-<BLURB>Interval of time between message posts (in nanoseconds).</BLURB>
-<DEFAULT>100000000</DEFAULT>
-</ARG>
-
-<ARG>
-<NAME>GstSpectrum::message</NAME>
-<TYPE>gboolean</TYPE>
-<RANGE></RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Message</NICK>
-<BLURB>Post a level message for each passed interval.</BLURB>
-<DEFAULT>TRUE</DEFAULT>
-</ARG>
-
-<ARG>
-<NAME>GstSpectrum::threshold</NAME>
-<TYPE>gint</TYPE>
-<RANGE><= 0</RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Threshold</NICK>
-<BLURB>dB threshold for result. All lower values will be set to this.</BLURB>
-<DEFAULT>-60</DEFAULT>
-</ARG>
-
-<ARG>
-<NAME>GstSpectrum::message-magnitude</NAME>
-<TYPE>gboolean</TYPE>
-<RANGE></RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Magnitude</NICK>
-<BLURB>Post the magnitude of the spectrum.</BLURB>
-<DEFAULT>TRUE</DEFAULT>
-</ARG>
-
-<ARG>
-<NAME>GstSpectrum::message-phase</NAME>
-<TYPE>gboolean</TYPE>
-<RANGE></RANGE>
-<FLAGS>rw</FLAGS>
-<NICK>Phase</NICK>
-<BLURB>Post the phase of the spectrum.</BLURB>
-<DEFAULT>FALSE</DEFAULT>
-</ARG>
-
-<ARG>
<NAME>GstModPlug::megabass</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
diff --git a/docs/plugins/gst-plugins-bad-plugins.hierarchy b/docs/plugins/gst-plugins-bad-plugins.hierarchy
index 452723e0..4097768c 100644
--- a/docs/plugins/gst-plugins-bad-plugins.hierarchy
+++ b/docs/plugins/gst-plugins-bad-plugins.hierarchy
@@ -52,7 +52,6 @@ GObject
GstBaseTransform
GstAudioFilter
GstBPMDetect
- GstSpectrum
GstStereo
GstGLUpload
GstGLDownload
diff --git a/docs/plugins/inspect/plugin-spectrum.xml b/docs/plugins/inspect/plugin-spectrum.xml
deleted file mode 100644
index 623fc53c..00000000
--- a/docs/plugins/inspect/plugin-spectrum.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<plugin>
- <name>spectrum</name>
- <description>Run an FFT on the audio signal, output spectrum data</description>
- <filename>../../gst/spectrum/.libs/libgstspectrum.so</filename>
- <basename>libgstspectrum.so</basename>
- <version>0.10.5.1</version>
- <license>LGPL</license>
- <source>gst-plugins-bad</source>
- <package>GStreamer Bad Plug-ins CVS/prerelease</package>
- <origin>Unknown package origin</origin>
- <elements>
- <element>
- <name>spectrum</name>
- <longname>Spectrum analyzer</longname>
- <class>Filter/Analyzer/Audio</class>
- <description>Run an FFT on the audio signal, output spectrum data</description>
- <author>Erik Walthinsen &lt;omega@cse.ogi.edu&gt;, Stefan Kost &lt;ensonic@users.sf.net&gt;, Sebastian Dröge &lt;slomo@circular-chaos.org&gt;</author>
- <pads>
- <caps>
- <name>sink</name>
- <direction>sink</direction>
- <presence>always</presence>
- <details>audio/x-raw-int, width=(int)16, depth=(int)16, signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-int, width=(int)32, depth=(int)32, signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details>
- </caps>
- <caps>
- <name>src</name>
- <direction>source</direction>
- <presence>always</presence>
- <details>audio/x-raw-int, width=(int)16, depth=(int)16, signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-int, width=(int)32, depth=(int)32, signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details>
- </caps>
- </pads>
- </element>
- </elements>
-</plugin> \ No newline at end of file
diff --git a/gst/spectrum/.gitignore b/gst/spectrum/.gitignore
deleted file mode 100644
index 08f366f8..00000000
--- a/gst/spectrum/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-Makefile
-Makefile.in
-*.o
-*.lo
-*.la
-.deps
-.libs
-demo-audiotest
-demo-osssrc
diff --git a/gst/spectrum/Makefile.am b/gst/spectrum/Makefile.am
deleted file mode 100644
index e161abbf..00000000
--- a/gst/spectrum/Makefile.am
+++ /dev/null
@@ -1,24 +0,0 @@
-
-plugin_LTLIBRARIES = libgstspectrum.la
-
-libgstspectrum_la_SOURCES = gstspectrum.c
-libgstspectrum_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) \
- $(GST_CFLAGS)
-libgstspectrum_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) $(GST_BASE_LIBS) $(GST_LIBS) -lgstaudio-$(GST_MAJORMINOR) -lgstfft-$(GST_MAJORMINOR) $(LIBM)
-libgstspectrum_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
-
-noinst_HEADERS = gstspectrum.h
-
-if HAVE_GTK
-noinst_PROGRAMS = demo-osssrc demo-audiotest
-endif
-
-demo_osssrc_SOURCES = demo-osssrc.c
-demo_osssrc_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
-demo_osssrc_LDFLAGS = $(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS)
-
-demo_audiotest_SOURCES = demo-audiotest.c
-demo_audiotest_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
-demo_audiotest_LDFLAGS = $(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS)
-
-EXTRA_DIST = README
diff --git a/gst/spectrum/README b/gst/spectrum/README
deleted file mode 100644
index 87555712..00000000
--- a/gst/spectrum/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This is a simple, rather lame spectrum analyzer made from the fix_fft.c
-code, as found I think in xmms-0.9.1 (the 75-wide output sounds like xmms
-to me), which is actually written by other people (see fix_fft.c for
-credits). It worked last time I had GiST working, which was a while ago.
-Yes, GiST is not included here yet, it will be in 0.1.0.
diff --git a/gst/spectrum/demo-audiotest.c b/gst/spectrum/demo-audiotest.c
deleted file mode 100644
index bc2e9abc..00000000
--- a/gst/spectrum/demo-audiotest.c
+++ /dev/null
@@ -1,178 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-/* TODO: add wave selection */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <gst/gst.h>
-#include <gtk/gtk.h>
-
-#define DEFAULT_AUDIOSINK "autoaudiosink"
-
-static GtkWidget *drawingarea = NULL;
-static guint spect_height = 64;
-static guint spect_bands = 256;
-static gfloat height_scale = 1.0;
-
-static void
-on_window_destroy (GtkObject * object, gpointer user_data)
-{
- drawingarea = NULL;
- gtk_main_quit ();
-}
-
-/* control audiotestsrc frequency */
-static void
-on_frequency_changed (GtkRange * range, gpointer user_data)
-{
- GstElement *machine = GST_ELEMENT (user_data);
- gdouble value = gtk_range_get_value (range);
-
- g_object_set (machine, "freq", value, NULL);
-}
-
-gboolean
-on_configure_event (GtkWidget * widget, GdkEventConfigure * event,
- gpointer user_data)
-{
- GstElement *spectrum = GST_ELEMENT (user_data);
-
- /*GST_INFO ("%d x %d", event->width, event->height); */
- spect_height = event->height;
- height_scale = event->height / 64.0;
- spect_bands = event->width;
-
- g_object_set (G_OBJECT (spectrum), "bands", spect_bands, NULL);
- return FALSE;
-}
-
-/* draw frequency spectrum as a bunch of bars */
-static void
-draw_spectrum (gfloat * data)
-{
- gint i;
- GdkRectangle rect = { 0, 0, spect_bands, spect_height };
-
- if (!drawingarea)
- return;
-
- gdk_window_begin_paint_rect (drawingarea->window, &rect);
- gdk_draw_rectangle (drawingarea->window, drawingarea->style->black_gc,
- TRUE, 0, 0, spect_bands, spect_height);
- for (i = 0; i < spect_bands; i++) {
- gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
- TRUE, i, -data[i], 1, spect_height + data[i]);
- }
- gdk_window_end_paint (drawingarea->window);
-}
-
-/* receive spectral data from element message */
-gboolean
-message_handler (GstBus * bus, GstMessage * message, gpointer data)
-{
- if (message->type == GST_MESSAGE_ELEMENT) {
- const GstStructure *s = gst_message_get_structure (message);
- const gchar *name = gst_structure_get_name (s);
-
- if (strcmp (name, "spectrum") == 0) {
- gfloat spect[spect_bands];
- const GValue *list;
- const GValue *value;
- guint i;
-
- list = gst_structure_get_value (s, "magnitude");
- for (i = 0; i < spect_bands; ++i) {
- value = gst_value_list_get_value (list, i);
- spect[i] = height_scale * g_value_get_float (value);
- }
- draw_spectrum (spect);
- }
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GstElement *bin;
- GstElement *src, *spectrum, *audioconvert, *sink;
- GstBus *bus;
- GtkWidget *appwindow, *vbox, *widget;
-
- gst_init (&argc, &argv);
- gtk_init (&argc, &argv);
-
- bin = gst_pipeline_new ("bin");
-
- src = gst_element_factory_make ("audiotestsrc", "src");
- g_object_set (G_OBJECT (src), "wave", 0, NULL);
-
- spectrum = gst_element_factory_make ("spectrum", "spectrum");
- g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
- "message", TRUE, NULL);
-
- audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
-
- sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink");
-
- gst_bin_add_many (GST_BIN (bin), src, spectrum, audioconvert, sink, NULL);
- if (!gst_element_link_many (src, spectrum, audioconvert, sink, NULL)) {
- fprintf (stderr, "can't link elements\n");
- exit (1);
- }
-
- bus = gst_element_get_bus (bin);
- gst_bus_add_watch (bus, message_handler, NULL);
- gst_object_unref (bus);
-
- appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (appwindow), "destroy",
- G_CALLBACK (on_window_destroy), NULL);
- vbox = gtk_vbox_new (FALSE, 6);
-
- widget = gtk_hscale_new_with_range (50.0, 20000.0, 10);
- gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE);
- gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP);
- gtk_range_set_value (GTK_RANGE (widget), 440.0);
- g_signal_connect (G_OBJECT (widget), "value-changed",
- G_CALLBACK (on_frequency_changed), (gpointer) src);
- gtk_box_pack_start (GTK_BOX (vbox), widget, FALSE, FALSE, 0);
-
- drawingarea = gtk_drawing_area_new ();
- gtk_widget_set_size_request (drawingarea, spect_bands, spect_height);
- g_signal_connect (G_OBJECT (drawingarea), "configure-event",
- G_CALLBACK (on_configure_event), (gpointer) spectrum);
- gtk_box_pack_start (GTK_BOX (vbox), drawingarea, TRUE, TRUE, 0);
-
- gtk_container_add (GTK_CONTAINER (appwindow), vbox);
- gtk_widget_show_all (appwindow);
-
- gst_element_set_state (bin, GST_STATE_PLAYING);
- gtk_main ();
- gst_element_set_state (bin, GST_STATE_NULL);
-
- gst_object_unref (bin);
-
- return 0;
-}
diff --git a/gst/spectrum/demo-osssrc.c b/gst/spectrum/demo-osssrc.c
deleted file mode 100644
index eb28cff7..00000000
--- a/gst/spectrum/demo-osssrc.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/* GStreamer
- * Copyright (C) 2006 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <gst/gst.h>
-#include <gtk/gtk.h>
-
-#define DEFAULT_AUDIOSRC "alsasrc"
-static guint spect_height = 64;
-static guint spect_bands = 256;
-static gfloat height_scale = 1.0;
-
-static GtkWidget *drawingarea = NULL;
-
-static void
-on_window_destroy (GtkObject * object, gpointer user_data)
-{
- drawingarea = NULL;
- gtk_main_quit ();
-}
-
-gboolean
-on_configure_event (GtkWidget * widget, GdkEventConfigure * event,
- gpointer user_data)
-{
- GstElement *spectrum = GST_ELEMENT (user_data);
-
- /*GST_INFO ("%d x %d", event->width, event->height); */
- spect_height = event->height;
- height_scale = event->height / 64.0;
- spect_bands = event->width;
-
- g_object_set (G_OBJECT (spectrum), "bands", spect_bands, NULL);
- return FALSE;
-}
-
-/* draw frequency spectrum as a bunch of bars */
-static void
-draw_spectrum (gfloat * data)
-{
- gint i;
- GdkRectangle rect = { 0, 0, spect_bands, spect_height };
-
- if (!drawingarea)
- return;
-
- gdk_window_begin_paint_rect (drawingarea->window, &rect);
- gdk_draw_rectangle (drawingarea->window, drawingarea->style->black_gc,
- TRUE, 0, 0, spect_bands, spect_height);
- for (i = 0; i < spect_bands; i++) {
- gdk_draw_rectangle (drawingarea->window, drawingarea->style->white_gc,
- TRUE, i, -data[i], 1, spect_height + data[i]);
- }
- gdk_window_end_paint (drawingarea->window);
-}
-
-/* receive spectral data from element message */
-gboolean
-message_handler (GstBus * bus, GstMessage * message, gpointer data)
-{
- if (message->type == GST_MESSAGE_ELEMENT) {
- const GstStructure *s = gst_message_get_structure (message);
- const gchar *name = gst_structure_get_name (s);
-
- if (strcmp (name, "spectrum") == 0) {
- gfloat spect[spect_bands];
- const GValue *list;
- const GValue *value;
- guint i;
-
- list = gst_structure_get_value (s, "magnitude");
- for (i = 0; i < spect_bands; ++i) {
- value = gst_value_list_get_value (list, i);
- spect[i] = height_scale * g_value_get_float (value);
- }
- draw_spectrum (spect);
- }
- }
- return TRUE;
-}
-
-int
-main (int argc, char *argv[])
-{
- GstElement *bin;
- GstElement *src, *spectrum, *sink;
- GstBus *bus;
- GtkWidget *appwindow;
-
- gst_init (&argc, &argv);
- gtk_init (&argc, &argv);
-
- bin = gst_pipeline_new ("bin");
-
- src = gst_element_factory_make (DEFAULT_AUDIOSRC, "src");
-
- spectrum = gst_element_factory_make ("spectrum", "spectrum");
- g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80,
- "message", TRUE, NULL);
-
- sink = gst_element_factory_make ("fakesink", "sink");
-
- gst_bin_add_many (GST_BIN (bin), src, spectrum, sink, NULL);
- if (!gst_element_link_many (src, spectrum, sink, NULL)) {
- fprintf (stderr, "can't link elements\n");
- exit (1);
- }
-
- bus = gst_element_get_bus (bin);
- gst_bus_add_watch (bus, message_handler, NULL);
- gst_object_unref (bus);
-
- appwindow = gtk_window_new (GTK_WINDOW_TOPLEVEL);
- g_signal_connect (G_OBJECT (appwindow), "destroy",
- G_CALLBACK (on_window_destroy), NULL);
-
- drawingarea = gtk_drawing_area_new ();
- gtk_widget_set_size_request (drawingarea, spect_bands, spect_height);
- g_signal_connect (G_OBJECT (drawingarea), "configure-event",
- G_CALLBACK (on_configure_event), (gpointer) spectrum);
- gtk_container_add (GTK_CONTAINER (appwindow), drawingarea);
- gtk_widget_show_all (appwindow);
-
- gst_element_set_state (bin, GST_STATE_PLAYING);
- gtk_main ();
- gst_element_set_state (bin, GST_STATE_NULL);
-
- gst_object_unref (bin);
-
- return 0;
-}
diff --git a/gst/spectrum/gstspectrum.c b/gst/spectrum/gstspectrum.c
deleted file mode 100644
index e3f7b2d4..00000000
--- a/gst/spectrum/gstspectrum.c
+++ /dev/null
@@ -1,693 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- * <2006> Stefan Kost <ensonic@users.sf.net>
- * <2007> Sebastian Dröge <slomo@circular-chaos.org>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-/**
- * SECTION:element-spectrum
- * @short_description: audio spectrum analyzer
- *
- * <refsect2>
- * <para>
- * The Spectrum element analyzes the frequency spectrum of an audio signal.
- * If #GstSpectrum:message property is #TRUE it sends analysis results as
- * application message named
- * <classname>&quot;spectrum&quot;</classname> after each interval of time given
- * by the #GstSpectrum:interval property.
- * </para>
- * <para>
- * The message's structure contains three fields:
- * <itemizedlist>
- * <listitem>
- * <para>
- * #GstClockTime
- * <classname>&quot;endtime&quot;</classname>:
- * the end time of the buffer that triggered the message
- * </para>
- * </listitem>
- * <listitem>
- * <para>
- * #GstValueList of #gfloat
- * <classname>&quot;magnitude&quot;</classname>:
- * the level for each frequency band in dB. All values below the value of the
- * #GstSpectrum:threshold property will be set to the threshold.
- * </para>
- * </listitem>
- * <listitem>
- * <para>
- * #GstValueList of #gfloat
- * <classname>&quot;phase&quot;</classname>:
- * the phase for each frequency band. The value is between -pi and pi.
- * </para>
- * </listitem>
- * </itemizedlist>
- * </para>
- * <para>
- * This element cannot be used with the gst-launch command in a sensible way.
- * The included demo shows how to use it in an application.
- * </para>
- * <para>
- * Last reviewed on 2008-02-07 (0.10.6)
- * </para>
- * </refsect2>
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#include <string.h>
-#include <stdlib.h>
-#include <gst/audio/audio.h>
-#include <gst/audio/gstaudiofilter.h>
-#include <math.h>
-#include "gstspectrum.h"
-
-#include <gst/fft/gstfft.h>
-#include <gst/fft/gstffts16.h>
-#include <gst/fft/gstffts32.h>
-#include <gst/fft/gstfftf32.h>
-#include <gst/fft/gstfftf64.h>
-
-GST_DEBUG_CATEGORY_STATIC (gst_spectrum_debug);
-#define GST_CAT_DEFAULT gst_spectrum_debug
-
-/* elementfactory information */
-static const GstElementDetails gst_spectrum_details =
-GST_ELEMENT_DETAILS ("Spectrum analyzer",
- "Filter/Analyzer/Audio",
- "Run an FFT on the audio signal, output spectrum data",
- "Erik Walthinsen <omega@cse.ogi.edu>, "
- "Stefan Kost <ensonic@users.sf.net>, "
- "Sebastian Dröge <slomo@circular-chaos.org>");
-
-#define ALLOWED_CAPS \
- "audio/x-raw-int, " \
- " width = (int) 16, " \
- " depth = (int) 16, " \
- " signed = (boolean) true, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]; " \
- "audio/x-raw-int, " \
- " width = (int) 32, " \
- " depth = (int) 32, " \
- " signed = (boolean) true, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]; " \
- "audio/x-raw-float, " \
- " width = (int) { 32, 64 }, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]"
-
-/* Spectrum properties */
-#define DEFAULT_SIGNAL_SPECTRUM TRUE
-#define DEFAULT_SIGNAL_MAGNITUDE TRUE
-#define DEFAULT_SIGNAL_PHASE FALSE
-#define DEFAULT_SIGNAL_INTERVAL (GST_SECOND / 10)
-#define DEFAULT_BANDS 128
-#define DEFAULT_THRESHOLD -60
-
-#define SPECTRUM_WINDOW_BASE 9
-#define SPECTRUM_WINDOW_LEN (1 << (SPECTRUM_WINDOW_BASE+1))
-
-enum
-{
- PROP_0,
- PROP_SIGNAL_SPECTRUM,
- PROP_SIGNAL_MAGNITUDE,
- PROP_SIGNAL_PHASE,
- PROP_SIGNAL_INTERVAL,
- PROP_BANDS,
- PROP_THRESHOLD
-};
-
-GST_BOILERPLATE (GstSpectrum, gst_spectrum, GstAudioFilter,
- GST_TYPE_AUDIO_FILTER);
-
-static void gst_spectrum_dispose (GObject * object);
-static void gst_spectrum_finalize (GObject * object);
-static void gst_spectrum_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_spectrum_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-static gboolean gst_spectrum_start (GstBaseTransform * trans);
-static gboolean gst_spectrum_stop (GstBaseTransform * trans);
-static gboolean gst_spectrum_event (GstBaseTransform * trans, GstEvent * event);
-static GstFlowReturn gst_spectrum_transform_ip (GstBaseTransform * trans,
- GstBuffer * in);
-static gboolean gst_spectrum_setup (GstAudioFilter * base,
- GstRingBufferSpec * format);
-
-static void process_s16 (GstSpectrum * spectrum, const gint16 * samples);
-static void process_s32 (GstSpectrum * spectrum, const gint32 * samples);
-static void process_f32 (GstSpectrum * spectrum, const gfloat * samples);
-static void process_f64 (GstSpectrum * spectrum, const gdouble * samples);
-
-static void
-gst_spectrum_base_init (gpointer g_class)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
- GstCaps *caps;
-
- gst_element_class_set_details (element_class, &gst_spectrum_details);
-
- caps = gst_caps_from_string (ALLOWED_CAPS);
- gst_audio_filter_class_add_pad_templates (GST_AUDIO_FILTER_CLASS (g_class),
- caps);
- gst_caps_unref (caps);
-}
-
-static void
-gst_spectrum_class_init (GstSpectrumClass * klass)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
- GstBaseTransformClass *trans_class = GST_BASE_TRANSFORM_CLASS (klass);
- GstAudioFilterClass *filter_class = GST_AUDIO_FILTER_CLASS (klass);
-
- gobject_class->set_property = gst_spectrum_set_property;
- gobject_class->get_property = gst_spectrum_get_property;
- gobject_class->dispose = gst_spectrum_dispose;
- gobject_class->finalize = gst_spectrum_finalize;
-
- trans_class->start = GST_DEBUG_FUNCPTR (gst_spectrum_start);
- trans_class->stop = GST_DEBUG_FUNCPTR (gst_spectrum_stop);
- trans_class->event = GST_DEBUG_FUNCPTR (gst_spectrum_event);
- trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_spectrum_transform_ip);
- trans_class->passthrough_on_same_caps = TRUE;
-
- filter_class->setup = GST_DEBUG_FUNCPTR (gst_spectrum_setup);
-
- g_object_class_install_property (gobject_class, PROP_SIGNAL_SPECTRUM,
- g_param_spec_boolean ("message", "Message",
- "Post a level message for each passed interval",
- DEFAULT_SIGNAL_SPECTRUM, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SIGNAL_MAGNITUDE,
- g_param_spec_boolean ("message-magnitude", "Magnitude",
- "Post the magnitude of the spectrum",
- DEFAULT_SIGNAL_MAGNITUDE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SIGNAL_PHASE,
- g_param_spec_boolean ("message-phase", "Phase",
- "Post the phase of the spectrum",
- DEFAULT_SIGNAL_PHASE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SIGNAL_INTERVAL,
- g_param_spec_uint64 ("interval", "Interval",
- "Interval of time between message posts (in nanoseconds)",
- 1, G_MAXUINT64, DEFAULT_SIGNAL_INTERVAL, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_BANDS,
- g_param_spec_uint ("bands", "Bands", "number of frequency bands",
- 0, G_MAXUINT, DEFAULT_BANDS, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_THRESHOLD,
- g_param_spec_int ("threshold", "Threshold",
- "dB threshold for result. All lower values will be set to this",
- G_MININT, 0, DEFAULT_THRESHOLD, G_PARAM_READWRITE));
-
- GST_DEBUG_CATEGORY_INIT (gst_spectrum_debug, "spectrum", 0,
- "audio spectrum analyser element");
-}
-
-static void
-gst_spectrum_init (GstSpectrum * spectrum, GstSpectrumClass * g_class)
-{
- spectrum->adapter = gst_adapter_new ();
-
- spectrum->message = DEFAULT_SIGNAL_SPECTRUM;
- spectrum->message_magnitude = DEFAULT_SIGNAL_MAGNITUDE;
- spectrum->message_phase = DEFAULT_SIGNAL_PHASE;
- spectrum->interval = DEFAULT_SIGNAL_INTERVAL;
- spectrum->bands = DEFAULT_BANDS;
- spectrum->threshold = DEFAULT_THRESHOLD;
-
- spectrum->spect_magnitude = g_new0 (gfloat, spectrum->bands);
- spectrum->spect_phase = g_new0 (gfloat, spectrum->bands);
-}
-
-static void
-gst_spectrum_dispose (GObject * object)
-{
- GstSpectrum *spectrum = GST_SPECTRUM (object);
-
- if (spectrum->adapter) {
- g_object_unref (spectrum->adapter);
- spectrum->adapter = NULL;
- }
-
- G_OBJECT_CLASS (parent_class)->dispose (object);
-}
-
-static void
-gst_spectrum_finalize (GObject * object)
-{
- GstSpectrum *spectrum = GST_SPECTRUM (object);
-
- g_free (spectrum->in);
- if (spectrum->fft_free_func) {
- spectrum->fft_free_func (spectrum->fft_ctx);
- spectrum->fft_ctx = NULL;
- spectrum->fft_free_func = NULL;
- }
- g_free (spectrum->freqdata);
- g_free (spectrum->spect_magnitude);
- g_free (spectrum->spect_phase);
-
- spectrum->in = NULL;
- spectrum->spect_magnitude = NULL;
- spectrum->spect_phase = NULL;
- spectrum->freqdata = NULL;
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gst_spectrum_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstSpectrum *filter = GST_SPECTRUM (object);
-
- switch (prop_id) {
- case PROP_SIGNAL_SPECTRUM:
- filter->message = g_value_get_boolean (value);
- break;
- case PROP_SIGNAL_MAGNITUDE:
- filter->message_magnitude = g_value_get_boolean (value);
- break;
- case PROP_SIGNAL_PHASE:
- filter->message_phase = g_value_get_boolean (value);
- break;
- case PROP_SIGNAL_INTERVAL:
- filter->interval = g_value_get_uint64 (value);
- break;
- case PROP_BANDS:
- GST_BASE_TRANSFORM_LOCK (filter);
-
- filter->bands = g_value_get_uint (value);
- g_free (filter->spect_magnitude);
- g_free (filter->spect_phase);
- g_free (filter->in);
- g_free (filter->freqdata);
-
- if (filter->fft_free_func) {
- filter->fft_free_func (filter->fft_ctx);
- filter->fft_ctx = NULL;
- filter->fft_free_func = NULL;
- }
-
- filter->in = NULL;
- filter->freqdata = NULL;
- filter->spect_magnitude = g_new0 (gfloat, filter->bands);
- filter->spect_phase = g_new0 (gfloat, filter->bands);
- filter->num_frames = 0;
- filter->num_fft = 0;
- GST_BASE_TRANSFORM_UNLOCK (filter);
- GST_DEBUG_OBJECT (filter, "reallocation, spect = %p, bands =%d ",
- filter->spect_magnitude, filter->bands);
- break;
- case PROP_THRESHOLD:
- filter->threshold = g_value_get_int (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_spectrum_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstSpectrum *filter = GST_SPECTRUM (object);
-
- switch (prop_id) {
- case PROP_SIGNAL_SPECTRUM:
- g_value_set_boolean (value, filter->message);
- break;
- case PROP_SIGNAL_MAGNITUDE:
- g_value_set_boolean (value, filter->message_magnitude);
- break;
- case PROP_SIGNAL_PHASE:
- g_value_set_boolean (value, filter->message_phase);
- break;
- case PROP_SIGNAL_INTERVAL:
- g_value_set_uint64 (value, filter->interval);
- break;
- case PROP_BANDS:
- g_value_set_uint (value, filter->bands);
- break;
- case PROP_THRESHOLD:
- g_value_set_int (value, filter->threshold);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static gboolean
-gst_spectrum_start (GstBaseTransform * trans)
-{
- GstSpectrum *filter = GST_SPECTRUM (trans);
-
- filter->num_frames = 0;
- filter->num_fft = 0;
- if (filter->spect_magnitude)
- memset (filter->spect_magnitude, 0, filter->bands * sizeof (gfloat));
- if (filter->spect_phase)
- memset (filter->spect_phase, 0, filter->bands * sizeof (gfloat));
-
- return TRUE;
-}
-
-static gboolean
-gst_spectrum_stop (GstBaseTransform * trans)
-{
- GstSpectrum *filter = GST_SPECTRUM (trans);
-
- gst_adapter_clear (filter->adapter);
-
- return TRUE;
-}
-
-static gboolean
-gst_spectrum_event (GstBaseTransform * trans, GstEvent * event)
-{
- GstSpectrum *filter = GST_SPECTRUM (trans);
-
- switch (GST_EVENT_TYPE (event)) {
- case GST_EVENT_FLUSH_STOP:
- case GST_EVENT_EOS:
- gst_adapter_clear (filter->adapter);
- break;
- default:
- break;
- }
-
- return TRUE;
-}
-
-static gboolean
-gst_spectrum_setup (GstAudioFilter * base, GstRingBufferSpec * format)
-{
- GstSpectrum *filter = GST_SPECTRUM (base);
-
- if (filter->in) {
- g_free (filter->in);
- filter->in = NULL;
- }
-
- if (filter->fft_free_func) {
- filter->fft_free_func (filter->fft_ctx);
- filter->fft_ctx = NULL;
- filter->fft_free_func = NULL;
- }
-
- if (filter->freqdata) {
- g_free (filter->freqdata);
- filter->freqdata = NULL;
- }
-
- if (format->type == GST_BUFTYPE_LINEAR && format->width == 32)
- filter->process = (GstSpectrumProcessFunc) process_s32;
- else if (format->type == GST_BUFTYPE_LINEAR && format->width == 16)
- filter->process = (GstSpectrumProcessFunc) process_s16;
- else if (format->type == GST_BUFTYPE_FLOAT && format->width == 64)
- filter->process = (GstSpectrumProcessFunc) process_f64;
- else if (format->type == GST_BUFTYPE_FLOAT && format->width == 32)
- filter->process = (GstSpectrumProcessFunc) process_f32;
- else
- g_assert_not_reached ();
-
- return TRUE;
-}
-
-static GstMessage *
-gst_spectrum_message_new (GstSpectrum * spectrum, GstClockTime endtime)
-{
- GstStructure *s;
- GValue v = { 0, };
- GValue *l;
- guint i;
- gfloat *spect_magnitude = spectrum->spect_magnitude;
- gfloat *spect_phase = spectrum->spect_phase;
-
- GST_DEBUG_OBJECT (spectrum, "preparing message, spect = %p, bands =%d ",
- spect_magnitude, spectrum->bands);
-
- s = gst_structure_new ("spectrum", "endtime", GST_TYPE_CLOCK_TIME,
- endtime, NULL);
-
- if (spectrum->message_magnitude) {
- g_value_init (&v, GST_TYPE_LIST);
- /* will copy-by-value */
- gst_structure_set_value (s, "magnitude", &v);
- g_value_unset (&v);
-
- g_value_init (&v, G_TYPE_FLOAT);
- l = (GValue *) gst_structure_get_value (s, "magnitude");
- for (i = 0; i < spectrum->bands; i++) {
- g_value_set_float (&v, spect_magnitude[i]);
- gst_value_list_append_value (l, &v); /* copies by value */
- }
- g_value_unset (&v);
- }
-
- if (spectrum->message_phase) {
- g_value_init (&v, GST_TYPE_LIST);
- /* will copy-by-value */
- gst_structure_set_value (s, "phase", &v);
- g_value_unset (&v);
-
- g_value_init (&v, G_TYPE_FLOAT);
- l = (GValue *) gst_structure_get_value (s, "phase");
- for (i = 0; i < spectrum->bands; i++) {
- g_value_set_float (&v, spect_phase[i]);
- gst_value_list_append_value (l, &v); /* copies by value */
- }
- g_value_unset (&v);
- }
-
- return gst_message_new_element (GST_OBJECT (spectrum), s);
-}
-
-#define DEFINE_PROCESS_FUNC_INT(width,next_width,max) \
-static void \
-process_s##width (GstSpectrum *spectrum, const gint##width *samples) \
-{ \
- gfloat *spect_magnitude = spectrum->spect_magnitude; \
- gfloat *spect_phase = spectrum->spect_phase; \
- gint channels = GST_AUDIO_FILTER (spectrum)->format.channels; \
- gint i, j, k; \
- gint##next_width acc; \
- GstFFTS##width##Complex *freqdata; \
- GstFFTS##width *ctx; \
- gint##width *in; \
- gint nfft = 2 * spectrum->bands - 2; \
- \
- if (!spectrum->in) \
- spectrum->in = (guint8 *) g_new (gint##width, nfft); \
- \
- in = (gint##width *) spectrum->in; \
- \
- for (i = 0, j = 0; i < nfft; i++) { \
- /* convert to mono */ \
- for (k = 0, acc = 0; k < channels; k++) \
- acc += samples[j++]; \
- in[i] = (gint##width) (acc / channels); \
- } \
- \
- if (!spectrum->fft_ctx) { \
- spectrum->fft_ctx = gst_fft_s##width##_new (nfft, FALSE); \
- spectrum->fft_free_func = (GstSpectrumFFTFreeFunc) gst_fft_s##width##_free; \
- } \
- ctx = spectrum->fft_ctx; \
- \
- gst_fft_s##width##_window (ctx, in, GST_FFT_WINDOW_HAMMING); \
- \
- if (!spectrum->freqdata) \
- spectrum->freqdata = g_new (GstFFTS##width##Complex, spectrum->bands); \
- \
- freqdata = (GstFFTS##width##Complex *) spectrum->freqdata; \
- \
- gst_fft_s##width##_fft (ctx, in, freqdata); \
- spectrum->num_fft++; \
- \
- /* Calculate magnitude in db */ \
- for (i = 0; i < spectrum->bands; i++) { \
- gdouble val = 0.0; \
- val = (gdouble) freqdata[i].r * (gdouble) freqdata[i].r; \
- val += (gdouble) freqdata[i].i * (gdouble) freqdata[i].i; \
- val /= max*max; \
- val = 10.0 * log10 (val); \
- if (val < spectrum->threshold) \
- val = spectrum->threshold; \
- spect_magnitude[i] += val; \
- } \
- \
- /* Calculate phase */ \
- for (i = 0; i < spectrum->bands; i++) \
- spect_phase[i] += atan2 (freqdata[i].i, freqdata[i].r); \
- \
-}
-
-DEFINE_PROCESS_FUNC_INT (16, 32, 32767.0);
-DEFINE_PROCESS_FUNC_INT (32, 64, 2147483647.0);
-
-#define DEFINE_PROCESS_FUNC_FLOAT(width,type) \
-static void \
-process_f##width (GstSpectrum *spectrum, const g##type *samples) \
-{ \
- gfloat *spect_magnitude = spectrum->spect_magnitude; \
- gfloat *spect_phase = spectrum->spect_phase; \
- gint channels = GST_AUDIO_FILTER (spectrum)->format.channels; \
- gint i, j, k; \
- g##type acc; \
- GstFFTF##width##Complex *freqdata; \
- GstFFTF##width *ctx; \
- g##type *in; \
- gint nfft = 2 * spectrum->bands - 2; \
- \
- if (!spectrum->in) \
- spectrum->in = (guint8 *) g_new (g##type, nfft); \
- \
- in = (g##type *) spectrum->in; \
- \
- for (i = 0, j = 0; i < nfft; i++) { \
- /* convert to mono */ \
- for (k = 0, acc = 0; k < channels; k++) \
- acc += samples[j++]; \
- in[i] = (g##type) (acc / channels); \
- if (abs (in[i]) > 1.0) \
- g_assert_not_reached(); \
- } \
- \
- if (!spectrum->fft_ctx) { \
- spectrum->fft_ctx = gst_fft_f##width##_new (nfft, FALSE); \
- spectrum->fft_free_func = (GstSpectrumFFTFreeFunc) gst_fft_f##width##_free; \
- } \
- ctx = spectrum->fft_ctx; \
- \
- gst_fft_f##width##_window (ctx, in, GST_FFT_WINDOW_HAMMING); \
- \
- if (!spectrum->freqdata) \
- spectrum->freqdata = g_new (GstFFTF##width##Complex, spectrum->bands); \
- \
- freqdata = (GstFFTF##width##Complex *) spectrum->freqdata; \
- \
- gst_fft_f##width##_fft (ctx, in, freqdata); \
- spectrum->num_fft++; \
- \
- /* Calculate magnitude in db */ \
- for (i = 0; i < spectrum->bands; i++) { \
- gdouble val = 0.0; \
- val = freqdata[i].r * freqdata[i].r; \
- val += freqdata[i].i * freqdata[i].i; \
- val /= nfft*nfft; \
- val = 10.0 * log10 (val); \
- if (val < spectrum->threshold) \
- val = spectrum->threshold; \
- spect_magnitude[i] += val; \
- } \
- \
- /* Calculate phase */ \
- for (i = 0; i < spectrum->bands; i++) \
- spect_phase[i] += atan2 (freqdata[i].i, freqdata[i].r); \
- \
-}
-
-DEFINE_PROCESS_FUNC_FLOAT (32, float);
-DEFINE_PROCESS_FUNC_FLOAT (64, double);
-
-static GstFlowReturn
-gst_spectrum_transform_ip (GstBaseTransform * trans, GstBuffer * in)
-{
- GstSpectrum *spectrum = GST_SPECTRUM (trans);
- gint wanted;
- gint i;
- gfloat *spect_magnitude = spectrum->spect_magnitude;
- gfloat *spect_phase = spectrum->spect_phase;
- gint rate = GST_AUDIO_FILTER (spectrum)->format.rate;
- gint channels = GST_AUDIO_FILTER (spectrum)->format.channels;
- gint width = GST_AUDIO_FILTER (spectrum)->format.width / 8;
- gint nfft = 2 * spectrum->bands - 2;
-
- GstClockTime endtime =
- gst_segment_to_running_time (&trans->segment, GST_FORMAT_TIME,
- GST_BUFFER_TIMESTAMP (in));
- GstClockTime blktime = GST_FRAMES_TO_CLOCK_TIME (nfft, rate);
-
- GST_LOG_OBJECT (spectrum, "input size: %d bytes", GST_BUFFER_SIZE (in));
-
- /* can we do this nicer? */
- gst_adapter_push (spectrum->adapter, gst_buffer_copy (in));
- /* required number of bytes */
- wanted = channels * nfft * width;
-
- while (gst_adapter_available (spectrum->adapter) >= wanted) {
- const guint8 *samples;
-
- samples = gst_adapter_peek (spectrum->adapter, wanted);
-
- spectrum->process (spectrum, samples);
-
- spectrum->num_frames += nfft;
- endtime += blktime;
- /* do we need to message ? */
- if (spectrum->num_frames >=
- GST_CLOCK_TIME_TO_FRAMES (spectrum->interval, rate)) {
- if (spectrum->message) {
- GstMessage *m;
-
- /* Calculate average */
- for (i = 0; i < spectrum->bands; i++) {
- spect_magnitude[i] /= spectrum->num_fft;
- spect_phase[i] /= spectrum->num_fft;
- }
-
- m = gst_spectrum_message_new (spectrum, endtime);
-
- gst_element_post_message (GST_ELEMENT (spectrum), m);
- }
- memset (spect_magnitude, 0, spectrum->bands * sizeof (gfloat));
- memset (spect_phase, 0, spectrum->bands * sizeof (gfloat));
- spectrum->num_frames = 0;
- spectrum->num_fft = 0;
- }
-
- gst_adapter_flush (spectrum->adapter, wanted);
- }
-
- return GST_FLOW_OK;
-}
-
-static gboolean
-plugin_init (GstPlugin * plugin)
-{
- return gst_element_register (plugin, "spectrum", GST_RANK_NONE,
- GST_TYPE_SPECTRUM);
-}
-
-GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
- GST_VERSION_MINOR,
- "spectrum",
- "Run an FFT on the audio signal, output spectrum data",
- plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
diff --git a/gst/spectrum/gstspectrum.h b/gst/spectrum/gstspectrum.h
deleted file mode 100644
index 291b2ffc..00000000
--- a/gst/spectrum/gstspectrum.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* GStreamer
- * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
- *
- * 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-
-#ifndef __GST_SPECTRUM_H__
-#define __GST_SPECTRUM_H__
-
-
-#include <gst/gst.h>
-#include <gst/base/gstadapter.h>
-#include <gst/base/gstbasetransform.h>
-#include <gst/audio/gstaudiofilter.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-#define GST_TYPE_SPECTRUM (gst_spectrum_get_type())
-#define GST_SPECTRUM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SPECTRUM,GstSpectrum))
-#define GST_IS_SPECTRUM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SPECTRUM))
-#define GST_SPECTRUM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SPECTRUM,GstSpectrumClass))
-#define GST_IS_SPECTRUM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SPECTRUM))
-
-typedef struct _GstSpectrum GstSpectrum;
-typedef struct _GstSpectrumClass GstSpectrumClass;
-typedef void (*GstSpectrumProcessFunc) (GstSpectrum *, const guint8 *);
-typedef void (*GstSpectrumFFTFreeFunc) (void *);
-
-struct _GstSpectrum {
- GstAudioFilter element;
-
- GstPad *sinkpad,*srcpad;
- GstAdapter *adapter;
-
- /* properties */
- gboolean message; /* whether or not to post messages */
- gboolean message_magnitude;
- gboolean message_phase;
- guint64 interval; /* how many seconds between emits */
- guint bands; /* number of spectrum bands */
- gint threshold; /* energy level treshold */
-
- gint num_frames; /* frame count (1 sample per channel)
- * since last emit */
- gint num_fft; /* number of FFTs since last emit */
-
- /* <private> */
- gfloat *spect_magnitude;
- gfloat *spect_phase;
- GstSpectrumProcessFunc process;
- void *fft_ctx;
- GstSpectrumFFTFreeFunc fft_free_func;
- void *in;
- void *freqdata;
-};
-
-struct _GstSpectrumClass {
- GstAudioFilterClass parent_class;
-};
-
-GType gst_spectrum_get_type (void);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __GST_SPECTRUM_H__ */
diff --git a/gst/spectrum/spectrum.vcproj b/gst/spectrum/spectrum.vcproj
deleted file mode 100644
index 2946792b..00000000
--- a/gst/spectrum/spectrum.vcproj
+++ /dev/null
@@ -1,151 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioProject
- ProjectType="Visual C++"
- Version="7.10"
- Name="spectrum"
- ProjectGUID="{979C216F-0ACF-4956-AE00-055A42D678CC}"
- Keyword="Win32Proj">
- <Platforms>
- <Platform
- Name="Win32"/>
- </Platforms>
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- OutputDirectory="../../win32/Debug"
- IntermediateDirectory="../../win32/Debug"
- ConfigurationType="2"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- Optimization="0"
- AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;&quot;../../gst-libs&quot;;../../../popt/include;../../../libxml2/include/libxml2"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;spectrum_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
- MinimalRebuild="TRUE"
- BasicRuntimeChecks="3"
- RuntimeLibrary="3"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="4"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
- OutputFile="$(OutDir)/gstspectrum.dll"
- LinkIncremental="2"
- AdditionalLibraryDirectories="../../../gstreamer/win32/Debug;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
- ModuleDefinitionFile=""
- GenerateDebugInformation="TRUE"
- ProgramDatabaseFile="$(OutDir)/spectrum.pdb"
- SubSystem="2"
- OptimizeReferences="2"
- ImportLibrary="$(OutDir)/gstspectrum.lib"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- <Configuration
- Name="Release|Win32"
- OutputDirectory="../../win32/Release"
- IntermediateDirectory="../../win32/Release"
- ConfigurationType="2"
- CharacterSet="2">
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories="../../../gstreamer/win32;../../../gstreamer;../../../gstreamer/libs;../../../glib;../../../glib/glib;../../../glib/gmodule;&quot;../../gst-libs&quot;;../../../popt/include;../../../libxml2/include/libxml2"
- PreprocessorDefinitions="WIN32;NDEBUG;GST_DISABLE_GST_DEBUG;_WINDOWS;_USRDLL;spectrum_EXPORTS;HAVE_CONFIG_H;_USE_MATH_DEFINES"
- RuntimeLibrary="2"
- UsePrecompiledHeader="0"
- WarningLevel="3"
- Detect64BitPortabilityProblems="TRUE"
- DebugInformationFormat="3"/>
- <Tool
- Name="VCCustomBuildTool"/>
- <Tool
- Name="VCLinkerTool"
- AdditionalDependencies="glib-2.0.lib gmodule-2.0.lib gthread-2.0.lib gobject-2.0.lib libgstreamer.lib gstbytestream.lib iconv.lib intl.lib"
- OutputFile="$(OutDir)/gstspectrum.dll"
- LinkIncremental="1"
- AdditionalLibraryDirectories="../../../gstreamer/win32/Release;../../../glib/glib;../../../glib/gmodule;../../../glib/gthread;../../../glib/gobject;../../../gettext/lib;../../../libiconv/lib"
- ModuleDefinitionFile=""
- GenerateDebugInformation="TRUE"
- SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- ImportLibrary="$(OutDir)/gstspectrum.lib"
- TargetMachine="1"/>
- <Tool
- Name="VCMIDLTool"/>
- <Tool
- Name="VCPostBuildEventTool"
- CommandLine="copy /Y $(TargetPath) c:\gstreamer\plugins"/>
- <Tool
- Name="VCPreBuildEventTool"/>
- <Tool
- Name="VCPreLinkEventTool"/>
- <Tool
- Name="VCResourceCompilerTool"/>
- <Tool
- Name="VCWebServiceProxyGeneratorTool"/>
- <Tool
- Name="VCXMLDataGeneratorTool"/>
- <Tool
- Name="VCWebDeploymentTool"/>
- <Tool
- Name="VCManagedWrapperGeneratorTool"/>
- <Tool
- Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
- </Configuration>
- </Configurations>
- <References>
- </References>
- <Files>
- <Filter
- Name="Source Files"
- Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
- <File
- RelativePath=".\gstspectrum.c">
- </File>
- <File
- RelativePath=".\fix_fft.c">
- </File>
- </Filter>
- <Filter
- Name="Header Files"
- Filter="h;hpp;hxx;hm;inl;inc;xsd"
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
- <File
- RelativePath=".\gstspectrum.h">
- </File>
- </Filter>
- <Filter
- Name="Resource Files"
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
- </Filter>
- </Files>
- <Globals>
- </Globals>
-</VisualStudioProject>
diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index fba6e109..2eb774b6 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -72,8 +72,7 @@ check_PROGRAMS = \
elements/rganalysis \
elements/rglimiter \
elements/rgvolume \
- elements/y4menc \
- elements/spectrum
+ elements/y4menc
noinst_HEADERS =
diff --git a/tests/check/elements/spectrum.c b/tests/check/elements/spectrum.c
deleted file mode 100644
index 245b37bc..00000000
--- a/tests/check/elements/spectrum.c
+++ /dev/null
@@ -1,571 +0,0 @@
-/* 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
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <unistd.h>
-
-#include <gst/check/gstcheck.h>
-
-GList *buffers = NULL;
-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 \
- "audio/x-raw-int, " \
- " width = (int) 16, " \
- " depth = (int) 16, " \
- " signed = (boolean) true, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]; " \
- "audio/x-raw-int, " \
- " width = (int) 32, " \
- " depth = (int) 32, " \
- " signed = (boolean) true, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]; " \
- "audio/x-raw-float, " \
- " width = (int) { 32, 64 }, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) [ 1, MAX ], " \
- " channels = (int) [ 1, MAX ]"
-
-#define SPECT_CAPS_STRING_S16 \
- "audio/x-raw-int, " \
- "rate = (int) 44100, " \
- "channels = (int) 1, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (boolean) true"
-
-#define SPECT_CAPS_STRING_S32 \
- "audio/x-raw-int, " \
- "rate = (int) 44100, " \
- "channels = (int) 1, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 32, " \
- "depth = (int) 32, " \
- "signed = (boolean) true"
-
-#define SPECT_CAPS_STRING_F32 \
- "audio/x-raw-float, " \
- " width = (int) 32, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) 44100, " \
- " channels = (int) 1"
-
-#define SPECT_CAPS_STRING_F64 \
- "audio/x-raw-float, " \
- " width = (int) 64, " \
- " endianness = (int) BYTE_ORDER, " \
- " rate = (int) 44100, " \
- " channels = (int) 1"
-
-#define SPECT_BANDS 256
-
-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 */
-GstElement *
-setup_spectrum ()
-{
- GstElement *spectrum;
-
- GST_DEBUG ("setup_spectrum");
- spectrum = gst_check_setup_element ("spectrum");
- mysrcpad = gst_check_setup_src_pad (spectrum, &srctemplate, NULL);
- mysinkpad = gst_check_setup_sink_pad (spectrum, &sinktemplate, NULL);
- gst_pad_set_active (mysrcpad, TRUE);
- gst_pad_set_active (mysinkpad, TRUE);
-
- return spectrum;
-}
-
-void
-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);
-}
-
-
-GST_START_TEST (test_int16)
-{
- GstElement *spectrum;
- GstBuffer *inbuffer, *outbuffer;
- GstBus *bus;
- GstCaps *caps;
- GstMessage *message;
- const GstStructure *structure;
- int i, j;
- gint16 *data;
- const GValue *list, *value;
- GstClockTime endtime;
- gfloat level;
-
- spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
- "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 */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint16));
- data = (gint16 *) GST_BUFFER_DATA (inbuffer);
-
- for (j = 0; j < 44100; j += 4) {
- *data = 0;
- ++data;
- *data = 32767;
- ++data;
- *data = 0;
- ++data;
- *data = -32767;
- ++data;
- }
-
- caps = gst_caps_from_string (SPECT_CAPS_STRING_S16);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
- 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)
- && level < -20.0);
- fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
- && level > -20.0);
- }
- 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);
- gst_buffer_unref (outbuffer);
- 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;
- GstCaps *caps;
- GstMessage *message;
- const GstStructure *structure;
- int i, j;
- gint32 *data;
- const GValue *list, *value;
- GstClockTime endtime;
- gfloat level;
-
- spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
- "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 */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gint32));
- data = (gint32 *) GST_BUFFER_DATA (inbuffer);
- for (j = 0; j < 44100; j += 4) {
- *data = 0;
- ++data;
- *data = 2147483647;
- ++data;
- *data = 0;
- ++data;
- *data = -2147483647;
- ++data;
- }
- caps = gst_caps_from_string (SPECT_CAPS_STRING_S32);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
- 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)
- && level < -20.0);
- fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
- && level > -20.0);
- }
- 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);
- gst_buffer_unref (outbuffer);
- 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;
- GstCaps *caps;
- GstMessage *message;
- const GstStructure *structure;
- int i, j;
- gfloat *data;
- const GValue *list, *value;
- GstClockTime endtime;
- gfloat level;
-
- spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
- "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 */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gfloat));
- data = (gfloat *) GST_BUFFER_DATA (inbuffer);
- for (j = 0; j < 44100; j += 4) {
- *data = 0.0;
- ++data;
- *data = 1.0;
- ++data;
- *data = 0.0;
- ++data;
- *data = -1.0;
- ++data;
- }
- caps = gst_caps_from_string (SPECT_CAPS_STRING_F32);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
- 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)
- && level < -20.0);
- fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
- && level > -20.0);
- }
- 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);
- gst_buffer_unref (outbuffer);
- 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;
- GstCaps *caps;
- GstMessage *message;
- const GstStructure *structure;
- int i, j;
- gdouble *data;
- const GValue *list, *value;
- GstClockTime endtime;
- gfloat level;
-
- spectrum = setup_spectrum ();
- g_object_set (spectrum, "message", TRUE, "interval", GST_SECOND / 100,
- "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 */
- inbuffer = gst_buffer_new_and_alloc (44100 * sizeof (gdouble));
- data = (gdouble *) GST_BUFFER_DATA (inbuffer);
- for (j = 0; j < 44100; j += 4) {
- *data = 0.0;
- ++data;
- *data = 1.0;
- ++data;
- *data = 0.0;
- ++data;
- *data = -1.0;
- ++data;
- }
- caps = gst_caps_from_string (SPECT_CAPS_STRING_F64);
- gst_buffer_set_caps (inbuffer, caps);
- gst_caps_unref (caps);
- 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)
- && level < -20.0);
- fail_if ((i != SPECT_BANDS / 2 && i != SPECT_BANDS / 2 - 1)
- && level > -20.0);
- }
- 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);
- gst_buffer_unref (outbuffer);
- 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;
-
-
-Suite *
-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);
- tcase_add_test (tc_chain, test_int32);
- tcase_add_test (tc_chain, test_float32);
- tcase_add_test (tc_chain, test_float64);
-
- return s;
-}
-
-int
-main (int argc, char **argv)
-{
- int nf;
-
- Suite *s = spectrum_suite ();
- 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;
-}