Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / equalizer / gstiirequalizer3bands.c
1 /* GStreamer
2  * Copyright (C) <2007> Stefan Kost <ensonic@users.sf.net>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 /**
21  * SECTION:element-equalizer-3bands
22  *
23  * The 3-band equalizer element allows to change the gain of a low frequency,
24  * medium frequency and high frequency band.
25  *
26  * <refsect2>
27  * <title>Example launch line</title>
28  * |[
29  * gst-launch filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-3bands band1=6.0 ! alsasink
30  * ]| This raises the volume of the 2nd band, which is at 1110 Hz, by 6 db.
31  * </refsect2>
32  */
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
37
38 #include "gstiirequalizer.h"
39 #include "gstiirequalizer3bands.h"
40
41 enum
42 {
43   PROP_BAND0 = 1,
44   PROP_BAND1,
45   PROP_BAND2,
46 };
47
48 static void gst_iir_equalizer_3bands_set_property (GObject * object,
49     guint prop_id, const GValue * value, GParamSpec * pspec);
50 static void gst_iir_equalizer_3bands_get_property (GObject * object,
51     guint prop_id, GValue * value, GParamSpec * pspec);
52
53 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
54 #define GST_CAT_DEFAULT equalizer_debug
55
56
57 static void
58 _do_init (GType object_type)
59 {
60   const GInterfaceInfo preset_interface_info = {
61     NULL,                       /* interface_init */
62     NULL,                       /* interface_finalize */
63     NULL                        /* interface_data */
64   };
65
66   g_type_add_interface_static (object_type, GST_TYPE_PRESET,
67       &preset_interface_info);
68 }
69
70 GST_BOILERPLATE_FULL (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
71     GstIirEqualizer, GST_TYPE_IIR_EQUALIZER, _do_init);
72
73 /* equalizer implementation */
74
75 static void
76 gst_iir_equalizer_3bands_base_init (gpointer g_class)
77 {
78   GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
79
80   gst_element_class_set_details_simple (element_class, "3 Band Equalizer",
81       "Filter/Effect/Audio",
82       "Direct Form 3 band IIR equalizer", "Stefan Kost <ensonic@users.sf.net>");
83 }
84
85 static void
86 gst_iir_equalizer_3bands_class_init (GstIirEqualizer3BandsClass * klass)
87 {
88   GObjectClass *gobject_class = (GObjectClass *) klass;
89
90   gobject_class->set_property = gst_iir_equalizer_3bands_set_property;
91   gobject_class->get_property = gst_iir_equalizer_3bands_get_property;
92
93   g_object_class_install_property (gobject_class, PROP_BAND0,
94       g_param_spec_double ("band0", "110 Hz",
95           "gain for the frequency band 100 Hz, ranging from -24.0 to +12.0",
96           -24.0, 12.0, 0.0,
97           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
98   g_object_class_install_property (gobject_class, PROP_BAND1,
99       g_param_spec_double ("band1", "1100 Hz",
100           "gain for the frequency band 1100 Hz, ranging from -24.0 to +12.0",
101           -24.0, 12.0, 0.0,
102           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
103   g_object_class_install_property (gobject_class, PROP_BAND2,
104       g_param_spec_double ("band2", "11 kHz",
105           "gain for the frequency band 11 kHz, ranging from -24.0 to +12.0",
106           -24.0, 12.0, 0.0,
107           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
108 }
109
110 static void
111 gst_iir_equalizer_3bands_init (GstIirEqualizer3Bands * equ_n,
112     GstIirEqualizer3BandsClass * g_class)
113 {
114   GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
115
116   gst_iir_equalizer_compute_frequencies (equ, 3);
117 }
118
119 static void
120 gst_iir_equalizer_3bands_set_property (GObject * object, guint prop_id,
121     const GValue * value, GParamSpec * pspec)
122 {
123   GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
124
125   switch (prop_id) {
126     case PROP_BAND0:
127       gst_child_proxy_set_property (GST_OBJECT (equ), "band0::gain", value);
128       break;
129     case PROP_BAND1:
130       gst_child_proxy_set_property (GST_OBJECT (equ), "band1::gain", value);
131       break;
132     case PROP_BAND2:
133       gst_child_proxy_set_property (GST_OBJECT (equ), "band2::gain", value);
134       break;
135     default:
136       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
137       break;
138   }
139 }
140
141 static void
142 gst_iir_equalizer_3bands_get_property (GObject * object, guint prop_id,
143     GValue * value, GParamSpec * pspec)
144 {
145   GstIirEqualizer *equ = GST_IIR_EQUALIZER (object);
146
147   switch (prop_id) {
148     case PROP_BAND0:
149       gst_child_proxy_get_property (GST_OBJECT (equ), "band0::gain", value);
150       break;
151     case PROP_BAND1:
152       gst_child_proxy_get_property (GST_OBJECT (equ), "band1::gain", value);
153       break;
154     case PROP_BAND2:
155       gst_child_proxy_get_property (GST_OBJECT (equ), "band2::gain", value);
156       break;
157     default:
158       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
159       break;
160   }
161 }