Commit ab6e3e5e authored by Stefan Kost's avatar Stefan Kost

gst/equalizer/: Refactor plugin into a base class and a first subclass (nband...

gst/equalizer/: Refactor plugin into a base class and a first subclass (nband eq). The nband eq uses GstChildProxy an...

Original commit message from CVS:
* gst/equalizer/Makefile.am:
* gst/equalizer/gstiirequalizer.c: (_do_init),
(gst_iir_equalizer_band_set_property),
(gst_iir_equalizer_band_get_property),
(gst_iir_equalizer_band_class_init),
(gst_iir_equalizer_band_get_type),
(gst_iir_equalizer_child_proxy_get_child_by_index),
(gst_iir_equalizer_child_proxy_get_children_count),
(gst_iir_equalizer_child_proxy_interface_init),
(gst_iir_equalizer_base_init), (gst_iir_equalizer_class_init),
(gst_iir_equalizer_finalize), (setup_filter),
(gst_iir_equalizer_compute_frequencies),
(gst_iir_equalizer_set_property), (gst_iir_equalizer_get_property),
(gst_iir_equalizer_setup), (plugin_init):
* gst/equalizer/gstiirequalizer.h:
* gst/equalizer/gstiirequalizernbands.c:
(gst_iir_equalizer_nbands_base_init),
(gst_iir_equalizer_nbands_class_init),
(gst_iir_equalizer_nbands_init),
(gst_iir_equalizer_nbands_set_property),
(gst_iir_equalizer_nbands_get_property):
* gst/equalizer/gstiirequalizernbands.h:
Refactor plugin into a base class and a first subclass (nband eq). The
nband eq uses GstChildProxy and is controlable. More subclasses will
follow.
parent f1b91e36
2007-03-09 Stefan Kost <ensonic@users.sf.net>
* gst/equalizer/Makefile.am:
* gst/equalizer/gstiirequalizer.c: (_do_init),
(gst_iir_equalizer_band_set_property),
(gst_iir_equalizer_band_get_property),
(gst_iir_equalizer_band_class_init),
(gst_iir_equalizer_band_get_type),
(gst_iir_equalizer_child_proxy_get_child_by_index),
(gst_iir_equalizer_child_proxy_get_children_count),
(gst_iir_equalizer_child_proxy_interface_init),
(gst_iir_equalizer_base_init), (gst_iir_equalizer_class_init),
(gst_iir_equalizer_finalize), (setup_filter),
(gst_iir_equalizer_compute_frequencies),
(gst_iir_equalizer_set_property), (gst_iir_equalizer_get_property),
(gst_iir_equalizer_setup), (plugin_init):
* gst/equalizer/gstiirequalizer.h:
* gst/equalizer/gstiirequalizernbands.c:
(gst_iir_equalizer_nbands_base_init),
(gst_iir_equalizer_nbands_class_init),
(gst_iir_equalizer_nbands_init),
(gst_iir_equalizer_nbands_set_property),
(gst_iir_equalizer_nbands_get_property):
* gst/equalizer/gstiirequalizernbands.h:
Refactor plugin into a base class and a first subclass (nband eq). The
nband eq uses GstChildProxy and is controlable. More subclasses will
follow.
2007-03-08 Wim Taymans <wim@fluendo.com>
Includes patch by: Paul Davis <paul at linuxaudiosystems dot com>
......
common @ ea828a47
Subproject commit 7c5a0ab68de1fed4e5a1fd473160debc2c4c7b89
Subproject commit ea828a478fe11561881a6eaf1f7bf2b0b77c8c85
plugin_LTLIBRARIES = libgstequalizer.la
libgstequalizer_la_SOURCES = gstiirequalizer.c gstiirequalizer.h
libgstequalizer_la_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS)
libgstequalizer_la_LIBADD = $(GST_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-$(GST_MAJORMINOR) $(GST_BASE_LIBS) $(LIBM)
libgstequalizer_la_SOURCES = \
gstiirequalizer.c gstiirequalizer.h \
gstiirequalizernbands.c gstiirequalizernbands.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
This diff is collapsed.
/* 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
......@@ -22,9 +23,19 @@
#include <gst/audio/gstaudiofilter.h>
#include <gst/audio/gstringbuffer.h>
#include <gst/controller/gstcontroller.h>
#define GST_EQUALIZER_TRANSFORM_LOCK(eq) \
g_mutex_lock (GST_BASE_TRANSFORM(eq)->transform_lock)
#define GST_EQUALIZER_TRANSFORM_UNLOCK(eq) \
g_mutex_unlock (GST_BASE_TRANSFORM(eq)->transform_lock)
typedef struct _GstIirEqualizer GstIirEqualizer;
typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
typedef struct _GstIirEqualizerBand GstIirEqualizerBand;
#define GST_TYPE_IIR_EQUALIZER \
(gst_iir_equalizer_get_type())
......@@ -43,30 +54,22 @@ typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
typedef void (*ProcessFunc) (GstIirEqualizer * eq, guint8 * data, guint size,
guint channels);
typedef struct
{
gdouble alpha; /* IIR coefficients for outputs */
gdouble beta; /* IIR coefficients for inputs */
gdouble gamma; /* IIR coefficients for inputs */
} SecondOrderFilter;
struct _GstIirEqualizer
{
GstAudioFilter audiofilter;
/*< private >*/
GstIirEqualizerBand **bands;
/* properties */
guint freq_count;
guint freq_band_count;
gdouble band_width;
gdouble *freqs;
gdouble *values;
/* data */
SecondOrderFilter *filter;
/* for each band and channel */
gpointer history;
ProcessFunc process;
guint history_size;
ProcessFunc process;
};
struct _GstIirEqualizerClass
......@@ -74,4 +77,8 @@ 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__ */
/* 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.
*/
/*
*
* gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-nbands rband5::gain=-1.0 ! alsasink
*/
#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@user.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", 2, 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_EQUALIZER_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_EQUALIZER_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;
}
}
/* 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__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment