tizen 2.3.1 release
[framework/multimedia/gst-plugins-ext0.10.git] / audioeq / src / gstaudioeq.h
1 /*
2  * audioeq
3  *
4  * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Aditi Narula <aditi.n@samsung.com>
7  *
8  * This library is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU Lesser General Public License as published by the
10  * Free Software Foundation; either version 2.1 of the License, or (at your option)
11  * any later version.
12  *
13  * This library is distributed in the hope that it will be useful, but WITHOUT ANY
14  * WARRANTY; without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; if not, write to the Free Software Foundation, Inc., 51
20  * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  *
22  */
23
24
25 #ifndef __GST_AUDIOEQ_H__
26 #define __GST_AUDIOEQ_H__
27
28 #include <stdio.h>
29 #include <gst/gst.h>
30 #include <gst/base/gstbasetransform.h>
31 #include <gst/audio/gstaudiofilter.h>
32 #include <gst/audio/gstringbuffer.h>
33 #include <gst/controller/gstcontroller.h>
34
35 G_BEGIN_DECLS
36
37 #define GST_TYPE_AUDIOEQ \
38         (gst_audioeq_get_type())
39 #define GST_AUDIOEQ(obj) \
40         (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_AUDIOEQ,Gstaudioeq))
41 #define GST_audioeq_CLASS(klass) \
42         (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_AUDIOEQ,GstaudioeqClass))
43 #define GST_IS_AUDIOEQ(obj) \
44         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_AUDIOEQ))
45 #define GST_IS_AUDIOEQ_CLASS(klass) \
46         (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_AUDIOEQ))
47 #define GST_TYPE_IIR_EQUALIZER \
48   (gst_iir_equalizer_get_type())
49 #define GST_IIR_EQUALIZER(obj) \
50   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_IIR_EQUALIZER,GstIirEqualizer))
51 #define GST_IIR_EQUALIZER_CLASS(klass) \
52   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_IIR_EQUALIZER,GstIirEqualizerClass))
53 #define GST_IS_IIR_EQUALIZER(obj) \
54   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_IIR_EQUALIZER))
55 #define GST_IS_IIR_EQUALIZER_CLASS(klass) \
56   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_IIR_EQUALIZER))
57
58 typedef struct _Gstaudioeq Gstaudioeq;
59 typedef struct _GstaudioeqClass GstaudioeqClass;
60 typedef struct _GstIirEqualizer GstIirEqualizer;
61 typedef struct _GstIirEqualizerClass GstIirEqualizerClass;
62 typedef struct _GstIirEqualizerBand GstIirEqualizerBand;
63
64 #define CUSTOM_EQ_BAND_MAX                              9
65
66 #define LOWEST_FREQ (20.0)
67 #define HIGHEST_FREQ (20000.0)
68
69 typedef void (*ProcessFunc) (GstIirEqualizer * eq, guint8 * data, guint size,
70     guint channels);
71
72 struct _GstIirEqualizer
73 {
74   GstAudioFilter audiofilter;
75
76   /*< private >*/
77
78   GMutex *bands_lock;
79   GstIirEqualizerBand **bands;
80
81   /* properties */
82   guint freq_band_count;
83   /* for each band and channel */
84   gpointer history;
85   guint history_size;
86
87   gboolean need_new_coefficients;
88
89   ProcessFunc process;
90 };
91
92 struct _GstIirEqualizerClass
93 {
94   GstAudioFilterClass audiofilter_class;
95 };
96
97
98
99 struct _Gstaudioeq
100 {
101         GstBaseTransform element;
102
103         guint           samplerate;
104         guint           channels;
105
106         /* properties */
107         guint           filter_action;
108         gint                    custom_eq[CUSTOM_EQ_BAND_MAX];
109         gboolean                need_update_filter;
110         GstIirEqualizer equ;
111 };
112
113 struct _GstaudioeqClass
114 {
115         GstAudioFilterClass parent_class;
116 };
117
118 void gst_iir_equalizer_compute_frequencies (Gstaudioeq * audioeq, guint new_count);
119
120 GType gst_iir_equalizer_get_type(void);
121
122 GType gst_audioeq_get_type (void);
123
124 G_END_DECLS
125
126 #endif /* __GST_AUDIOEQ_H__ */
127