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-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-1.0 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 #define gst_iir_equalizer_3bands_parent_class parent_class
57 G_DEFINE_TYPE (GstIirEqualizer3Bands, gst_iir_equalizer_3bands,
58 GST_TYPE_IIR_EQUALIZER);
59
60 /* equalizer implementation */
61
62 static void
gst_iir_equalizer_3bands_class_init(GstIirEqualizer3BandsClass * klass)63 gst_iir_equalizer_3bands_class_init (GstIirEqualizer3BandsClass * klass)
64 {
65 GObjectClass *gobject_class = (GObjectClass *) klass;
66 GstElementClass *gstelement_class = (GstElementClass *) klass;
67
68 gobject_class->set_property = gst_iir_equalizer_3bands_set_property;
69 gobject_class->get_property = gst_iir_equalizer_3bands_get_property;
70
71 g_object_class_install_property (gobject_class, PROP_BAND0,
72 g_param_spec_double ("band0", "110 Hz",
73 "gain for the frequency band 100 Hz, ranging from -24.0 to +12.0",
74 -24.0, 12.0, 0.0,
75 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
76 g_object_class_install_property (gobject_class, PROP_BAND1,
77 g_param_spec_double ("band1", "1100 Hz",
78 "gain for the frequency band 1100 Hz, ranging from -24.0 to +12.0",
79 -24.0, 12.0, 0.0,
80 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
81 g_object_class_install_property (gobject_class, PROP_BAND2,
82 g_param_spec_double ("band2", "11 kHz",
83 "gain for the frequency band 11 kHz, ranging from -24.0 to +12.0",
84 -24.0, 12.0, 0.0,
85 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | GST_PARAM_CONTROLLABLE));
86
87 gst_element_class_set_static_metadata (gstelement_class, "3 Band Equalizer",
88 "Filter/Effect/Audio",
89 "Direct Form 3 band IIR equalizer", "Stefan Kost <ensonic@users.sf.net>");
90 }
91
92 static void
gst_iir_equalizer_3bands_init(GstIirEqualizer3Bands * equ_n)93 gst_iir_equalizer_3bands_init (GstIirEqualizer3Bands * equ_n)
94 {
95 GstIirEqualizer *equ = GST_IIR_EQUALIZER (equ_n);
96
97 gst_iir_equalizer_compute_frequencies (equ, 3);
98 }
99
100 static void
gst_iir_equalizer_3bands_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)101 gst_iir_equalizer_3bands_set_property (GObject * object, guint prop_id,
102 const GValue * value, GParamSpec * pspec)
103 {
104 GstChildProxy *equ = GST_CHILD_PROXY (object);
105
106 switch (prop_id) {
107 case PROP_BAND0:
108 gst_child_proxy_set_property (equ, "band0::gain", value);
109 break;
110 case PROP_BAND1:
111 gst_child_proxy_set_property (equ, "band1::gain", value);
112 break;
113 case PROP_BAND2:
114 gst_child_proxy_set_property (equ, "band2::gain", value);
115 break;
116 default:
117 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
118 break;
119 }
120 }
121
122 static void
gst_iir_equalizer_3bands_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)123 gst_iir_equalizer_3bands_get_property (GObject * object, guint prop_id,
124 GValue * value, GParamSpec * pspec)
125 {
126 GstChildProxy *equ = GST_CHILD_PROXY (object);
127
128 switch (prop_id) {
129 case PROP_BAND0:
130 gst_child_proxy_get_property (equ, "band0::gain", value);
131 break;
132 case PROP_BAND1:
133 gst_child_proxy_get_property (equ, "band1::gain", value);
134 break;
135 case PROP_BAND2:
136 gst_child_proxy_get_property (equ, "band2::gain", value);
137 break;
138 default:
139 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
140 break;
141 }
142 }
143