Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / docs / plugins / html / gst-plugins-good-plugins-spectrum.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <title>spectrum</title>
6 <meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
7 <link rel="home" href="index.html" title="GStreamer Good Plugins 0.10 Plugins Reference Manual">
8 <link rel="up" href="ch01.html" title="gst-plugins-good Elements">
9 <link rel="prev" href="gst-plugins-good-plugins-souphttpsrc.html" title="souphttpsrc">
10 <link rel="next" href="gst-plugins-good-plugins-speexenc.html" title="speexenc">
11 <meta name="generator" content="GTK-Doc V1.18 (XML mode)">
12 <link rel="stylesheet" href="style.css" type="text/css">
13 </head>
14 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
15 <table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
16 <tr valign="middle">
17 <td><a accesskey="p" href="gst-plugins-good-plugins-souphttpsrc.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
18 <td><a accesskey="u" href="ch01.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
19 <td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
20 <th width="100%" align="center">GStreamer Good Plugins 0.10 Plugins Reference Manual</th>
21 <td><a accesskey="n" href="gst-plugins-good-plugins-speexenc.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
22 </tr>
23 <tr><td colspan="5" class="shortcuts">
24 <a href="#gst-plugins-good-plugins-spectrum.synopsis" class="shortcut">Top</a>
25                    | 
26                   <a href="#gst-plugins-good-plugins-spectrum.description" class="shortcut">Description</a>
27                    | 
28                   <a href="#gst-plugins-good-plugins-spectrum.object-hierarchy" class="shortcut">Object Hierarchy</a>
29                    | 
30                   <a href="#gst-plugins-good-plugins-spectrum.properties" class="shortcut">Properties</a>
31 </td></tr>
32 </table>
33 <div class="refentry">
34 <a name="gst-plugins-good-plugins-spectrum"></a><div class="titlepage"></div>
35 <div class="refnamediv"><table width="100%"><tr>
36 <td valign="top">
37 <h2><span class="refentrytitle"><a name="gst-plugins-good-plugins-spectrum.top_of_page"></a>spectrum</span></h2>
38 <p>spectrum — Run an FFT on the audio signal, output spectrum data</p>
39 </td>
40 <td valign="top" align="right"></td>
41 </tr></table></div>
42 <div class="refsynopsisdiv">
43 <a name="gst-plugins-good-plugins-spectrum.synopsis"></a><h2>Synopsis</h2>
44 <a name="GstSpectrum"></a><pre class="synopsis">struct              <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum-struct" title="struct GstSpectrum">GstSpectrum</a>;
45 </pre>
46 </div>
47 <div class="refsect1">
48 <a name="gst-plugins-good-plugins-spectrum.object-hierarchy"></a><h2>Object Hierarchy</h2>
49 <pre class="synopsis">
50   <a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#GObject">GObject</a>
51    +----<a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstObject.html">GstObject</a>
52          +----<a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html">GstElement</a>
53                +----<a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-libs/html/GstBaseTransform.html">GstBaseTransform</a>
54                      +----<a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-libs/html/gst-plugins-base-libs-gstaudiofilter.html#GstAudioFilter">GstAudioFilter</a>
55                            +----GstSpectrum
56 </pre>
57 </div>
58 <div class="refsect1">
59 <a name="gst-plugins-good-plugins-spectrum.properties"></a><h2>Properties</h2>
60 <pre class="synopsis">
61   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--bands" title='The "bands" property'>bands</a>"                    <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#guint"><span class="type">guint</span></a>                 : Read / Write
62   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--interval" title='The "interval" property'>interval</a>"                 <span class="type">guint64</span>               : Read / Write
63   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--message" title='The "message" property'>message</a>"                  <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write
64   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--threshold" title='The "threshold" property'>threshold</a>"                <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gint"><span class="type">gint</span></a>                  : Read / Write
65   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--message-magnitude" title='The "message-magnitude" property'>message-magnitude</a>"        <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write
66   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--message-phase" title='The "message-phase" property'>message-phase</a>"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write
67   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--post-messages" title='The "post-messages" property'>post-messages</a>"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write
68   "<a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--multi-channel" title='The "multi-channel" property'>multi-channel</a>"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write
69 </pre>
70 </div>
71 <div class="refsect1">
72 <a name="gst-plugins-good-plugins-spectrum.description"></a><h2>Description</h2>
73 <p>
74 The Spectrum element analyzes the frequency spectrum of an audio signal.
75 If the <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--post-messages" title='The "post-messages" property'><span class="type">"post-messages"</span></a> property is <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><span class="type">TRUE</span></a>, it sends analysis results
76 as application messages named
77 <code class="classname">"spectrum"</code> after each interval of time given
78 by the <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--interval" title='The "interval" property'><span class="type">"interval"</span></a> property.
79 </p>
80 <p>
81 The message's structure contains some combination of these fields:
82 </p>
83 <div class="itemizedlist"><ul class="itemizedlist" type="disc">
84 <li class="listitem"><p>
85   <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
86   <code class="classname">"timestamp"</code>:
87   the timestamp of the buffer that triggered the message.
88   </p></li>
89 <li class="listitem"><p>
90   <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
91   <code class="classname">"stream-time"</code>:
92   the stream time of the buffer.
93   </p></li>
94 <li class="listitem"><p>
95   <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
96   <code class="classname">"running-time"</code>:
97   the running_time of the buffer.
98   </p></li>
99 <li class="listitem"><p>
100   <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
101   <code class="classname">"duration"</code>:
102   the duration of the buffer.
103   </p></li>
104 <li class="listitem"><p>
105   <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstClock.html#GstClockTime"><span class="type">GstClockTime</span></a>
106   <code class="classname">"endtime"</code>:
107   the end time of the buffer that triggered the message as stream time (this
108   is deprecated, as it can be calculated from stream-time + duration)
109   </p></li>
110 <li class="listitem"><p>
111   <span class="type">GstValueList</span> of <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a>
112   <code class="classname">"magnitude"</code>:
113   the level for each frequency band in dB. All values below the value of the
114   <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--threshold" title='The "threshold" property'><span class="type">"threshold"</span></a> property will be set to the threshold. Only present
115   if the <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--message-magnitude" title='The "message-magnitude" property'><span class="type">"message-magnitude"</span></a> property is <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.
116   </p></li>
117 <li class="listitem"><p>
118   <span class="type">GstValueList</span> of <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a>
119   <code class="classname">"phase"</code>:
120   The phase for each frequency band. The value is between -pi and pi. Only
121   present if the <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--message-phase" title='The "message-phase" property'><span class="type">"message-phase"</span></a> property is <a href="http://library.gnome.org/devel/glib/unstable/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a>.
122   </p></li>
123 </ul></div>
124 <p>
125 </p>
126 <p>
127 If <a class="link" href="gst-plugins-good-plugins-spectrum.html#GstSpectrum--multi-channel" title='The "multi-channel" property'><span class="type">"multi-channel"</span></a> property is set to true. magnitude and phase
128 fields will be each a nested <a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-libs/html/GstControlSource.html#GstValueArray"><span class="type">GstValueArray</span></a>. The first dimension are the
129 channels and the second dimension are the values.
130 </p>
131 <p>
132 </p>
133 <div class="refsect2">
134 <a name="idp22181664"></a><h3>Example application</h3>
135 <div class="informalexample">
136   <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
137     <tbody>
138       <tr>
139         <td class="listing_lines" align="right"><pre>1
140 2
141 3
142 4
143 5
144 6
145 7
146 8
147 9
148 10
149 11
150 12
151 13
152 14
153 15
154 16
155 17
156 18
157 19
158 20
159 21
160 22
161 23
162 24
163 25
164 26
165 27
166 28
167 29
168 30
169 31
170 32
171 33
172 34
173 35
174 36
175 37
176 38
177 39
178 40
179 41
180 42
181 43
182 44
183 45
184 46
185 47
186 48
187 49
188 50
189 51
190 52
191 53
192 54
193 55
194 56
195 57
196 58
197 59
198 60
199 61
200 62
201 63
202 64
203 65
204 66
205 67
206 68
207 69
208 70
209 71
210 72
211 73
212 74
213 75
214 76
215 77
216 78
217 79
218 80
219 81
220 82
221 83
222 84
223 85
224 86
225 87
226 88
227 89
228 90
229 91
230 92
231 93
232 94
233 95
234 96
235 97
236 98
237 99
238 100
239 101
240 102
241 103
242 104
243 105
244 106
245 107
246 108
247 109
248 110
249 111
250 112
251 113
252 114
253 115
254 116
255 117
256 118
257 119
258 120
259 121
260 122
261 123
262 124</pre></td>
263         <td class="listing_code"><pre class="programlisting"><span class="comment">/* GStreamer</span>
264 <span class="comment"> * Copyright (C) 2006 Stefan Kost &lt;ensonic&#64;users.sf.net&gt;</span>
265 <span class="comment"> * Copyright (C) 2008 Jan Schmidt &lt;jan.schmidt&#64;sun.com&gt;</span>
266 <span class="comment"> *</span>
267 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
268 <span class="comment"> * modify it under the terms of the GNU Library General Public</span>
269 <span class="comment"> * License as published by the Free Software Foundation; either</span>
270 <span class="comment"> * version 2 of the License, or (at your option) any later version.</span>
271 <span class="comment"> *</span>
272 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
273 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
274 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU</span>
275 <span class="comment"> * Library General Public License for more details.</span>
276 <span class="comment"> *</span>
277 <span class="comment"> * You should have received a copy of the GNU Library General Public</span>
278 <span class="comment"> * License along with this library; if not, write to the</span>
279 <span class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330,</span>
280 <span class="comment"> * Boston, MA 02111-1307, USA.</span>
281 <span class="comment"> */</span>
282
283 <span class="gtkdoc ppc">#include &lt;stdio.h&gt;</span>
284 <span class="gtkdoc ppc">#include &lt;string.h&gt;</span>
285 <span class="gtkdoc ppc">#include &lt;stdlib.h&gt;</span>
286 <span class="gtkdoc ppc">#include &lt;gst/gst.h&gt;</span>
287
288 <span class="gtkdoc kwb">static</span> guint spect_bands <span class="gtkdoc opt">=</span> <span class="number">20</span><span class="gtkdoc opt">;</span>
289
290 <span class="gtkdoc ppc">#define AUDIOFREQ 32000</span>
291
292 <span class="comment">/* receive spectral data from element message */</span>
293 <span class="gtkdoc kwb">static</span> gboolean
294 <span class="function">message_handler</span> <span class="gtkdoc opt">(</span>GstBus <span class="gtkdoc opt">*</span> bus<span class="gtkdoc opt">,</span> GstMessage <span class="gtkdoc opt">*</span> message<span class="gtkdoc opt">,</span> gpointer data<span class="gtkdoc opt">)</span>
295 <span class="gtkdoc opt">{</span>
296   <span class="keyword">if</span> <span class="gtkdoc opt">(</span>message<span class="gtkdoc opt">-&gt;</span>type <span class="gtkdoc opt">==</span> GST_MESSAGE_ELEMENT<span class="gtkdoc opt">) {</span>
297     <span class="gtkdoc kwb">const</span> GstStructure <span class="gtkdoc opt">*</span>s <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstMessage.html#gst-message-get-structure">gst_message_get_structure</a></span> <span class="gtkdoc opt">(</span>message<span class="gtkdoc opt">);</span>
298     <span class="gtkdoc kwb">const</span> gchar <span class="gtkdoc opt">*</span>name <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstStructure.html#gst-structure-get-name">gst_structure_get_name</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">);</span>
299     GstClockTime endtime<span class="gtkdoc opt">;</span>
300
301     <span class="keyword">if</span> <span class="gtkdoc opt">(</span><span class="function">strcmp</span> <span class="gtkdoc opt">(</span>name<span class="gtkdoc opt">,</span> <span class="string">&quot;spectrum&quot;</span><span class="gtkdoc opt">) ==</span> <span class="number">0</span><span class="gtkdoc opt">) {</span>
302       <span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>magnitudes<span class="gtkdoc opt">;</span>
303       <span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>phases<span class="gtkdoc opt">;</span>
304       <span class="gtkdoc kwb">const</span> GValue <span class="gtkdoc opt">*</span>mag<span class="gtkdoc opt">, *</span>phase<span class="gtkdoc opt">;</span>
305       gdouble freq<span class="gtkdoc opt">;</span>
306       guint i<span class="gtkdoc opt">;</span>
307
308       <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstStructure.html#gst-structure-get-clock-time">gst_structure_get_clock_time</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;endtime&quot;</span><span class="gtkdoc opt">, &amp;</span>endtime<span class="gtkdoc opt">))</span>
309         endtime <span class="gtkdoc opt">=</span> GST_CLOCK_TIME_NONE<span class="gtkdoc opt">;</span>
310
311       <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;New spectrum message, endtime %&quot;</span> GST_TIME_FORMAT <span class="string">&quot;</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span>
312           <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstInfo.html#GST-TIME-ARGS:CAPS">GST_TIME_ARGS</a></span> <span class="gtkdoc opt">(</span>endtime<span class="gtkdoc opt">));</span>
313
314       magnitudes <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstStructure.html#gst-structure-get-value">gst_structure_get_value</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;magnitude&quot;</span><span class="gtkdoc opt">);</span>
315       phases <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstStructure.html#gst-structure-get-value">gst_structure_get_value</a></span> <span class="gtkdoc opt">(</span>s<span class="gtkdoc opt">,</span> <span class="string">&quot;phase&quot;</span><span class="gtkdoc opt">);</span>
316
317       <span class="keyword">for</span> <span class="gtkdoc opt">(</span>i <span class="gtkdoc opt">=</span> <span class="number">0</span><span class="gtkdoc opt">;</span> i <span class="gtkdoc opt">&lt;</span> spect_bands<span class="gtkdoc opt">; ++</span>i<span class="gtkdoc opt">) {</span>
318         freq <span class="gtkdoc opt">= (</span>gdouble<span class="gtkdoc opt">) ((</span>AUDIOFREQ <span class="gtkdoc opt">/</span> <span class="number">2</span><span class="gtkdoc opt">) *</span> i <span class="gtkdoc opt">+</span> AUDIOFREQ <span class="gtkdoc opt">/</span> <span class="number">4</span><span class="gtkdoc opt">) /</span> spect_bands<span class="gtkdoc opt">;</span>
319         mag <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstValue.html#gst-value-list-get-value">gst_value_list_get_value</a></span> <span class="gtkdoc opt">(</span>magnitudes<span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
320         phase <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstValue.html#gst-value-list-get-value">gst_value_list_get_value</a></span> <span class="gtkdoc opt">(</span>phases<span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">);</span>
321
322         <span class="keyword">if</span> <span class="gtkdoc opt">(</span>mag <span class="gtkdoc opt">!=</span> NULL <span class="gtkdoc opt">&amp;&amp;</span> phase <span class="gtkdoc opt">!=</span> NULL<span class="gtkdoc opt">) {</span>
323           <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;band %d (freq %g): magnitude %f dB phase %f</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">,</span> i<span class="gtkdoc opt">,</span> freq<span class="gtkdoc opt">,</span>
324               <span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-float">g_value_get_float</a></span> <span class="gtkdoc opt">(</span>mag<span class="gtkdoc opt">),</span> <span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-Standard-Parameter-and-Value-Types.html#g-value-get-float">g_value_get_float</a></span> <span class="gtkdoc opt">(</span>phase<span class="gtkdoc opt">));</span>
325         <span class="gtkdoc opt">}</span>
326       <span class="gtkdoc opt">}</span>
327       <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Warnings-and-Assertions.html#g-print">g_print</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">);</span>
328     <span class="gtkdoc opt">}</span>
329   <span class="gtkdoc opt">}</span>
330   <span class="keyword">return</span> TRUE<span class="gtkdoc opt">;</span>
331 <span class="gtkdoc opt">}</span>
332
333 <span class="gtkdoc kwb">int</span>
334 <span class="function">main</span> <span class="gtkdoc opt">(</span><span class="gtkdoc kwb">int</span> argc<span class="gtkdoc opt">,</span> <span class="gtkdoc kwb">char</span> <span class="gtkdoc opt">*</span>argv<span class="gtkdoc opt">[])</span>
335 <span class="gtkdoc opt">{</span>
336   GstElement <span class="gtkdoc opt">*</span>bin<span class="gtkdoc opt">;</span>
337   GstElement <span class="gtkdoc opt">*</span>src<span class="gtkdoc opt">, *</span>audioconvert<span class="gtkdoc opt">, *</span>spectrum<span class="gtkdoc opt">, *</span>sink<span class="gtkdoc opt">;</span>
338   GstBus <span class="gtkdoc opt">*</span>bus<span class="gtkdoc opt">;</span>
339   GstCaps <span class="gtkdoc opt">*</span>caps<span class="gtkdoc opt">;</span>
340   GMainLoop <span class="gtkdoc opt">*</span>loop<span class="gtkdoc opt">;</span>
341
342   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-Gst.html#gst-init">gst_init</a></span> <span class="gtkdoc opt">(&amp;</span>argc<span class="gtkdoc opt">, &amp;</span>argv<span class="gtkdoc opt">);</span>
343
344   bin <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstPipeline.html#gst-pipeline-new">gst_pipeline_new</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;bin&quot;</span><span class="gtkdoc opt">);</span>
345
346   src <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audiotestsrc&quot;</span><span class="gtkdoc opt">,</span> <span class="string">&quot;src&quot;</span><span class="gtkdoc opt">);</span>
347   <span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-set">g_object_set</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#G-OBJECT:CAPS">G_OBJECT</a></span> <span class="gtkdoc opt">(</span>src<span class="gtkdoc opt">),</span> <span class="string">&quot;wave&quot;</span><span class="gtkdoc opt">,</span> <span class="number">0</span><span class="gtkdoc opt">,</span> <span class="string">&quot;freq&quot;</span><span class="gtkdoc opt">,</span> <span class="number">6000.0</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
348   audioconvert <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audioconvert&quot;</span><span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
349   <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-Testing.html#g-assert">g_assert</a></span> <span class="gtkdoc opt">(</span>audioconvert<span class="gtkdoc opt">);</span>
350
351   spectrum <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;spectrum&quot;</span><span class="gtkdoc opt">,</span> <span class="string">&quot;spectrum&quot;</span><span class="gtkdoc opt">);</span>
352   <span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-set">g_object_set</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#G-OBJECT:CAPS">G_OBJECT</a></span> <span class="gtkdoc opt">(</span>spectrum<span class="gtkdoc opt">),</span> <span class="string">&quot;bands&quot;</span><span class="gtkdoc opt">,</span> spect_bands<span class="gtkdoc opt">,</span> <span class="string">&quot;threshold&quot;</span><span class="gtkdoc opt">, -</span><span class="number">80</span><span class="gtkdoc opt">,</span>
353       <span class="string">&quot;message&quot;</span><span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">,</span> <span class="string">&quot;message-phase&quot;</span><span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
354
355   sink <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElementFactory.html#gst-element-factory-make">gst_element_factory_make</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;fakesink&quot;</span><span class="gtkdoc opt">,</span> <span class="string">&quot;sink&quot;</span><span class="gtkdoc opt">);</span>
356   <span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#g-object-set">g_object_set</a></span> <span class="gtkdoc opt">(</span><span class="function"><a href="http://library.gnome.org/devel/gobject/unstable/gobject-The-Base-Object-Type.html#G-OBJECT:CAPS">G_OBJECT</a></span> <span class="gtkdoc opt">(</span>sink<span class="gtkdoc opt">),</span> <span class="string">&quot;sync&quot;</span><span class="gtkdoc opt">,</span> TRUE<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
357
358   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBin.html#gst-bin-add-many">gst_bin_add_many</a></span> <span class="gtkdoc opt">(</span><span class="function">GST_BIN</span> <span class="gtkdoc opt">(</span>bin<span class="gtkdoc opt">),</span> src<span class="gtkdoc opt">,</span> audioconvert<span class="gtkdoc opt">,</span> spectrum<span class="gtkdoc opt">,</span> sink<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
359
360   caps <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstCaps.html#gst-caps-new-simple">gst_caps_new_simple</a></span> <span class="gtkdoc opt">(</span><span class="string">&quot;audio/x-raw-int&quot;</span><span class="gtkdoc opt">,</span>
361       <span class="string">&quot;rate&quot;</span><span class="gtkdoc opt">,</span> G_TYPE_INT<span class="gtkdoc opt">,</span> AUDIOFREQ<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
362
363   <span class="keyword">if</span> <span class="gtkdoc opt">(!</span><span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-link">gst_element_link</a></span> <span class="gtkdoc opt">(</span>src<span class="gtkdoc opt">,</span> audioconvert<span class="gtkdoc opt">) ||</span>
364       <span class="gtkdoc opt">!</span><span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-link-filtered">gst_element_link_filtered</a></span> <span class="gtkdoc opt">(</span>audioconvert<span class="gtkdoc opt">,</span> spectrum<span class="gtkdoc opt">,</span> caps<span class="gtkdoc opt">) ||</span>
365       <span class="gtkdoc opt">!</span><span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-link">gst_element_link</a></span> <span class="gtkdoc opt">(</span>spectrum<span class="gtkdoc opt">,</span> sink<span class="gtkdoc opt">)) {</span>
366     <span class="function">fprintf</span> <span class="gtkdoc opt">(</span>stderr<span class="gtkdoc opt">,</span> <span class="string">&quot;can't link elements</span><span class="gtkdoc esc">\n</span><span class="string">&quot;</span><span class="gtkdoc opt">);</span>
367     <span class="function">exit</span> <span class="gtkdoc opt">(</span><span class="number">1</span><span class="gtkdoc opt">);</span>
368   <span class="gtkdoc opt">}</span>
369   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstCaps.html#gst-caps-unref">gst_caps_unref</a></span> <span class="gtkdoc opt">(</span>caps<span class="gtkdoc opt">);</span>
370
371   bus <span class="gtkdoc opt">=</span> <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-get-bus">gst_element_get_bus</a></span> <span class="gtkdoc opt">(</span>bin<span class="gtkdoc opt">);</span>
372   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBus.html#gst-bus-add-watch">gst_bus_add_watch</a></span> <span class="gtkdoc opt">(</span>bus<span class="gtkdoc opt">,</span> message_handler<span class="gtkdoc opt">,</span> NULL<span class="gtkdoc opt">);</span>
373   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstObject.html#gst-object-unref">gst_object_unref</a></span> <span class="gtkdoc opt">(</span>bus<span class="gtkdoc opt">);</span>
374
375   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-set-state">gst_element_set_state</a></span> <span class="gtkdoc opt">(</span>bin<span class="gtkdoc opt">,</span> GST_STATE_PLAYING<span class="gtkdoc opt">);</span>
376
377   <span class="comment">/* we need to run a GLib main loop to get the messages */</span>
378   loop <span class="gtkdoc opt">=</span> <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-main-loop-new">g_main_loop_new</a></span> <span class="gtkdoc opt">(</span>NULL<span class="gtkdoc opt">,</span> FALSE<span class="gtkdoc opt">);</span>
379   <span class="function"><a href="http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html#g-main-loop-run">g_main_loop_run</a></span> <span class="gtkdoc opt">(</span>loop<span class="gtkdoc opt">);</span>
380
381   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstElement.html#gst-element-set-state">gst_element_set_state</a></span> <span class="gtkdoc opt">(</span>bin<span class="gtkdoc opt">,</span> GST_STATE_NULL<span class="gtkdoc opt">);</span>
382
383   <span class="function"><a href="http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstObject.html#gst-object-unref">gst_object_unref</a></span> <span class="gtkdoc opt">(</span>bin<span class="gtkdoc opt">);</span>
384
385   <span class="keyword">return</span> <span class="number">0</span><span class="gtkdoc opt">;</span>
386 <span class="gtkdoc opt">}</span></pre></td>
387       </tr>
388     </tbody>
389   </table>
390 </div>
391
392 </div>
393 <p>
394 </p>
395 <p>
396 Last reviewed on 2011-03-10 (0.10.29)
397 </p>
398 <div class="refsynopsisdiv">
399 <h2>Synopsis</h2>
400 <div class="refsect2">
401 <a name="idp22154752"></a><h3>Element Information</h3>
402 <div class="variablelist"><table border="0">
403 <col align="left" valign="top">
404 <tbody>
405 <tr>
406 <td><p><span class="term">plugin</span></p></td>
407 <td>
408             <a class="link" href="gst-plugins-good-plugins-plugin-spectrum.html#plugin-spectrum">spectrum</a>
409           </td>
410 </tr>
411 <tr>
412 <td><p><span class="term">author</span></p></td>
413 <td>Erik Walthinsen &lt;omega@cse.ogi.edu&gt;, Stefan Kost &lt;ensonic@users.sf.net&gt;, Sebastian Dröge &lt;sebastian.droege@collabora.co.uk&gt;</td>
414 </tr>
415 <tr>
416 <td><p><span class="term">class</span></p></td>
417 <td>Filter/Analyzer/Audio</td>
418 </tr>
419 </tbody>
420 </table></div>
421 </div>
422 <hr>
423 <div class="refsect2">
424 <a name="idp22804672"></a><h3>Element Pads</h3>
425 <div class="variablelist"><table border="0">
426 <col align="left" valign="top">
427 <tbody>
428 <tr>
429 <td><p><span class="term">name</span></p></td>
430 <td>sink</td>
431 </tr>
432 <tr>
433 <td><p><span class="term">direction</span></p></td>
434 <td>sink</td>
435 </tr>
436 <tr>
437 <td><p><span class="term">presence</span></p></td>
438 <td>always</td>
439 </tr>
440 <tr>
441 <td><p><span class="term">details</span></p></td>
442 <td>audio/x-raw-int, width=(int)16, depth=(int)[ 1, 16 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
443 </tr>
444 <tr>
445 <td><p><span class="term"></span></p></td>
446 <td> audio/x-raw-int, width=(int)24, depth=(int)[ 1, 24 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
447 </tr>
448 <tr>
449 <td><p><span class="term"></span></p></td>
450 <td> audio/x-raw-int, width=(int)32, depth=(int)[ 1, 32 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
451 </tr>
452 <tr>
453 <td><p><span class="term"></span></p></td>
454 <td> audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
455 </tr>
456 </tbody>
457 </table></div>
458 <div class="variablelist"><table border="0">
459 <col align="left" valign="top">
460 <tbody>
461 <tr>
462 <td><p><span class="term">name</span></p></td>
463 <td>src</td>
464 </tr>
465 <tr>
466 <td><p><span class="term">direction</span></p></td>
467 <td>source</td>
468 </tr>
469 <tr>
470 <td><p><span class="term">presence</span></p></td>
471 <td>always</td>
472 </tr>
473 <tr>
474 <td><p><span class="term">details</span></p></td>
475 <td>audio/x-raw-int, width=(int)16, depth=(int)[ 1, 16 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
476 </tr>
477 <tr>
478 <td><p><span class="term"></span></p></td>
479 <td> audio/x-raw-int, width=(int)24, depth=(int)[ 1, 24 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
480 </tr>
481 <tr>
482 <td><p><span class="term"></span></p></td>
483 <td> audio/x-raw-int, width=(int)32, depth=(int)[ 1, 32 ], signed=(boolean)true, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
484 </tr>
485 <tr>
486 <td><p><span class="term"></span></p></td>
487 <td> audio/x-raw-float, width=(int){ 32, 64 }, endianness=(int)1234, rate=(int)[ 1, 2147483647 ], channels=(int)[ 1, 2147483647 ]</td>
488 </tr>
489 </tbody>
490 </table></div>
491 </div>
492 </div>
493 <p>
494 </p>
495 </div>
496 <div class="refsect1">
497 <a name="gst-plugins-good-plugins-spectrum.details"></a><h2>Details</h2>
498 <div class="refsect2">
499 <a name="GstSpectrum-struct"></a><h3>struct GstSpectrum</h3>
500 <pre class="programlisting">struct GstSpectrum;</pre>
501 <p>
502 </p>
503 </div>
504 </div>
505 <div class="refsect1">
506 <a name="gst-plugins-good-plugins-spectrum.property-details"></a><h2>Property Details</h2>
507 <div class="refsect2">
508 <a name="GstSpectrum--bands"></a><h3>The <code class="literal">"bands"</code> property</h3>
509 <pre class="programlisting">  "bands"                    <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#guint"><span class="type">guint</span></a>                 : Read / Write</pre>
510 <p>Number of frequency bands.</p>
511 <p>Default value: 128</p>
512 </div>
513 <hr>
514 <div class="refsect2">
515 <a name="GstSpectrum--interval"></a><h3>The <code class="literal">"interval"</code> property</h3>
516 <pre class="programlisting">  "interval"                 <span class="type">guint64</span>               : Read / Write</pre>
517 <p>Interval of time between message posts (in nanoseconds).</p>
518 <p>Allowed values: &gt;= 1</p>
519 <p>Default value: 100000000</p>
520 </div>
521 <hr>
522 <div class="refsect2">
523 <a name="GstSpectrum--message"></a><h3>The <code class="literal">"message"</code> property</h3>
524 <pre class="programlisting">  "message"                  <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write</pre>
525 <p>Whether to post a 'spectrum' element message on the bus for each passed interval (deprecated, use post-messages).</p>
526 <p>Default value: TRUE</p>
527 </div>
528 <hr>
529 <div class="refsect2">
530 <a name="GstSpectrum--threshold"></a><h3>The <code class="literal">"threshold"</code> property</h3>
531 <pre class="programlisting">  "threshold"                <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gint"><span class="type">gint</span></a>                  : Read / Write</pre>
532 <p>dB threshold for result. All lower values will be set to this.</p>
533 <p>Allowed values: &lt;= 0</p>
534 <p>Default value: -60</p>
535 </div>
536 <hr>
537 <div class="refsect2">
538 <a name="GstSpectrum--message-magnitude"></a><h3>The <code class="literal">"message-magnitude"</code> property</h3>
539 <pre class="programlisting">  "message-magnitude"        <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write</pre>
540 <p>Whether to add a 'magnitude' field to the structure of any 'spectrum' element messages posted on the bus.</p>
541 <p>Default value: TRUE</p>
542 </div>
543 <hr>
544 <div class="refsect2">
545 <a name="GstSpectrum--message-phase"></a><h3>The <code class="literal">"message-phase"</code> property</h3>
546 <pre class="programlisting">  "message-phase"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write</pre>
547 <p>Whether to add a 'phase' field to the structure of any 'spectrum' element messages posted on the bus.</p>
548 <p>Default value: FALSE</p>
549 </div>
550 <hr>
551 <div class="refsect2">
552 <a name="GstSpectrum--post-messages"></a><h3>The <code class="literal">"post-messages"</code> property</h3>
553 <pre class="programlisting">  "post-messages"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write</pre>
554 <p>
555 Post messages on the bus with spectrum information.
556 </p>
557 <p>Default value: TRUE</p>
558 <p class="since">Since 0.10.17</p>
559 </div>
560 <hr>
561 <div class="refsect2">
562 <a name="GstSpectrum--multi-channel"></a><h3>The <code class="literal">"multi-channel"</code> property</h3>
563 <pre class="programlisting">  "multi-channel"            <a href="http://library.gnome.org/devel/glib/unstable/glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>              : Read / Write</pre>
564 <p>
565 Send separate results for each channel
566 </p>
567 <p>Default value: FALSE</p>
568 <p class="since">Since 0.10.29</p>
569 </div>
570 </div>
571 </div>
572 <div class="footer">
573 <hr>
574           Generated by GTK-Doc V1.18</div>
575 </body>
576 </html>