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 * @title: equalizer-10bands
23 *
24 * The 10 band equalizer element allows to change the gain of 10 equally distributed
25 * frequency bands between 30 Hz and 15 kHz.
26 *
27 * ## Example launch line
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 *
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 GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (equalizer_10bands, "equalizer-10bands",
69 GST_RANK_NONE, GST_TYPE_IIR_EQUALIZER_10BANDS,
70 equalizer_element_init (plugin));
71
72 /* equalizer implementation */
73
74 static void
gst_iir_equalizer_10bands_class_init(GstIirEqualizer10BandsClass * klass)75 gst_iir_equalizer_10bands_class_init (GstIirEqualizer10BandsClass * klass)
76 {
77 GObjectClass *gobject_class = (GObjectClass *) klass;
78 GstElementClass *gstelement_class = (GstElementClass *) klass;
79
80 gobject_class->set_property = gst_iir_equalizer_10bands_set_property;
81 gobject_class->get_property = gst_iir_equalizer_10bands_get_property;
82
83 g_object_class_install_property (gobject_class, PROP_BAND0,
84 g_param_spec_double ("band0", "29 Hz",
85 "gain for the frequency band 29 Hz, ranging from -24 dB to +12 dB",
86 -24.0, 12.0, 0.0,
87 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
88 g_object_class_install_property (gobject_class, PROP_BAND1,
89 g_param_spec_double ("band1", "59 Hz",
90 "gain for the frequency band 59 Hz, ranging from -24 dB to +12 dB",
91 -24.0, 12.0, 0.0,
92 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
93 g_object_class_install_property (gobject_class, PROP_BAND2,
94 g_param_spec_double ("band2", "119 Hz",
95 "gain for the frequency band 119 Hz, ranging from -24 dB to +12 dB",
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_BAND3,
99 g_param_spec_double ("band3", "237 Hz",
100 "gain for the frequency band 237 Hz, ranging from -24 dB to +12 dB",
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_BAND4,
104 g_param_spec_double ("band4", "474 Hz",
105 "gain for the frequency band 474 Hz, ranging from -24 dB to +12 dB",
106 -24.0, 12.0, 0.0,
107 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
108 g_object_class_install_property (gobject_class, PROP_BAND5,
109 g_param_spec_double ("band5", "947 Hz",
110 "gain for the frequency band 947 Hz, ranging from -24 dB to +12 dB",
111 -24.0, 12.0, 0.0,
112 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
113 g_object_class_install_property (gobject_class, PROP_BAND6,
114 g_param_spec_double ("band6", "1889 Hz",
115 "gain for the frequency band 1889 Hz, ranging from -24 dB to +12 dB",
116 -24.0, 12.0, 0.0,
117 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
118 g_object_class_install_property (gobject_class, PROP_BAND7,
119 g_param_spec_double ("band7", "3770 Hz",
120 "gain for the frequency band 3770 Hz, ranging from -24 dB to +12 dB",
121 -24.0, 12.0, 0.0,
122 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
123 g_object_class_install_property (gobject_class, PROP_BAND8,
124 g_param_spec_double ("band8", "7523 Hz",
125 "gain for the frequency band 7523 Hz, ranging from -24 dB to +12 dB",
126 -24.0, 12.0, 0.0,
127 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
128 g_object_class_install_property (gobject_class, PROP_BAND9,
129 g_param_spec_double ("band9", "15011 Hz",
130 "gain for the frequency band 15011 Hz, ranging from -24 dB to +12 dB",
131 -24.0, 12.0, 0.0,
132 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
133
134 gst_element_class_set_static_metadata (gstelement_class, "10 Band Equalizer",
135 "Filter/Effect/Audio",
136 "Direct Form 10 band IIR equalizer",
137 "Stefan Kost <ensonic@users.sf.net>");
138 }
139
140 static void
gst_iir_equalizer_10bands_init(GstIirEqualizer10Bands * equ_n)141 gst_iir_equalizer_10bands_init (GstIirEqualizer10Bands * equ_n)
142 {
143 GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
144
145 gst_iir_equalizer_compute_frequencies (equ, 10);
146 }
147
148 static void
gst_iir_equalizer_10bands_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)149 gst_iir_equalizer_10bands_set_property (GObject * object, guint prop_id,
150 const GValue * value, GParamSpec * pspec)
151 {
152 GstChildProxy *equ = GST_CHILD_PROXY (object);
153
154 switch (prop_id) {
155 case PROP_BAND0:
156 gst_child_proxy_set_property (equ, "band0::gain", value);
157 break;
158 case PROP_BAND1:
159 gst_child_proxy_set_property (equ, "band1::gain", value);
160 break;
161 case PROP_BAND2:
162 gst_child_proxy_set_property (equ, "band2::gain", value);
163 break;
164 case PROP_BAND3:
165 gst_child_proxy_set_property (equ, "band3::gain", value);
166 break;
167 case PROP_BAND4:
168 gst_child_proxy_set_property (equ, "band4::gain", value);
169 break;
170 case PROP_BAND5:
171 gst_child_proxy_set_property (equ, "band5::gain", value);
172 break;
173 case PROP_BAND6:
174 gst_child_proxy_set_property (equ, "band6::gain", value);
175 break;
176 case PROP_BAND7:
177 gst_child_proxy_set_property (equ, "band7::gain", value);
178 break;
179 case PROP_BAND8:
180 gst_child_proxy_set_property (equ, "band8::gain", value);
181 break;
182 case PROP_BAND9:
183 gst_child_proxy_set_property (equ, "band9::gain", value);
184 break;
185 default:
186 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
187 break;
188 }
189 }
190
191 static void
gst_iir_equalizer_10bands_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)192 gst_iir_equalizer_10bands_get_property (GObject * object, guint prop_id,
193 GValue * value, GParamSpec * pspec)
194 {
195 GstChildProxy *equ = GST_CHILD_PROXY (object);
196
197 switch (prop_id) {
198 case PROP_BAND0:
199 gst_child_proxy_get_property (equ, "band0::gain", value);
200 break;
201 case PROP_BAND1:
202 gst_child_proxy_get_property (equ, "band1::gain", value);
203 break;
204 case PROP_BAND2:
205 gst_child_proxy_get_property (equ, "band2::gain", value);
206 break;
207 case PROP_BAND3:
208 gst_child_proxy_get_property (equ, "band3::gain", value);
209 break;
210 case PROP_BAND4:
211 gst_child_proxy_get_property (equ, "band4::gain", value);
212 break;
213 case PROP_BAND5:
214 gst_child_proxy_get_property (equ, "band5::gain", value);
215 break;
216 case PROP_BAND6:
217 gst_child_proxy_get_property (equ, "band6::gain", value);
218 break;
219 case PROP_BAND7:
220 gst_child_proxy_get_property (equ, "band7::gain", value);
221 break;
222 case PROP_BAND8:
223 gst_child_proxy_get_property (equ, "band8::gain", value);
224 break;
225 case PROP_BAND9:
226 gst_child_proxy_get_property (equ, "band9::gain", value);
227 break;
228 default:
229 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
230 break;
231 }
232 }
233