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., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
22 * SECTION:element-equalizer-nbands
24 * The n-band equalizer element is a fully parametric equalizer. It allows to
25 * select between 1 and 64 bands and has properties on each band to change
26 * the center frequency, band width and gain.
29 * <title>Example launch line</title>
31 * gst-launch 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.
35 * <title>Example code</title>
37 * #include <gst/gst.h>
44 * } GstEqualizerBandState;
48 * GstElement *equalizer;
51 * GstEqualizerBandState state[] = {
52 * { 120.0, 50.0, - 3.0},
53 * { 500.0, 20.0, 12.0},
54 * {1503.0, 2.0, -20.0},
55 * {6000.0, 1000.0, 6.0},
56 * {3000.0, 120.0, 2.0}
61 * equalizer = gst_element_factory_make ("equalizer-nbands", "equalizer");
62 * g_object_set (G_OBJECT (equalizer), "num-bands", 5, NULL);
66 * for (i = 0; i < 5; i++) {
67 * band = gst_child_proxy_get_child_by_index (GST_CHILD_PROXY (equalizer), i);
68 * g_object_set (G_OBJECT (band), "freq", state[i].freq,
69 * "bandwidth", state[i].width,
70 * "gain", state[i].gain);
71 * g_object_unref (G_OBJECT (band));
83 #include "gstiirequalizer.h"
84 #include "gstiirequalizernbands.h"
92 static void gst_iir_equalizer_nbands_set_property (GObject * object,
93 guint prop_id, const GValue * value, GParamSpec * pspec);
94 static void gst_iir_equalizer_nbands_get_property (GObject * object,
95 guint prop_id, GValue * value, GParamSpec * pspec);
97 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
98 #define GST_CAT_DEFAULT equalizer_debug
100 #define gst_iir_equalizer_nbands_parent_class parent_class
101 G_DEFINE_TYPE (GstIirEqualizerNBands, gst_iir_equalizer_nbands,
102 GST_TYPE_IIR_EQUALIZER);
104 /* equalizer implementation */
107 gst_iir_equalizer_nbands_class_init (GstIirEqualizerNBandsClass * klass)
109 GObjectClass *gobject_class = (GObjectClass *) klass;
110 GstElementClass *gstelement_class = (GstElementClass *) klass;
112 gobject_class->set_property = gst_iir_equalizer_nbands_set_property;
113 gobject_class->get_property = gst_iir_equalizer_nbands_get_property;
115 g_object_class_install_property (gobject_class, PROP_NUM_BANDS,
116 g_param_spec_uint ("num-bands", "num-bands",
117 "number of different bands to use", 1, 64, 10,
118 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT));
120 gst_element_class_set_static_metadata (gstelement_class, "N Band Equalizer",
121 "Filter/Effect/Audio",
122 "Direct Form IIR equalizer",
123 "Benjamin Otte <otte@gnome.org>," " Stefan Kost <ensonic@users.sf.net>");
127 gst_iir_equalizer_nbands_init (GstIirEqualizerNBands * equ_n)
129 GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
131 gst_iir_equalizer_compute_frequencies (equ, 10);
135 gst_iir_equalizer_nbands_set_property (GObject * object, guint prop_id,
136 const GValue * value, GParamSpec * pspec)
138 GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
142 gst_iir_equalizer_compute_frequencies (equ, g_value_get_uint (value));
145 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151 gst_iir_equalizer_nbands_get_property (GObject * object, guint prop_id,
152 GValue * value, GParamSpec * pspec)
154 GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
158 g_value_set_uint (value, equ->freq_band_count);
161 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);