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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 /**
21 * SECTION:element-equalizer-10bands
22 *
23 * The 10 band equalizer element allows to change the gain of 10 equally distributed
24 * frequency bands between 30 Hz and 15 kHz.
25 *
26 * <refsect2>
27 * <title>Example launch line</title>
28 * |[
29 * gst-launch-1.0 filesrc location=song.ogg ! oggdemux ! vorbisdec ! audioconvert ! equalizer-10bands band2=3.0 ! alsasink
30 * ]| This raises the volume of the 3rd band which is at 119 Hz by 3 db.
31 * </refsect2>
32 */
33
34 #ifdef HAVE_CONFIG_H
35 #include "config.h"
36 #endif
37
38 #include "gstiirequalizer.h"
39 #include "gstiirequalizer10bands.h"
40
41
42 enum
43 {
44 PROP_BAND0 = 1,
45 PROP_BAND1,
46 PROP_BAND2,
47 PROP_BAND3,
48 PROP_BAND4,
49 PROP_BAND5,
50 PROP_BAND6,
51 PROP_BAND7,
52 PROP_BAND8,
53 PROP_BAND9,
54 };
55
56 static void gst_iir_equalizer_10bands_set_property (GObject * object,
57 guint prop_id, const GValue * value, GParamSpec * pspec);
58 static void gst_iir_equalizer_10bands_get_property (GObject * object,
59 guint prop_id, GValue * value, GParamSpec * pspec);
60
61 GST_DEBUG_CATEGORY_EXTERN (equalizer_debug);
62 #define GST_CAT_DEFAULT equalizer_debug
63
64
65 #define gst_iir_equalizer_10bands_parent_class parent_class
66 G_DEFINE_TYPE (GstIirEqualizer10Bands, gst_iir_equalizer_10bands,
67 GST_TYPE_IIR_EQUALIZER);
68
69 /* equalizer implementation */
70
71 static void
gst_iir_equalizer_10bands_class_init(GstIirEqualizer10BandsClass * klass)72 gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass)
73 {
74 GObjectClass *gobject_class = (GObjectClass *) klass;
75 GstElementClass *gstelement_class = (GstElementClass *) klass;
76
77 gobject_class->set_property = gst_iir_equalizer_10bands_set_property;
78 gobject_class->get_property = gst_iir_equalizer_10bands_get_property;
79
80 g_object_class_install_property (gobject_class, PROP_BAND0,
81 g_param_spec_double ("band0", "29 Hz",
82 "gain for the frequency band 29 Hz, ranging from -24 dB to +12 dB",
83 -24.0, 12.0, 0.0,
84 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
85 g_object_class_install_property (gobject_class, PROP_BAND1,
86 g_param_spec_double ("band1", "59 Hz",
87 "gain for the frequency band 59 Hz, ranging from -24 dB to +12 dB",
88 -24.0, 12.0, 0.0,
89 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
90 g_object_class_install_property (gobject_class, PROP_BAND2,
91 g_param_spec_double ("band2", "119 Hz",
92 "gain for the frequency band 119 Hz, ranging from -24 dB to +12 dB",
93 -24.0, 12.0, 0.0,
94 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
95 g_object_class_install_property (gobject_class, PROP_BAND3,
96 g_param_spec_double ("band3", "237 Hz",
97 "gain for the frequency band 237 Hz, ranging from -24 dB to +12 dB",
98 -24.0, 12.0, 0.0,
99 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
100 g_object_class_install_property (gobject_class, PROP_BAND4,
101 g_param_spec_double ("band4", "474 Hz",
102 "gain for the frequency band 474 Hz, ranging from -24 dB to +12 dB",
103 -24.0, 12.0, 0.0,
104 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
105 g_object_class_install_property (gobject_class, PROP_BAND5,
106 g_param_spec_double ("band5", "947 Hz",
107 "gain for the frequency band 947 Hz, ranging from -24 dB to +12 dB",
108 -24.0, 12.0, 0.0,
109 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
110 g_object_class_install_property (gobject_class, PROP_BAND6,
111 g_param_spec_double ("band6", "1889 Hz",
112 "gain for the frequency band 1889 Hz, ranging from -24 dB to +12 dB",
113 -24.0, 12.0, 0.0,
114 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
115 g_object_class_install_property (gobject_class, PROP_BAND7,
116 g_param_spec_double ("band7", "3770 Hz",
117 "gain for the frequency band 3770 Hz, ranging from -24 dB to +12 dB",
118 -24.0, 12.0, 0.0,
119 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
120 g_object_class_install_property (gobject_class, PROP_BAND8,
121 g_param_spec_double ("band8", "7523 Hz",
122 "gain for the frequency band 7523 Hz, ranging from -24 dB to +12 dB",
123 -24.0, 12.0, 0.0,
124 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
125 g_object_class_install_property (gobject_class, PROP_BAND9,
126 g_param_spec_double ("band9", "15011 Hz",
127 "gain for the frequency band 15011 Hz, ranging from -24 dB to +12 dB",
128 -24.0, 12.0, 0.0,
129 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
130
131 gst_element_class_set_static_metadata (gstelement_class, "10 Band Equalizer",
132 "Filter/Effect/Audio",
133 "Direct Form 10 band IIR equalizer",
134 "Stefan Kost <ensonic@users.sf.net>");
135 }
136
137 static void
gst_iir_equalizer_10bands_init(GstIirEqualizer10Bands * equ_n)138 gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n)
139 {
140 GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
141
142 gst_iir_equalizer_compute_frequencies (equ, 10);
143 }
144
145 static void
gst_iir_equalizer_10bands_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)146 gst_iir_equalizer_10bands_set_property (GObject * object, guint prop_id,
147 const GValue * value, GParamSpec * pspec)
148 {
149 GstChildProxy *equ = GST_CHILD_PROXY (object);
150
151 switch (prop_id) {
152 case PROP_BAND0:
153 gst_child_proxy_set_property (equ, "band0::gain", value);
154 break;
155 case PROP_BAND1:
156 gst_child_proxy_set_property (equ, "band1::gain", value);
157 break;
158 case PROP_BAND2:
159 gst_child_proxy_set_property (equ, "band2::gain", value);
160 break;
161 case PROP_BAND3:
162 gst_child_proxy_set_property (equ, "band3::gain", value);
163 break;
164 case PROP_BAND4:
165 gst_child_proxy_set_property (equ, "band4::gain", value);
166 break;
167 case PROP_BAND5:
168 gst_child_proxy_set_property (equ, "band5::gain", value);
169 break;
170 case PROP_BAND6:
171 gst_child_proxy_set_property (equ, "band6::gain", value);
172 break;
173 case PROP_BAND7:
174 gst_child_proxy_set_property (equ, "band7::gain", value);
175 break;
176 case PROP_BAND8:
177 gst_child_proxy_set_property (equ, "band8::gain", value);
178 break;
179 case PROP_BAND9:
180 gst_child_proxy_set_property (equ, "band9::gain", value);
181 break;
182 default:
183 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
184 break;
185 }
186 }
187
188 static void
gst_iir_equalizer_10bands_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)189 gst_iir_equalizer_10bands_get_property (GObject * object, guint prop_id,
190 GValue * value, GParamSpec * pspec)
191 {
192 GstChildProxy *equ = GST_CHILD_PROXY (object);
193
194 switch (prop_id) {
195 case PROP_BAND0:
196 gst_child_proxy_get_property (equ, "band0::gain", value);
197 break;
198 case PROP_BAND1:
199 gst_child_proxy_get_property (equ, "band1::gain", value);
200 break;
201 case PROP_BAND2:
202 gst_child_proxy_get_property (equ, "band2::gain", value);
203 break;
204 case PROP_BAND3:
205 gst_child_proxy_get_property (equ, "band3::gain", value);
206 break;
207 case PROP_BAND4:
208 gst_child_proxy_get_property (equ, "band4::gain", value);
209 break;
210 case PROP_BAND5:
211 gst_child_proxy_get_property (equ, "band5::gain", value);
212 break;
213 case PROP_BAND6:
214 gst_child_proxy_get_property (equ, "band6::gain", value);
215 break;
216 case PROP_BAND7:
217 gst_child_proxy_get_property (equ, "band7::gain", value);
218 break;
219 case PROP_BAND8:
220 gst_child_proxy_get_property (equ, "band8::gain", value);
221 break;
222 case PROP_BAND9:
223 gst_child_proxy_get_property (equ, "band9::gain", value);
224 break;
225 default:
226 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
227 break;
228 }
229 }
230