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