2 * Copyright (C) <2004> Benjamin Otte <otte@gnome.org>
3 * <2007> Stefan Kost <ensonic@users.sf.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:element-equalizer-nbands
23 * @title: equalizer-nbands
25 * The n-band equalizer element is a fully parametric equalizer. It allows to
26 * select between 1 and 64 bands and has properties on each band to change
27 * the center frequency, band width and gain.
29 * ## Example launch line
31 * gst-launch-1.0 filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-nbands num-bands=15 band5::gain=6.0 ! alsasink
32 * ]| This make the equalizer use 15 bands and raises the volume of the 5th band by 6 db.
36 * #include <gst/gst.h>
43 * } GstEqualizerBandState;
47 * GstElement *equalizer;
50 * GstEqualizerBandState state[] = {
51 * { 120.0, 50.0, - 3.0},
52 * { 500.0, 20.0, 12.0},
53 * {1503.0, 2.0, -20.0},
54 * {6000.0, 1000.0, 6.0},
55 * {3000.0, 120.0, 2.0}
60 * equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer");
61 * g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL);
65 * for (i = 0; i < 5; i++) {
66 * band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i);
67 * g_object_set (G_OBJECT (band), "freq", state[i].freq,
68 * "bandwidth", state[i].width,
69 * "gain", state[i].gain);
70 * g_object_unref (G_OBJECT (band));
82 #include "gstiirequalizer.h"
83 #include "gstiirequalizernbands.h"
91 static void gst_iir_equalizer_nbands_set_property (GObject * object,
92 guint prop_id, const GValue * value, GParamSpec * pspec);
93 static void gst_iir_equalizer_nbands_get_property (GObject * object,
94 guint prop_id, GValue * value, GParamSpec * pspec);
96 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
97 #define GST_CAT_DEFAULT equalizer_debug
99 #define gst_iir_equalizer_nbands_parent_class parent_class
100 G_DEFINE_TYPE (GstIirEqualizerNBands, gst_iir_equalizer_nbands,
101 GST_TYPE_IIR_EQUALIZER);
102 GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (equalizer_nbands, "equalizer-nbands",
103 GST_RANK_NONE, GST_TYPE_IIR_EQUALIZER_NBANDS,
104 equalizer_element_init (plugin));
105 /* equalizer implementation */
108 gst_iir_equalizer_nbands_class_init (GstIirEqualizerNBandsClass * klass)
110 GObjectClass *gobject_class = (GObjectClass *) klass;
111 GstElementClass *gstelement_class = (GstElementClass *) klass;
113 gobject_class->set_property = gst_iir_equalizer_nbands_set_property;
114 gobject_class->get_property = gst_iir_equalizer_nbands_get_property;
116 g_object_class_install_property (gobject_class, PROP_NUM_BANDS,
117 g_param_spec_uint ("num-bands", "num-bands",
118 "number of different bands to use", 1, 64, 10,
119 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
121 gst_element_class_set_static_metadata (gstelement_class, "N Band Equalizer",
122 "Filter/Effect/Audio",
123 "Direct Form IIR equalizer",
124 "Benjamin Otte <otte@gnome.org>," " Stefan Kost <ensonic@users.sf.net>");
128 gst_iir_equalizer_nbands_init (GstIirEqualizerNBands * equ_n)
130 GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
132 gst_iir_equalizer_compute_frequencies (equ, 10);
136 gst_iir_equalizer_nbands_set_property (GObject * object, guint prop_id,
137 const GValue * value, GParamSpec * pspec)
139 GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
143 gst_iir_equalizer_compute_frequencies (equ, g_value_get_uint (value));
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
152 gst_iir_equalizer_nbands_get_property (GObject * object, guint prop_id,
153 GValue * value, GParamSpec * pspec)
155 GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
159 g_value_set_uint (value, equ->freq_band_count);
162 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);