diff options
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | docs/plugins/Makefile.am | 4 | ||||
-rw-r--r-- | docs/plugins/gst-plugins-bad-plugins-docs.sgml | 5 | ||||
-rw-r--r-- | docs/plugins/gst-plugins-bad-plugins-sections.txt | 56 | ||||
-rw-r--r-- | docs/plugins/inspect/plugin-equalizer.xml | 76 | ||||
-rw-r--r-- | gst/equalizer/.gitignore | 1 | ||||
-rw-r--r-- | gst/equalizer/Makefile.am | 22 | ||||
-rw-r--r-- | gst/equalizer/demo.c | 247 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer.c | 660 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer.h | 75 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer10bands.c | 230 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer10bands.h | 51 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer3bands.c | 152 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizer3bands.h | 51 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizernbands.c | 183 | ||||
-rw-r--r-- | gst/equalizer/gstiirequalizernbands.h | 52 | ||||
-rw-r--r-- | tests/check/Makefile.am | 1 | ||||
-rw-r--r-- | tests/check/elements/.gitignore | 3 | ||||
-rw-r--r-- | tests/check/elements/equalizer.c | 331 |
20 files changed, 25 insertions, 2203 deletions
@@ -1,6 +1,30 @@ 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/inspect/plugin-equalizer.xml: + * gst/equalizer/.cvsignore: + * gst/equalizer/Makefile.am: + * gst/equalizer/demo.c: + * gst/equalizer/gstiirequalizer.c: + * gst/equalizer/gstiirequalizer.h: + * gst/equalizer/gstiirequalizer10bands.c: + * gst/equalizer/gstiirequalizer10bands.h: + * gst/equalizer/gstiirequalizer3bands.c: + * gst/equalizer/gstiirequalizer3bands.h: + * gst/equalizer/gstiirequalizernbands.c: + * gst/equalizer/gstiirequalizernbands.h: + * tests/check/Makefile.am: + * tests/check/elements/.cvsignore: + * tests/check/elements/equalizer.c: + + Remove the equalizer plugin, which has moved to -good + +2008-02-08 Jan Schmidt <jan.schmidt@sun.com> + + * configure.ac: Make DISABLE_DEPRECATED defined *only* during CVS, not during pre-releases or releases. diff --git a/configure.ac b/configure.ac index 70757550..f30421c4 100644 --- a/configure.ac +++ b/configure.ac @@ -44,7 +44,7 @@ dnl AS_LIBTOOL_TAGS([CXX]) AM_PROG_LIBTOOL dnl *** required versions of GStreamer stuff *** -dnl *** remove rtpmanager/equalizer stuff below when this is updated +dnl *** remove rtpmanager stuff below when this is updated GST_REQ=0.10.17 GSTPB_REQ=0.10.17 @@ -84,7 +84,6 @@ GST_PLUGINS_ALL="\ cdxaparse \ deinterlace \ dvdspu \ - equalizer \ festival \ filter \ flv \ @@ -1045,7 +1044,6 @@ gst/bayer/Makefile gst/cdxaparse/Makefile gst/deinterlace/Makefile gst/dvdspu/Makefile -gst/equalizer/Makefile gst/festival/Makefile gst/filter/Makefile gst/flv/Makefile diff --git a/docs/plugins/Makefile.am b/docs/plugins/Makefile.am index 6d5ee8e6..d899af20 100644 --- a/docs/plugins/Makefile.am +++ b/docs/plugins/Makefile.am @@ -113,10 +113,6 @@ EXTRA_HFILES = \ $(top_srcdir)/ext/timidity/gsttimidity.h \ $(top_srcdir)/ext/timidity/gstwildmidi.h \ $(top_srcdir)/gst/dvdspu/gstdvdspu.h \ - $(top_srcdir)/gst/equalizer/gstiirequalizer.h \ - $(top_srcdir)/gst/equalizer/gstiirequalizer3bands.h \ - $(top_srcdir)/gst/equalizer/gstiirequalizer10bands.h \ - $(top_srcdir)/gst/equalizer/gstiirequalizernbands.h \ $(top_srcdir)/gst/festival/gstfestival.h \ $(top_srcdir)/gst/modplug/gstmodplug.h \ $(top_srcdir)/gst/multifile/gstmultifilesink.h \ diff --git a/docs/plugins/gst-plugins-bad-plugins-docs.sgml b/docs/plugins/gst-plugins-bad-plugins-docs.sgml index b200125f..087f02b4 100644 --- a/docs/plugins/gst-plugins-bad-plugins-docs.sgml +++ b/docs/plugins/gst-plugins-bad-plugins-docs.sgml @@ -20,9 +20,6 @@ <xi:include href="xml/element-dfbvideosink.xml" /> <xi:include href="xml/element-dvbsrc.xml" /> <xi:include href="xml/element-dvdspu.xml" /> - <xi:include href="xml/element-equalizer-10bands.xml" /> - <xi:include href="xml/element-equalizer-3bands.xml" /> - <xi:include href="xml/element-equalizer-nbands.xml" /> <xi:include href="xml/element-festival.xml" /> <xi:include href="xml/element-giosink.xml" /> <xi:include href="xml/element-giosrc.xml" /> @@ -79,7 +76,6 @@ <xi:include href="xml/plugin-dvbsrc.xml" /> <xi:include href="xml/plugin-dvb.xml" /> <xi:include href="xml/plugin-dvdspu.xml" /> - <xi:include href="xml/plugin-equalizer.xml" /> <xi:include href="xml/plugin-faac.xml" /> <xi:include href="xml/plugin-faad.xml" /> <xi:include href="xml/plugin-fbdevsink.xml" /> @@ -144,6 +140,5 @@ <chapter> <title>gst-plugins-bad Classes</title> <xi:include href="xml/gstbasemetadata.xml" /> - <xi:include href="xml/gstiirequalizer.xml" /> </chapter> </book> diff --git a/docs/plugins/gst-plugins-bad-plugins-sections.txt b/docs/plugins/gst-plugins-bad-plugins-sections.txt index c90598dc..c0910d0c 100644 --- a/docs/plugins/gst-plugins-bad-plugins-sections.txt +++ b/docs/plugins/gst-plugins-bad-plugins-sections.txt @@ -137,62 +137,6 @@ SPU_STATE_FLAGS_MASK </SECTION> <SECTION> -<FILE>gstiirequalizer</FILE> -<TITLE>GstIirEqualize</TITLE> -GstIirEqualizer -<SUBSECTION Standard> -GstIirEqualizerClass -GST_IIR_EQUALIZER -GST_IIR_EQUALIZER_CLASS -GST_IS_IIR_EQUALIZER -GST_IS_IIR_EQUALIZER_CLASS -GST_TYPE_IIR_EQUALIZER -gst_iir_equalizer_get_type -</SECTION> - -<SECTION> -<FILE>element-equalizer-3bands</FILE> -<TITLE>equalizer-3bands</TITLE> -GstIirEqualizer3Bands -<SUBSECTION Standard> -GstIirEqualizer3BandsClass -GST_IIR_EQUALIZER_3BANDS -GST_IIR_EQUALIZER_3BANDS_CLASS -GST_IS_IIR_EQUALIZER_3BANDS -GST_IS_IIR_EQUALIZER_3BANDS_CLASS -GST_TYPE_IIR_EQUALIZER_3BANDS -gst_iir_equalizer_3bands_get_type -</SECTION> - -<SECTION> -<FILE>element-equalizer-10bands</FILE> -<TITLE>equalizer-10bands</TITLE> -GstIirEqualizer10Bands -<SUBSECTION Standard> -GstIirEqualizer10BandsClass -GST_IIR_EQUALIZER_10BANDS -GST_IIR_EQUALIZER_10BANDS_CLASS -GST_IS_IIR_EQUALIZER_10BANDS -GST_IS_IIR_EQUALIZER_10BANDS_CLASS -GST_TYPE_IIR_EQUALIZER_10BANDS -gst_iir_equalizer_10bands_get_type -</SECTION> - -<SECTION> -<FILE>element-equalizer-nbands</FILE> -<TITLE>equalizer-nbands</TITLE> -GstIirEqualizerNBands -<SUBSECTION Standard> -GstIirEqualizerNBandsClass -GST_IIR_EQUALIZER_NBANDS -GST_IIR_EQUALIZER_NBANDS_CLASS -GST_IS_IIR_EQUALIZER_NBANDS -GST_IS_IIR_EQUALIZER_NBANDS_CLASS -GST_TYPE_IIR_EQUALIZER_NBANDS -gst_iir_equalizer_nbands_get_type -</SECTION> - -<SECTION> <FILE>element-festival</FILE> <TITLE>festival</TITLE> GstFestival diff --git a/docs/plugins/inspect/plugin-equalizer.xml b/docs/plugins/inspect/plugin-equalizer.xml deleted file mode 100644 index f95a1f06..00000000 --- a/docs/plugins/inspect/plugin-equalizer.xml +++ /dev/null @@ -1,76 +0,0 @@ -<plugin> - <name>equalizer</name> - <description>GStreamer audio equalizers</description> - <filename>../../gst/equalizer/.libs/libgstequalizer.so</filename> - <basename>libgstequalizer.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>equalizer-10bands</name> - <longname>10 Band Equalizer</longname> - <class>Filter/Effect/Audio</class> - <description>Direct Form 10 band IIR equalizer</description> - <author>Stefan Kost <ensonic@users.sf.net></author> - <pads> - <caps> - <name>sink</name> - <direction>sink</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - <caps> - <name>src</name> - <direction>source</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - </pads> - </element> - <element> - <name>equalizer-3bands</name> - <longname>3 Band Equalizer</longname> - <class>Filter/Effect/Audio</class> - <description>Direct Form 3 band IIR equalizer</description> - <author>Stefan Kost <ensonic@users.sf.net></author> - <pads> - <caps> - <name>sink</name> - <direction>sink</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - <caps> - <name>src</name> - <direction>source</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - </pads> - </element> - <element> - <name>equalizer-nbands</name> - <longname>N Band Equalizer</longname> - <class>Filter/Effect/Audio</class> - <description>Direct Form IIR equalizer</description> - <author>Benjamin Otte <otte@gnome.org>, Stefan Kost <ensonic@users.sf.net></author> - <pads> - <caps> - <name>sink</name> - <direction>sink</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - <caps> - <name>src</name> - <direction>source</direction> - <presence>always</presence> - <details>audio/x-raw-int, depth=(int)16, width=(int)16, endianness=(int)1234, signed=(boolean)true, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]; audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1000, 2147483647 ], channels=(int)[ 1, 2147483647 ]</details> - </caps> - </pads> - </element> - </elements> -</plugin>
\ No newline at end of file diff --git a/gst/equalizer/.gitignore b/gst/equalizer/.gitignore deleted file mode 100644 index 1549b67c..00000000 --- a/gst/equalizer/.gitignore +++ /dev/null @@ -1 +0,0 @@ -demo diff --git a/gst/equalizer/Makefile.am b/gst/equalizer/Makefile.am deleted file mode 100644 index ceb6877d..00000000 --- a/gst/equalizer/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -plugin_LTLIBRARIES = libgstequalizer.la - -libgstequalizer_la_SOURCES = \ - gstiirequalizer.c gstiirequalizer.h \ - gstiirequalizernbands.c gstiirequalizernbands.h \ - gstiirequalizer3bands.c gstiirequalizer3bands.h \ - gstiirequalizer10bands.c gstiirequalizer10bands.h - -libgstequalizer_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CONTROLLER_CFLAGS) -libgstequalizer_la_LIBADD = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(GST_CONTROLLER_LIBS) $(LIBM) -libgstequalizer_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) - -noinst_HEADERS = gstiirequalizer.h - -if HAVE_GTK -noinst_PROGRAMS = demo -endif - -demo_SOURCES = demo.c -demo_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS) -demo_LDFLAGS = $(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS) - diff --git a/gst/equalizer/demo.c b/gst/equalizer/demo.c deleted file mode 100644 index 43518463..00000000 --- a/gst/equalizer/demo.c +++ /dev/null @@ -1,247 +0,0 @@ -#include <stdlib.h> -#include <string.h> -#include <math.h> -#include <gst/gst.h> -#include <gtk/gtk.h> - -#define NBANDS 10 - -static GtkWidget *drawingarea = NULL; -static guint spect_height = 128; -static guint spect_bands = 256; -static gfloat height_scale = 2.0; - -static void -on_window_destroy (GtkObject * object, gpointer user_data) -{ - drawingarea = NULL; - gtk_main_quit (); -} - -static 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; -} - -/* control gains */ -static void -on_gain_changed (GtkRange * range, gpointer user_data) -{ - GstObject *band = GST_OBJECT (user_data); - gdouble value = gtk_range_get_value (range); - - g_object_set (band, "gain", value, NULL); -} - -/* control bandwidths */ -static void -on_bandwidth_changed (GtkRange * range, gpointer user_data) -{ - GstObject *band = GST_OBJECT (user_data); - gdouble value = gtk_range_get_value (range); - - g_object_set (band, "bandwidth", value, NULL); -} - -/* control frequency */ -static void -on_freq_changed (GtkRange * range, gpointer user_data) -{ - GstObject *band = GST_OBJECT (user_data); - gdouble value = gtk_range_get_value (range); - - /* hbox */ - GtkWidget *parent = gtk_widget_get_parent (GTK_WIDGET (range)); - - /* frame */ - GtkWidget *parent_parent = gtk_widget_get_parent (parent); - gchar *label = g_strdup_printf ("%d Hz", (int) (value + 0.5)); - - gtk_frame_set_label (GTK_FRAME (parent_parent), label); - g_free (label); - - g_object_set (band, "freq", value, NULL); -} - -/* 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, *capsfilter, *equalizer, *spectrum, *audioconvert, *sink; - GstCaps *caps; - GstBus *bus; - GtkWidget *appwindow, *vbox, *hbox, *widget; - - gst_init (&argc, &argv); - gtk_init (&argc, &argv); - - bin = gst_pipeline_new ("bin"); - - /* White noise */ - src = gst_element_factory_make ("audiotestsrc", "src"); - g_object_set (G_OBJECT (src), "wave", 5, "volume", 0.8, NULL); - - /* Force float32 samples */ - capsfilter = gst_element_factory_make ("capsfilter", "capsfilter"); - caps = - gst_caps_new_simple ("audio/x-raw-float", "width", G_TYPE_INT, 32, NULL); - g_object_set (capsfilter, "caps", caps, NULL); - - equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer"); - g_object_set (G_OBJECT (equalizer), "num-bands", NBANDS, NULL); - - spectrum = gst_element_factory_make ("spectrum", "spectrum"); - g_object_set (G_OBJECT (spectrum), "bands", spect_bands, "threshold", -80, - "message", TRUE, "interval", 500 * GST_MSECOND, NULL); - - audioconvert = gst_element_factory_make ("audioconvert", "audioconvert"); - - sink = gst_element_factory_make ("autoaudiosink", "sink"); - - gst_bin_add_many (GST_BIN (bin), src, capsfilter, equalizer, spectrum, - audioconvert, sink, NULL); - if (!gst_element_link_many (src, capsfilter, equalizer, 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); - - 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); - - hbox = gtk_hbox_new (FALSE, 20); - - int i; - - for (i = 0; i < NBANDS; i++) { - GstObject *band; - gdouble freq; - gdouble bw; - gdouble gain; - gchar *label; - GtkWidget *frame, *scales_hbox; - - band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - g_assert (band != NULL); - g_object_get (G_OBJECT (band), "freq", &freq, NULL); - g_object_get (G_OBJECT (band), "bandwidth", &bw, NULL); - g_object_get (G_OBJECT (band), "gain", &gain, NULL); - - label = g_strdup_printf ("%d Hz", (int) (freq + 0.5)); - frame = gtk_frame_new (label); - g_free (label); - - scales_hbox = gtk_hbox_new (FALSE, 6); - - widget = gtk_vscale_new_with_range (-24.0, 12.0, 0.5); - 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), gain); - gtk_widget_set_size_request (widget, 25, 150); - g_signal_connect (G_OBJECT (widget), "value-changed", - G_CALLBACK (on_gain_changed), (gpointer) band); - gtk_box_pack_start (GTK_BOX (scales_hbox), widget, FALSE, FALSE, 0); - - widget = gtk_vscale_new_with_range (0.0, 20000.0, 5.0); - 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), bw); - gtk_widget_set_size_request (widget, 25, 150); - g_signal_connect (G_OBJECT (widget), "value-changed", - G_CALLBACK (on_bandwidth_changed), (gpointer) band); - gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0); - - widget = gtk_vscale_new_with_range (20.0, 20000.0, 5.0); - 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), freq); - gtk_widget_set_size_request (widget, 25, 150); - g_signal_connect (G_OBJECT (widget), "value-changed", - G_CALLBACK (on_freq_changed), (gpointer) band); - gtk_box_pack_start (GTK_BOX (scales_hbox), widget, TRUE, TRUE, 0); - - gtk_container_add (GTK_CONTAINER (frame), scales_hbox); - - gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); - } - - gtk_box_pack_start (GTK_BOX (vbox), hbox, 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/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c deleted file mode 100644 index 684e8843..00000000 --- a/gst/equalizer/gstiirequalizer.c +++ /dev/null @@ -1,660 +0,0 @@ -/* GStreamer - * Copyright (C) <2004> Benjamin Otte <otte@gnome.org> - * <2007> 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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <math.h> -#include <string.h> - -#include "gstiirequalizer.h" -#include "gstiirequalizernbands.h" -#include "gstiirequalizer3bands.h" -#include "gstiirequalizer10bands.h" - -GST_DEBUG_CATEGORY (equalizer_debug); -#define GST_CAT_DEFAULT equalizer_debug - -static void gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface, - gpointer iface_data); - -static void gst_iir_equalizer_finalize (GObject * object); - -static gboolean gst_iir_equalizer_setup (GstAudioFilter * filter, - GstRingBufferSpec * fmt); -static GstFlowReturn gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, - GstBuffer * buf); - -GST_DEBUG_CATEGORY_EXTERN (equalizer_debug); -#define GST_CAT_DEFAULT equalizer_debug - -#define ALLOWED_CAPS \ - "audio/x-raw-int," \ - " depth=(int)16," \ - " width=(int)16," \ - " endianness=(int)BYTE_ORDER," \ - " signed=(bool)TRUE," \ - " rate=(int)[1000,MAX]," \ - " channels=(int)[1,MAX]; " \ - "audio/x-raw-float," \ - " width=(int) { 32, 64 } ," \ - " endianness=(int)BYTE_ORDER," \ - " rate=(int)[1000,MAX]," \ - " channels=(int)[1,MAX]" - -static void -_do_init (GType object_type) -{ - const GInterfaceInfo child_proxy_interface_info = { - (GInterfaceInitFunc) gst_iir_equalizer_child_proxy_interface_init, - NULL, /* interface_finalize */ - NULL /* interface_data */ - }; - - g_type_add_interface_static (object_type, GST_TYPE_CHILD_PROXY, - &child_proxy_interface_info); -} - -GST_BOILERPLATE_FULL (GstIirEqualizer, gst_iir_equalizer, - GstAudioFilter, GST_TYPE_AUDIO_FILTER, _do_init); - -/* child object */ - -enum -{ - ARG_GAIN = 1, - ARG_FREQ, - ARG_BANDWIDTH -}; - -typedef struct _GstIirEqualizerBandClass GstIirEqualizerBandClass; - -#define GST_TYPE_IIR_EQUALIZER_BAND \ - (gst_iir_equalizer_band_get_type()) -#define GST_IIR_EQUALIZER_BAND(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_BAND,GstIirEqualizerBand)) -#define GST_IIR_EQUALIZER_BAND_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_BAND,GstIirEqualizerBandClass)) -#define GST_IS_IIR_EQUALIZER_BAND(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_BAND)) -#define GST_IS_IIR_EQUALIZER_BAND_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_BAND)) - -struct _GstIirEqualizerBand -{ - GstObject object; - - /*< private > */ - /* center frequency and gain */ - gdouble freq; - gdouble gain; - gdouble width; - - /* second order iir filter */ - gdouble b1, b2; /* IIR coefficients for outputs */ - gdouble a0, a1, a2; /* IIR coefficients for inputs */ -}; - -struct _GstIirEqualizerBandClass -{ - GstObjectClass parent_class; -}; - -static GType gst_iir_equalizer_band_get_type (void); -static void setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band); - -static void -gst_iir_equalizer_band_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstIirEqualizerBand *band = GST_IIR_EQUALIZER_BAND (object); - - switch (prop_id) { - case ARG_GAIN:{ - gdouble gain; - - gain = g_value_get_double (value); - GST_DEBUG_OBJECT (band, "gain = %lf -> %lf", band->gain, gain); - if (gain != band->gain) { - GstIirEqualizer *equ = - GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band))); - - band->gain = gain; - if (GST_AUDIO_FILTER (equ)->format.rate) { - setup_filter (equ, band); - } - gst_object_unref (equ); - GST_DEBUG_OBJECT (band, "changed gain = %lf ", band->gain); - } - break; - } - case ARG_FREQ:{ - gdouble freq; - - freq = g_value_get_double (value); - GST_DEBUG_OBJECT (band, "freq = %lf -> %lf", band->freq, freq); - if (freq != band->freq) { - GstIirEqualizer *equ = - GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band))); - - band->freq = freq; - if (GST_AUDIO_FILTER (equ)->format.rate) { - setup_filter (equ, band); - } - gst_object_unref (equ); - GST_DEBUG_OBJECT (band, "changed freq = %lf ", band->freq); - } - break; - } - case ARG_BANDWIDTH:{ - gdouble width; - - width = g_value_get_double (value); - GST_DEBUG_OBJECT (band, "width = %lf -> %lf", band->width, width); - if (width != band->width) { - GstIirEqualizer *equ = - GST_IIR_EQUALIZER (gst_object_get_parent (GST_OBJECT (band))); - - band->width = width; - if (GST_AUDIO_FILTER (equ)->format.rate) { - setup_filter (equ, band); - } - gst_object_unref (equ); - GST_DEBUG_OBJECT (band, "changed width = %lf ", band->width); - } - break; - } - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_iir_equalizer_band_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstIirEqualizerBand *band = GST_IIR_EQUALIZER_BAND (object); - - switch (prop_id) { - case ARG_GAIN: - g_value_set_double (value, band->gain); - break; - case ARG_FREQ: - g_value_set_double (value, band->freq); - break; - case ARG_BANDWIDTH: - g_value_set_double (value, band->width); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_iir_equalizer_band_class_init (GstIirEqualizerBandClass * klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->set_property = gst_iir_equalizer_band_set_property; - gobject_class->get_property = gst_iir_equalizer_band_get_property; - - g_object_class_install_property (gobject_class, ARG_GAIN, - g_param_spec_double ("gain", "gain", - "gain for the frequency band ranging from -24.0 dB to +12.0 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - - g_object_class_install_property (gobject_class, ARG_FREQ, - g_param_spec_double ("freq", "freq", - "center frequency of the band", - 0.0, 100000.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - - g_object_class_install_property (gobject_class, ARG_BANDWIDTH, - g_param_spec_double ("bandwidth", "bandwidth", - "difference between bandedges in Hz", - 0.0, 100000.0, 1.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); -} - -static void -gst_iir_equalizer_band_init (GstIirEqualizerBand * band, - GstIirEqualizerBandClass * klass) -{ - band->freq = 0.0; - band->gain = 0.0; - band->width = 1.0; -} - -static GType -gst_iir_equalizer_band_get_type (void) -{ - static GType type = 0; - - if (G_UNLIKELY (!type)) { - const GTypeInfo type_info = { - sizeof (GstIirEqualizerBandClass), - NULL, - NULL, - (GClassInitFunc) gst_iir_equalizer_band_class_init, - NULL, - NULL, - sizeof (GstIirEqualizerBand), - 0, - (GInstanceInitFunc) gst_iir_equalizer_band_init, - }; - type = - g_type_register_static (GST_TYPE_OBJECT, "GstIirEqualizerBand", - &type_info, 0); - } - return (type); -} - - -/* child proxy iface */ -static GstObject * -gst_iir_equalizer_child_proxy_get_child_by_index (GstChildProxy * child_proxy, - guint index) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (child_proxy); - - g_return_val_if_fail (index < equ->freq_band_count, NULL); - - GST_LOG ("return child[%d] '%s'", index, GST_OBJECT_NAME (equ->bands[index])); - return (gst_object_ref (equ->bands[index])); -} - -static guint -gst_iir_equalizer_child_proxy_get_children_count (GstChildProxy * child_proxy) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (child_proxy); - - GST_LOG ("we have %d children", equ->freq_band_count); - return (equ->freq_band_count); -} - -static void -gst_iir_equalizer_child_proxy_interface_init (gpointer g_iface, - gpointer iface_data) -{ - GstChildProxyInterface *iface = g_iface; - - GST_DEBUG ("initializing iface"); - - iface->get_child_by_index = gst_iir_equalizer_child_proxy_get_child_by_index; - iface->get_children_count = gst_iir_equalizer_child_proxy_get_children_count; -} - - -/* equalizer implementation */ - -static void -gst_iir_equalizer_base_init (gpointer g_class) -{ - GstAudioFilterClass *audiofilter_class = GST_AUDIO_FILTER_CLASS (g_class); - GstCaps *caps; - - caps = gst_caps_from_string (ALLOWED_CAPS); - gst_audio_filter_class_add_pad_templates (audiofilter_class, caps); - gst_caps_unref (caps); -} - -static void -gst_iir_equalizer_class_init (GstIirEqualizerClass * klass) -{ - GstAudioFilterClass *audio_filter_class = (GstAudioFilterClass *) klass; - GstBaseTransformClass *btrans_class = (GstBaseTransformClass *) klass; - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->finalize = gst_iir_equalizer_finalize; - - audio_filter_class->setup = gst_iir_equalizer_setup; - btrans_class->transform_ip = gst_iir_equalizer_transform_ip; -} - -static void -gst_iir_equalizer_init (GstIirEqualizer * eq, GstIirEqualizerClass * g_class) -{ - /* nothing to do here */ -} - -static void -gst_iir_equalizer_finalize (GObject * object) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - gint i; - - for (i = 0; i < equ->freq_band_count; i++) { - if (equ->bands[i]) - gst_object_unparent (GST_OBJECT (equ->bands[i])); - equ->bands[i] = NULL; - } - equ->freq_band_count = 0; - - g_free (equ->bands); - g_free (equ->history); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static inline gdouble -arg_to_scale (gdouble arg) -{ - return (pow (10.0, arg / 20.0)); -} - -/* Filter taken from - * - * The Equivalence of Various Methods of Computing - * Biquad Coefficients for Audio Parametric Equalizers - * - * by Robert Bristow-Johnson - * - * http://www.aes.org/e-lib/browse.cfm?elib=6326 - * http://www.musicdsp.org/files/EQ-Coefficients.pdf - * - * The bandwidth method that we use here is the preferred - * one from this article transformed from octaves to frequency - * in Hz. - */ -static void -setup_filter (GstIirEqualizer * equ, GstIirEqualizerBand * band) -{ - g_return_if_fail (GST_AUDIO_FILTER (equ)->format.rate); - - /* FIXME: we need better filters - * - we need shelf-filter for 1st and last band - */ - { - gdouble gain, omega, bw; - gdouble edge_gain, gamma; - gdouble alpha, beta; - - - gain = arg_to_scale (band->gain); - - if (band->freq / GST_AUDIO_FILTER (equ)->format.rate > 0.5) - omega = M_PI; - else if (band->freq < 0.0) - omega = 0.0; - else - omega = 2.0 * M_PI * (band->freq / GST_AUDIO_FILTER (equ)->format.rate); - - if (band->width / GST_AUDIO_FILTER (equ)->format.rate >= 0.5) { - /* If bandwidth == 0.5 the calculation below fails as tan(M_PI/2) - * is undefined. So set the bandwidth to a slightly smaller value. - */ - bw = M_PI - 0.00000001; - } else if (band->width <= 0.0) { - /* If bandwidth == 0 this band won't change anything so set - * the coefficients accordingly. The coefficient calculation - * below would create coefficients that for some reason amplify - * the band. - */ - band->a0 = 1.0; - band->a1 = 0.0; - band->a2 = 0.0; - band->b1 = 0.0; - band->b2 = 0.0; - goto out; - } else { - bw = 2.0 * M_PI * (band->width / GST_AUDIO_FILTER (equ)->format.rate); - } - - edge_gain = sqrt (gain); - gamma = tan (bw / 2.0); - - alpha = gamma * edge_gain; - beta = gamma / edge_gain; - - band->a0 = (1.0 + alpha) / (1.0 + beta); - band->a1 = (-2.0 * cos (omega)) / (1.0 + beta); - band->a2 = (1.0 - alpha) / (1.0 + beta); - band->b1 = (2.0 * cos (omega)) / (1.0 + beta); - band->b2 = -(1.0 - beta) / (1.0 + beta); - - out: - GST_INFO - ("gain = %7.5g, , bandwidth= %7.5g, frequency = %7.5g, a0 = %7.5g, a1 = %7.5g, a2=%7.5g b1 = %7.5g, b2 = %7.5g", - band->gain, band->width, band->freq, band->a0, band->a1, band->a2, - band->b1, band->b2); - } -} - -void -gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count) -{ - guint old_count, i; - gdouble freq0, freq1, step; - gchar name[20]; - - old_count = equ->freq_band_count; - equ->freq_band_count = new_count; - GST_DEBUG ("bands %u -> %u", old_count, new_count); - - if (old_count < new_count) { - /* add new bands */ - equ->bands = g_realloc (equ->bands, sizeof (GstObject *) * new_count); - for (i = old_count; i < new_count; i++) { - equ->bands[i] = g_object_new (GST_TYPE_IIR_EQUALIZER_BAND, NULL); - /* otherwise they get names like 'iirequalizerband5' */ - sprintf (name, "band%u", i); - gst_object_set_name (GST_OBJECT (equ->bands[i]), name); - - gst_object_set_parent (GST_OBJECT (equ->bands[i]), GST_OBJECT (equ)); - gst_child_proxy_child_added (GST_OBJECT (equ), - GST_OBJECT (equ->bands[i])); - } - } else { - /* free unused bands */ - for (i = new_count; i < old_count; i++) { - GST_DEBUG ("removing band[%d]=%p", i, equ->bands[i]); - gst_child_proxy_child_removed (GST_OBJECT (equ), - GST_OBJECT (equ->bands[i])); - gst_object_unparent (GST_OBJECT (equ->bands[i])); - equ->bands[i] = NULL; - } - } - - /* free + alloc = no memcpy */ - g_free (equ->history); - equ->history = - g_malloc0 (equ->history_size * GST_AUDIO_FILTER (equ)->format.channels * - new_count); - - /* set center frequencies and name band objects - * FIXME: arg! we can't change the name of parented objects :( - * application should read band->freq to get the name - */ - - step = pow (HIGHEST_FREQ / LOWEST_FREQ, 1.0 / new_count); - freq0 = LOWEST_FREQ; - for (i = 0; i < new_count; i++) { - freq1 = freq0 * step; - equ->bands[i]->freq = freq0 + ((freq1 - freq0) / 2.0); - equ->bands[i]->width = freq1 - freq0; - GST_DEBUG ("band[%2d] = '%lf'", i, equ->bands[i]->freq); - /* - if(equ->bands[i]->freq<10000.0) - sprintf (name,"%dHz",(gint)equ->bands[i]->freq); - else - sprintf (name,"%dkHz",(gint)(equ->bands[i]->freq/1000.0)); - gst_object_set_name( GST_OBJECT (equ->bands[i]), name); - GST_DEBUG ("band[%2d] = '%s'",i,name); - */ - freq0 = freq1; - } - - - if (GST_AUDIO_FILTER (equ)->format.rate) { - for (i = 0; i < new_count; i++) { - setup_filter (equ, equ->bands[i]); - } - } -} - -/* start of code that is type specific */ - -#define CREATE_OPTIMIZED_FUNCTIONS(TYPE,BIG_TYPE,MIN_VAL,MAX_VAL) \ -typedef struct { \ - TYPE x1, x2; /* history of input values for a filter */ \ - TYPE y1, y2; /* history of output values for a filter */ \ -} SecondOrderHistory ## TYPE; \ - \ -static inline TYPE \ -one_step_ ## TYPE (GstIirEqualizerBand *filter, \ - SecondOrderHistory ## TYPE *history, TYPE input) \ -{ \ - /* calculate output */ \ - TYPE output = filter->a0 * input + filter->a1 * history->x1 + \ - filter->a2 * history->x2 + filter->b1 * history->y1 + \ - filter->b2 * history->y2; \ - /* update history */ \ - history->y2 = history->y1; \ - history->y1 = output; \ - history->x2 = history->x1; \ - history->x1 = input; \ - \ - return output; \ -} \ - \ -static const guint \ -history_size_ ## TYPE = sizeof (SecondOrderHistory ## TYPE); \ - \ -static void \ -gst_iir_equ_process_ ## TYPE (GstIirEqualizer *equ, guint8 *data, \ -guint size, guint channels) \ -{ \ - guint frames = size / channels / sizeof (TYPE); \ - guint i, c, f; \ - BIG_TYPE cur; \ - \ - for (i = 0; i < frames; i++) { \ - for (c = 0; c < channels; c++) { \ - SecondOrderHistory ## TYPE *history = equ->history; \ - cur = *((TYPE *) data); \ - for (f = 0; f < equ->freq_band_count; f++) { \ - GstIirEqualizerBand *filter = equ->bands[f]; \ - \ - cur = one_step_ ## TYPE (filter, history, cur); \ - history++; \ - } \ - cur = CLAMP (cur, MIN_VAL, MAX_VAL); \ - *((TYPE *) data) = (TYPE) cur; \ - data += sizeof (TYPE); \ - } \ - } \ -} - -CREATE_OPTIMIZED_FUNCTIONS (gint16, gint, -32768, 32767); -CREATE_OPTIMIZED_FUNCTIONS (gfloat, gfloat, -1.0, 1.0); -CREATE_OPTIMIZED_FUNCTIONS (gdouble, gdouble, -1.0, 1.0); - -static GstFlowReturn -gst_iir_equalizer_transform_ip (GstBaseTransform * btrans, GstBuffer * buf) -{ - GstAudioFilter *filter = GST_AUDIO_FILTER (btrans); - GstIirEqualizer *equ = GST_IIR_EQUALIZER (btrans); - GstClockTime timestamp; - - if (gst_base_transform_is_passthrough (btrans)) - return GST_FLOW_OK; - - if (G_UNLIKELY (filter->format.channels < 1 || equ->process == NULL)) - return GST_FLOW_NOT_NEGOTIATED; - - timestamp = GST_BUFFER_TIMESTAMP (buf); - timestamp = - gst_segment_to_stream_time (&btrans->segment, GST_FORMAT_TIME, timestamp); - - if (GST_CLOCK_TIME_IS_VALID (timestamp)) - gst_object_sync_values (G_OBJECT (equ), timestamp); - - equ->process (equ, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf), - filter->format.channels); - - return GST_FLOW_OK; -} - -static gboolean -gst_iir_equalizer_setup (GstAudioFilter * audio, GstRingBufferSpec * fmt) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (audio); - - switch (fmt->type) { - case GST_BUFTYPE_LINEAR: - switch (fmt->width) { - case 16: - equ->history_size = history_size_gint16; - equ->process = gst_iir_equ_process_gint16; - break; - default: - return FALSE; - } - break; - case GST_BUFTYPE_FLOAT: - switch (fmt->width) { - case 32: - equ->history_size = history_size_gfloat; - equ->process = gst_iir_equ_process_gfloat; - break; - case 64: - equ->history_size = history_size_gdouble; - equ->process = gst_iir_equ_process_gdouble; - break; - default: - return FALSE; - } - break; - default: - return FALSE; - } - - gst_iir_equalizer_compute_frequencies (equ, equ->freq_band_count); - return TRUE; -} - - -static gboolean -plugin_init (GstPlugin * plugin) -{ - GST_DEBUG_CATEGORY_INIT (equalizer_debug, "equalizer", 0, "equalizer"); - - if (!(gst_element_register (plugin, "equalizer-nbands", GST_RANK_NONE, - GST_TYPE_IIR_EQUALIZER_NBANDS))) - return FALSE; - - if (!(gst_element_register (plugin, "equalizer-3bands", GST_RANK_NONE, - GST_TYPE_IIR_EQUALIZER_3BANDS))) - return FALSE; - - if (!(gst_element_register (plugin, "equalizer-10bands", GST_RANK_NONE, - GST_TYPE_IIR_EQUALIZER_10BANDS))) - return FALSE; - - return TRUE; -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - "equalizer", - "GStreamer audio equalizers", - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/gst/equalizer/gstiirequalizer.h b/gst/equalizer/gstiirequalizer.h deleted file mode 100644 index 6e7839a3..00000000 --- a/gst/equalizer/gstiirequalizer.h +++ /dev/null @@ -1,75 +0,0 @@ -/* GStreamer IIR equalizer - * Copyright (C) <2004> Benjamin Otte <otte@gnome.org> - * <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. - */ - -#ifndef __GST_IIR_EQUALIZER__ -#define __GST_IIR_EQUALIZER__ - -#include <gst/audio/gstaudiofilter.h> -#include <gst/audio/gstringbuffer.h> -#include <gst/controller/gstcontroller.h> - -typedef struct _GstIirEqualizer GstIirEqualizer; -typedef struct _GstIirEqualizerClass GstIirEqualizerClass; -typedef struct _GstIirEqualizerBand GstIirEqualizerBand; - -#define GST_TYPE_IIR_EQUALIZER \ - (gst_iir_equalizer_get_type()) -#define GST_IIR_EQUALIZER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER,GstIirEqualizer)) -#define GST_IIR_EQUALIZER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER,GstIirEqualizerClass)) -#define GST_IS_IIR_EQUALIZER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER)) -#define GST_IS_IIR_EQUALIZER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER)) - -#define LOWEST_FREQ (20.0) -#define HIGHEST_FREQ (20000.0) - -typedef void (*ProcessFunc) (GstIirEqualizer * eq, guint8 * data, guint size, - guint channels); - -struct _GstIirEqualizer -{ - GstAudioFilter audiofilter; - - /*< private >*/ - - GstIirEqualizerBand **bands; - - /* properties */ - guint freq_band_count; - /* for each band and channel */ - gpointer history; - guint history_size; - - ProcessFunc process; -}; - -struct _GstIirEqualizerClass -{ - GstAudioFilterClass audiofilter_class; -}; - -extern void gst_iir_equalizer_compute_frequencies (GstIirEqualizer * equ, guint new_count); - -extern GType gst_iir_equalizer_get_type(void); - -#endif /* __GST_IIR_EQUALIZER__ */ diff --git a/gst/equalizer/gstiirequalizer10bands.c b/gst/equalizer/gstiirequalizer10bands.c deleted file mode 100644 index e951077d..00000000 --- a/gst/equalizer/gstiirequalizer10bands.c +++ /dev/null @@ -1,230 +0,0 @@ -/* GStreamer - * 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. - */ - -/** - * SECTION:element-equalizer-10bands - * @short_description: 10-band equalizer - * - * <refsect2> - * <para> - * The 10 band equalizer element allows to change the gain of 10 equally distributed - * frequency bands between 30 Hz and 15 kHz. - * </para> - * <title>Example launch line</title> - * <para> - * <programlisting> - * gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-10bands band2=3.0 ! alsasink - * </programlisting> - * This raises the volume of the 3rd band which is at 119 Hz by 3 db. - * </para> - * </refsect2> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstiirequalizer.h" -#include "gstiirequalizer10bands.h" - - -enum -{ - ARG_BAND0 = 1, - ARG_BAND1, - ARG_BAND2, - ARG_BAND3, - ARG_BAND4, - ARG_BAND5, - ARG_BAND6, - ARG_BAND7, - ARG_BAND8, - ARG_BAND9, -}; - -static void gst_iir_equalizer_10bands_set_property (GObject * object, - guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_iir_equalizer_10bands_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec); - -GST_DEBUG_CATEGORY_EXTERN (equalizer_debug); -#define GST_CAT_DEFAULT equalizer_debug - -GST_BOILERPLATE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands, - GstIirEqualizer, GST_TYPE_IIR_EQUALIZER); - -/* equalizer implementation */ - -static void -gst_iir_equalizer_10bands_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - const GstElementDetails iir_equalizer_details = - GST_ELEMENT_DETAILS ("10 Band Equalizer", - "Filter/Effect/Audio", - "Direct Form 10 band IIR equalizer", - "Stefan Kost <ensonic@users.sf.net>"); - - gst_element_class_set_details (element_class, &iir_equalizer_details); -} - -static void -gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->set_property = gst_iir_equalizer_10bands_set_property; - gobject_class->get_property = gst_iir_equalizer_10bands_get_property; - - g_object_class_install_property (gobject_class, ARG_BAND0, - g_param_spec_double ("band0", "29 Hz", - "gain for the frequency band 29 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND1, - g_param_spec_double ("band1", "59 Hz", - "gain for the frequency band 59 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND2, - g_param_spec_double ("band2", "119 Hz", - "gain for the frequency band 119 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND3, - g_param_spec_double ("band3", "227 Hz", - "gain for the frequency band 227 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND4, - g_param_spec_double ("band4", "474 Hz", - "gain for the frequency band 474 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND5, - g_param_spec_double ("band5", "947 Hz", - "gain for the frequency band 947 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND6, - g_param_spec_double ("band6", "1889 Hz", - "gain for the frequency band 1889 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND7, - g_param_spec_double ("band7", "3770 Hz", - "gain for the frequency band 3770 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND8, - g_param_spec_double ("band8", "7523 Hz", - "gain for the frequency band 7523 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND9, - g_param_spec_double ("band9", "15011 Hz", - "gain for the frequency band 15011 Hz, ranging from -24 dB to +12 dB", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); -} - -static void -gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n, - GstIirEqualizer10BandsClass * g_class) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n); - - gst_iir_equalizer_compute_frequencies (equ, 10); -} - -static void -gst_iir_equalizer_10bands_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - switch (prop_id) { - case ARG_BAND0: - gst_child_proxy_set_property (GST_OBJECT (equ), "band0::gain", value); - break; - case ARG_BAND1: - gst_child_proxy_set_property (GST_OBJECT (equ), "band1::gain", value); - break; - case ARG_BAND2: - gst_child_proxy_set_property (GST_OBJECT (equ), "band2::gain", value); - break; - case ARG_BAND3: - gst_child_proxy_set_property (GST_OBJECT (equ), "band3::gain", value); - break; - case ARG_BAND4: - gst_child_proxy_set_property (GST_OBJECT (equ), "band4::gain", value); - break; - case ARG_BAND5: - gst_child_proxy_set_property (GST_OBJECT (equ), "band5::gain", value); - break; - case ARG_BAND6: - gst_child_proxy_set_property (GST_OBJECT (equ), "band6::gain", value); - break; - case ARG_BAND7: - gst_child_proxy_set_property (GST_OBJECT (equ), "band7::gain", value); - break; - case ARG_BAND8: - gst_child_proxy_set_property (GST_OBJECT (equ), "band8::gain", value); - break; - case ARG_BAND9: - gst_child_proxy_set_property (GST_OBJECT (equ), "band9::gain", value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_iir_equalizer_10bands_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - switch (prop_id) { - case ARG_BAND0: - gst_child_proxy_get_property (GST_OBJECT (equ), "band0::gain", value); - break; - case ARG_BAND1: - gst_child_proxy_get_property (GST_OBJECT (equ), "band1::gain", value); - break; - case ARG_BAND2: - gst_child_proxy_get_property (GST_OBJECT (equ), "band2::gain", value); - break; - case ARG_BAND3: - gst_child_proxy_get_property (GST_OBJECT (equ), "band3::gain", value); - break; - case ARG_BAND4: - gst_child_proxy_get_property (GST_OBJECT (equ), "band4::gain", value); - break; - case ARG_BAND5: - gst_child_proxy_get_property (GST_OBJECT (equ), "band5::gain", value); - break; - case ARG_BAND6: - gst_child_proxy_get_property (GST_OBJECT (equ), "band6::gain", value); - break; - case ARG_BAND7: - gst_child_proxy_get_property (GST_OBJECT (equ), "band7::gain", value); - break; - case ARG_BAND8: - gst_child_proxy_get_property (GST_OBJECT (equ), "band8::gain", value); - break; - case ARG_BAND9: - gst_child_proxy_get_property (GST_OBJECT (equ), "band9::gain", value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} diff --git a/gst/equalizer/gstiirequalizer10bands.h b/gst/equalizer/gstiirequalizer10bands.h deleted file mode 100644 index 96bed280..00000000 --- a/gst/equalizer/gstiirequalizer10bands.h +++ /dev/null @@ -1,51 +0,0 @@ -/* GStreamer - * 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. - */ - -#ifndef __GST_IIR_EQUALIZER_10BANDS__ -#define __GST_IIR_EQUALIZER_10BANDS__ - -#include "gstiirequalizer.h" - -typedef struct _GstIirEqualizer10Bands GstIirEqualizer10Bands; -typedef struct _GstIirEqualizer10BandsClass GstIirEqualizer10BandsClass; - -#define GST_TYPE_IIR_EQUALIZER_10BANDS \ - (gst_iir_equalizer_10bands_get_type()) -#define GST_IIR_EQUALIZER_10BANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_10BANDS,GstIirEqualizer10Bands)) -#define GST_IIR_EQUALIZER_10BANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_10BANDS,GstIirEqualizer10BandsClass)) -#define GST_IS_IIR_EQUALIZER_10BANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_10BANDS)) -#define GST_IS_IIR_EQUALIZER_10BANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_10BANDS)) - -struct _GstIirEqualizer10Bands -{ - GstIirEqualizer equalizer; -}; - -struct _GstIirEqualizer10BandsClass -{ - GstIirEqualizer equalizer_class; -}; - -extern GType gst_iir_equalizer_10bands_get_type(void); - -#endif /* __GST_IIR_EQUALIZER_10BANDS__ */ diff --git a/gst/equalizer/gstiirequalizer3bands.c b/gst/equalizer/gstiirequalizer3bands.c deleted file mode 100644 index f1e11d50..00000000 --- a/gst/equalizer/gstiirequalizer3bands.c +++ /dev/null @@ -1,152 +0,0 @@ -/* GStreamer - * 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. - */ - -/** - * SECTION:element-equalizer-3bands - * @short_description: 3-band equalizer - * - * <refsect2> - * <para> - * The 3-band equalizer element allows to change the gain of a low frequency, - * medium frequency and high frequency band. - * </para> - * <title>Example launch line</title> - * <para> - * <programlisting> - * gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-3bands band1=6.0 ! alsasink - * </programlisting> - * This raises the volume of the 2nd band, which is at 1110 Hz, by 6 db. - * </para> - * </refsect2> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstiirequalizer.h" -#include "gstiirequalizer3bands.h" - -enum -{ - ARG_BAND0 = 1, - ARG_BAND1, - ARG_BAND2, -}; - -static void gst_iir_equalizer_3bands_set_property (GObject * object, - guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_iir_equalizer_3bands_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec); - -GST_DEBUG_CATEGORY_EXTERN (equalizer_debug); -#define GST_CAT_DEFAULT equalizer_debug - -GST_BOILERPLATE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands, - GstIirEqualizer, GST_TYPE_IIR_EQUALIZER); - -/* equalizer implementation */ - -static void -gst_iir_equalizer_3bands_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - const GstElementDetails iir_equalizer_details = - GST_ELEMENT_DETAILS ("3 Band Equalizer", - "Filter/Effect/Audio", - "Direct Form 3 band IIR equalizer", - "Stefan Kost <ensonic@users.sf.net>"); - - gst_element_class_set_details (element_class, &iir_equalizer_details); -} - -static void -gst_iir_equalizer_3bands_class_init (GstIirEqualizer3BandsClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->set_property = gst_iir_equalizer_3bands_set_property; - gobject_class->get_property = gst_iir_equalizer_3bands_get_property; - - g_object_class_install_property (gobject_class, ARG_BAND0, - g_param_spec_double ("band0", "110 Hz", - "gain for the frequency band 100 Hz, ranging from -24.0 to +12.0", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND1, - g_param_spec_double ("band1", "1100 Hz", - "gain for the frequency band 1100 Hz, ranging from -24.0 to +12.0", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); - g_object_class_install_property (gobject_class, ARG_BAND2, - g_param_spec_double ("band2", "11 kHz", - "gain for the frequency band 11 kHz, ranging from -24.0 to +12.0", - -24.0, 12.0, 0.0, G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE)); -} - -static void -gst_iir_equalizer_3bands_init (GstIirEqualizer3Bands * equ_n, - GstIirEqualizer3BandsClass * g_class) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n); - - gst_iir_equalizer_compute_frequencies (equ, 3); -} - -static void -gst_iir_equalizer_3bands_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - switch (prop_id) { - case ARG_BAND0: - gst_child_proxy_set_property (GST_OBJECT (equ), "band0::gain", value); - break; - case ARG_BAND1: - gst_child_proxy_set_property (GST_OBJECT (equ), "band1::gain", value); - break; - case ARG_BAND2: - gst_child_proxy_set_property (GST_OBJECT (equ), "band2::gain", value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gst_iir_equalizer_3bands_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - switch (prop_id) { - case ARG_BAND0: - gst_child_proxy_get_property (GST_OBJECT (equ), "band0::gain", value); - break; - case ARG_BAND1: - gst_child_proxy_get_property (GST_OBJECT (equ), "band1::gain", value); - break; - case ARG_BAND2: - gst_child_proxy_get_property (GST_OBJECT (equ), "band2::gain", value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} diff --git a/gst/equalizer/gstiirequalizer3bands.h b/gst/equalizer/gstiirequalizer3bands.h deleted file mode 100644 index e167f52d..00000000 --- a/gst/equalizer/gstiirequalizer3bands.h +++ /dev/null @@ -1,51 +0,0 @@ -/* GStreamer - * 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. - */ - -#ifndef __GST_IIR_EQUALIZER_3BANDS__ -#define __GST_IIR_EQUALIZER_3BANDS__ - -#include "gstiirequalizer.h" - -typedef struct _GstIirEqualizer3Bands GstIirEqualizer3Bands; -typedef struct _GstIirEqualizer3BandsClass GstIirEqualizer3BandsClass; - -#define GST_TYPE_IIR_EQUALIZER_3BANDS \ - (gst_iir_equalizer_3bands_get_type()) -#define GST_IIR_EQUALIZER_3BANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_3BANDS,GstIirEqualizer3Bands)) -#define GST_IIR_EQUALIZER_3BANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_3BANDS,GstIirEqualizer3BandsClass)) -#define GST_IS_IIR_EQUALIZER_3BANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_3BANDS)) -#define GST_IS_IIR_EQUALIZER_3BANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_3BANDS)) - -struct _GstIirEqualizer3Bands -{ - GstIirEqualizer equalizer; -}; - -struct _GstIirEqualizer3BandsClass -{ - GstIirEqualizer equalizer_class; -}; - -extern GType gst_iir_equalizer_3bands_get_type(void); - -#endif /* __GST_IIR_EQUALIZER_3BANDS__ */ diff --git a/gst/equalizer/gstiirequalizernbands.c b/gst/equalizer/gstiirequalizernbands.c deleted file mode 100644 index 316cd029..00000000 --- a/gst/equalizer/gstiirequalizernbands.c +++ /dev/null @@ -1,183 +0,0 @@ -/* GStreamer - * Copyright (C) <2004> Benjamin Otte <otte@gnome.org> - * <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. - */ - -/** - * SECTION:element-equalizer-nbands - * @short_description: Fully parametric N-band equalizer - * - * <refsect2> - * <para> - * The n-band equalizer element is a fully parametric equalizer. It allows to - * select between 1 and 64 bands and has properties on each band to change - * the center frequency, band width and gain. - * </para> - * <title>Example launch line</title> - * <para> - * <programlisting> - * gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-nbands num-bands=15 band5::gain=6.0 ! alsasink - * </programlisting> - * This make the equalizer use 15 bands and raises the volume of the 5th band by 6 db. - * </para> - * <title>Example code</title> - * <para> - * <programlisting> - -#include <gst/gst.h> - -... -typedef struct { - gfloat freq; - gfloat width; - gfloat gain; -} GstEqualizerBandState; - -... - - GstElement *equalizer; - GstObject *band; - gint i; - GstEqualizerBandState state[] = { - { 120.0, 50.0, - 3.0}, - { 500.0, 20.0, 12.0}, - {1503.0, 2.0, -20.0}, - {6000.0, 1000.0, 6.0}, - {3000.0, 120.0, 2.0} - }; - -... - - - equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer"); - g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL); - -... - - for (i = 0; i < 5; i++) { - band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - g_object_set (G_OBJECT (band), "freq", state[i].freq, - "bandwidth", state[i].width, - "gain", state[i].gain); - g_object_unref (G_OBJECT (band)); - } - -... - - * </programlisting> - * </para> - * </refsect2> - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "gstiirequalizer.h" -#include "gstiirequalizernbands.h" - - -enum -{ - ARG_NUM_BANDS = 1 -}; - -static void gst_iir_equalizer_nbands_set_property (GObject * object, - guint prop_id, const GValue * value, GParamSpec * pspec); -static void gst_iir_equalizer_nbands_get_property (GObject * object, - guint prop_id, GValue * value, GParamSpec * pspec); - -GST_DEBUG_CATEGORY_EXTERN (equalizer_debug); -#define GST_CAT_DEFAULT equalizer_debug - -GST_BOILERPLATE (GstIirEqualizerNBands, gst_iir_equalizer_nbands, - GstIirEqualizer, GST_TYPE_IIR_EQUALIZER); - -/* equalizer implementation */ - -static void -gst_iir_equalizer_nbands_base_init (gpointer g_class) -{ - GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - const GstElementDetails iir_equalizer_details = - GST_ELEMENT_DETAILS ("N Band Equalizer", - "Filter/Effect/Audio", - "Direct Form IIR equalizer", - "Benjamin Otte <otte@gnome.org>," " Stefan Kost <ensonic@users.sf.net>"); - - gst_element_class_set_details (element_class, &iir_equalizer_details); -} - -static void -gst_iir_equalizer_nbands_class_init (GstIirEqualizerNBandsClass * klass) -{ - GObjectClass *gobject_class = (GObjectClass *) klass; - - gobject_class->set_property = gst_iir_equalizer_nbands_set_property; - gobject_class->get_property = gst_iir_equalizer_nbands_get_property; - - g_object_class_install_property (gobject_class, ARG_NUM_BANDS, - g_param_spec_uint ("num-bands", "num-bands", - "number of different bands to use", 1, 64, 10, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); -} - -static void -gst_iir_equalizer_nbands_init (GstIirEqualizerNBands * equ_n, - GstIirEqualizerNBandsClass * g_class) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n); - - gst_iir_equalizer_compute_frequencies (equ, 10); -} - -static void -gst_iir_equalizer_nbands_set_property (GObject * object, guint prop_id, - const GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - GST_BASE_TRANSFORM_LOCK (equ); - GST_OBJECT_LOCK (equ); - switch (prop_id) { - case ARG_NUM_BANDS: - gst_iir_equalizer_compute_frequencies (equ, g_value_get_uint (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } - GST_OBJECT_UNLOCK (equ); - GST_BASE_TRANSFORM_UNLOCK (equ); -} - -static void -gst_iir_equalizer_nbands_get_property (GObject * object, guint prop_id, - GValue * value, GParamSpec * pspec) -{ - GstIirEqualizer *equ = GST_IIR_EQUALIZER (object); - - switch (prop_id) { - case ARG_NUM_BANDS: - g_value_set_uint (value, equ->freq_band_count); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} diff --git a/gst/equalizer/gstiirequalizernbands.h b/gst/equalizer/gstiirequalizernbands.h deleted file mode 100644 index c523f90f..00000000 --- a/gst/equalizer/gstiirequalizernbands.h +++ /dev/null @@ -1,52 +0,0 @@ -/* GStreamer - * Copyright (C) <2004> Benjamin Otte <otte@gnome.org> - * <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. - */ - -#ifndef __GST_IIR_EQUALIZER_NBANDS__ -#define __GST_IIR_EQUALIZER_NBANDS__ - -#include "gstiirequalizer.h" - -typedef struct _GstIirEqualizerNBands GstIirEqualizerNBands; -typedef struct _GstIirEqualizerNBandsClass GstIirEqualizerNBandsClass; - -#define GST_TYPE_IIR_EQUALIZER_NBANDS \ - (gst_iir_equalizer_nbands_get_type()) -#define GST_IIR_EQUALIZER_NBANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER_NBANDS,GstIirEqualizerNBands)) -#define GST_IIR_EQUALIZER_NBANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER_NBANDS,GstIirEqualizerNBandsClass)) -#define GST_IS_IIR_EQUALIZER_NBANDS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER_NBANDS)) -#define GST_IS_IIR_EQUALIZER_NBANDS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER_NBANDS)) - -struct _GstIirEqualizerNBands -{ - GstIirEqualizer equalizer; -}; - -struct _GstIirEqualizerNBandsClass -{ - GstIirEqualizer equalizer_class; -}; - -extern GType gst_iir_equalizer_nbands_get_type(void); - -#endif /* __GST_IIR_EQUALIZER_NBANDS__ */ diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index c4db624c..fefbc854 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -67,7 +67,6 @@ check_PROGRAMS = \ $(check_neon) \ $(check_soup) \ $(check_timidity) \ - elements/equalizer \ elements/interleave \ elements/multifile \ elements/rganalysis \ diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 67933fff..3ec9ac29 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -1,11 +1,8 @@ .dirstamp -bpwsinc deinterleave -equalizer gdpdepay gdppay interleave -lpwsinc mpeg2enc neonhttpsrc souphttpsrc diff --git a/tests/check/elements/equalizer.c b/tests/check/elements/equalizer.c deleted file mode 100644 index 1563f4b4..00000000 --- a/tests/check/elements/equalizer.c +++ /dev/null @@ -1,331 +0,0 @@ -/* GStreamer - * - * Copyright (C) 2008 Sebastian Dröge <slomo@circular-chaos.org> - * - * equalizer.c: Unit test for the equalizer element - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public License - * as published by the Free Software Foundation; either version 2.1 of - * the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA - * 02110-1301 USA - */ - -#include <gst/gst.h> -#include <gst/base/gstbasetransform.h> -#include <gst/check/gstcheck.h> - -#include <math.h> - -/* For ease of programming we use globals to keep refs for our floating - * src and sink pads we create; otherwise we always have to do get_pad, - * get_peer, and then remove references in every test function */ -GstPad *mysrcpad, *mysinkpad; - -#define EQUALIZER_CAPS_STRING \ - "audio/x-raw-float, " \ - "channels = (int) 1, " \ - "rate = (int) 48000, " \ - "endianness = (int) BYTE_ORDER, " \ - "width = (int) 64" \ - -static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "channels = (int) 1, " - "rate = (int) 48000, " - "endianness = (int) BYTE_ORDER, " "width = (int) 64 ") - ); -static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "channels = (int) 1, " - "rate = (int) 48000, " - "endianness = (int) BYTE_ORDER, " "width = (int) 64 ") - ); - -GstElement * -setup_equalizer () -{ - GstElement *equalizer; - - GST_DEBUG ("setup_equalizer"); - equalizer = gst_check_setup_element ("equalizer-nbands"); - mysrcpad = gst_check_setup_src_pad (equalizer, &srctemplate, NULL); - mysinkpad = gst_check_setup_sink_pad (equalizer, &sinktemplate, NULL); - gst_pad_set_active (mysrcpad, TRUE); - gst_pad_set_active (mysinkpad, TRUE); - - return equalizer; -} - -void -cleanup_equalizer (GstElement * equalizer) -{ - GST_DEBUG ("cleanup_equalizer"); - - g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL); - g_list_free (buffers); - buffers = NULL; - - gst_pad_set_active (mysrcpad, FALSE); - gst_pad_set_active (mysinkpad, FALSE); - gst_check_teardown_src_pad (equalizer); - gst_check_teardown_sink_pad (equalizer); - gst_check_teardown_element (equalizer); -} - -GST_START_TEST (test_equalizer_5bands_passthrough) -{ - GstElement *equalizer; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble *in, *res; - gint i; - - equalizer = setup_equalizer (); - g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL); - - fail_unless_equals_int (gst_child_proxy_get_children_count (GST_CHILD_PROXY - (equalizer)), 5); - - fail_unless (gst_element_set_state (equalizer, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); - for (i = 0; i < 1024; i++) - in[i] = g_random_double_range (-1.0, 1.0); - - caps = gst_caps_from_string (EQUALIZER_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ())); - /* ... and puts a new buffer on the global list */ - fail_unless (g_list_length (buffers) == 1); - - res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data)); - - for (i = 0; i < 1024; i++) - fail_unless_equals_float (in[i], res[i]); - - /* cleanup */ - cleanup_equalizer (equalizer); -} - -GST_END_TEST; - -GST_START_TEST (test_equalizer_5bands_minus_24) -{ - GstElement *equalizer; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble *in, *res, rms_in, rms_out; - gint i; - - equalizer = setup_equalizer (); - g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL); - - fail_unless_equals_int (gst_child_proxy_get_children_count (GST_CHILD_PROXY - (equalizer)), 5); - - for (i = 0; i < 5; i++) { - GstObject *band = - gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - fail_unless (band != NULL); - - g_object_set (G_OBJECT (band), "gain", -24.0, 0); - g_object_unref (G_OBJECT (band)); - } - - fail_unless (gst_element_set_state (equalizer, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); - for (i = 0; i < 1024; i++) - in[i] = g_random_double_range (-1.0, 1.0); - - rms_in = 0.0; - for (i = 0; i < 1024; i++) - rms_in += in[i] * in[i]; - rms_in = sqrt (rms_in / 1024); - - caps = gst_caps_from_string (EQUALIZER_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ())); - /* ... and puts a new buffer on the global list */ - fail_unless (g_list_length (buffers) == 1); - - res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data)); - - rms_out = 0.0; - for (i = 0; i < 1024; i++) - rms_out += res[i] * res[i]; - rms_out = sqrt (rms_out / 1024); - - fail_unless (rms_in > rms_out); - - /* cleanup */ - cleanup_equalizer (equalizer); -} - -GST_END_TEST; - -GST_START_TEST (test_equalizer_5bands_plus_12) -{ - GstElement *equalizer; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble *in, *res, rms_in, rms_out; - gint i; - - equalizer = setup_equalizer (); - g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL); - - fail_unless_equals_int (gst_child_proxy_get_children_count (GST_CHILD_PROXY - (equalizer)), 5); - - for (i = 0; i < 5; i++) { - GstObject *band = - gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - fail_unless (band != NULL); - - g_object_set (G_OBJECT (band), "gain", 12.0, 0); - g_object_unref (G_OBJECT (band)); - } - - fail_unless (gst_element_set_state (equalizer, - GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, - "could not set to playing"); - - inbuffer = gst_buffer_new_and_alloc (1024 * sizeof (gdouble)); - in = (gdouble *) GST_BUFFER_DATA (inbuffer); - for (i = 0; i < 1024; i++) - in[i] = g_random_double_range (-1.0, 1.0); - - rms_in = 0.0; - for (i = 0; i < 1024; i++) - rms_in += in[i] * in[i]; - rms_in = sqrt (rms_in / 1024); - - caps = gst_caps_from_string (EQUALIZER_CAPS_STRING); - gst_buffer_set_caps (inbuffer, caps); - gst_caps_unref (caps); - ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1); - - /* pushing gives away my reference ... */ - fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK); - fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_eos ())); - /* ... and puts a new buffer on the global list */ - fail_unless (g_list_length (buffers) == 1); - - res = (gdouble *) GST_BUFFER_DATA (GST_BUFFER (buffers->data)); - - rms_out = 0.0; - for (i = 0; i < 1024; i++) - rms_out += res[i] * res[i]; - rms_out = sqrt (rms_out / 1024); - - fail_unless (rms_in < rms_out); - - /* cleanup */ - cleanup_equalizer (equalizer); -} - -GST_END_TEST; - -GST_START_TEST (test_equalizer_band_number_changing) -{ - GstElement *equalizer; - GstBuffer *inbuffer, *outbuffer; - GstCaps *caps; - gdouble *in, *res; - gint i; - - equalizer = setup_equalizer (); - - g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL); - fail_unless_equals_int (gst_child_proxy_get_children_count (GST_CHILD_PROXY - (equalizer)), 5); - - for (i = 0; i < 5; i++) { - GstObject *band; - gdouble freq; - - band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - fail_unless (band != NULL); - gst_object_unref (band); - } - - g_object_set (G_OBJECT (equalizer), "num-bands", 10, NULL); - fail_unless_equals_int (gst_child_proxy_get_children_count (GST_CHILD_PROXY - (equalizer)), 10); - - for (i = 0; i < 10; i++) { - GstObject *band; - - band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i); - fail_unless (band != NULL); - gst_object_unref (band); - } - - /* cleanup */ - cleanup_equalizer (equalizer); -} - -GST_END_TEST; - -Suite * -equalizer_suite (void) -{ - Suite *s = suite_create ("equalizer"); - TCase *tc_chain = tcase_create ("general"); - - suite_add_tcase (s, tc_chain); - tcase_add_test (tc_chain, test_equalizer_5bands_passthrough); - tcase_add_test (tc_chain, test_equalizer_5bands_minus_24); - tcase_add_test (tc_chain, test_equalizer_5bands_plus_12); - tcase_add_test (tc_chain, test_equalizer_band_number_changing); - - return s; -} - -int -main (int argc, char **argv) -{ - int nf; - - Suite *s = equalizer_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; -} |