| 1 | |
| 2 | <refentry id="centroid"> |
| 3 | <indexterm id="IndexCentroid"><primary>centroid</primary></indexterm> |
| 4 | <refentryinfo><title>Spectral Processing:Other</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>centroid</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>centroid</refname> |
| 11 | <refpurpose> |
| 12 | Calculate the spectral centroid of a signal. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Calculate the spectral centroid of an audio signal on a given trigger. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis>kcent <command>centroid</command> asig, ktrig, ifftsize</synopsis> |
| 26 | </refsect1> |
| 27 | |
| 28 | <refsect1> |
| 29 | <title>Initialization</title> |
| 30 | <emphasis>ifftsize</emphasis> -- fftsize. Non pow-of-two values are converted to the next pow-of-two not smaller than ifftsize. |
| 31 | </refsect1> |
| 32 | |
| 33 | <refsect1> |
| 34 | <title>Performance</title> |
| 35 | <para> |
| 36 | <emphasis>kcent</emphasis> -- the spectral centroid in Hz |
| 37 | </para> |
| 38 | <para> |
| 39 | <emphasis>asig</emphasis> -- an input audio signal |
| 40 | </para> |
| 41 | <para> |
| 42 | <emphasis>ktrig</emphasis> -- 1 to calculate a new centroid, 0 to skip the process (and output previous value). |
| 43 | </para> |
| 44 | </refsect1> |
| 45 | |
| 46 | <refsect1> |
| 47 | <title>Examples</title> |
| 48 | <para> |
| 49 | Here is an example of the centroid opcode. It uses the file <ulink url="examples/centroid.csd"><citetitle>centroid.csd</citetitle></ulink>. |
| 50 | <example> |
| 51 | <title>Example of the centroid opcode.</title> |
| 52 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 53 | <xi:include href="examples-xml/centroid.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 54 | </example> |
| 55 | </para> |
| 56 | </refsect1> |
| 57 | |
| 58 | <refsect1> |
| 59 | <title>See also</title> |
| 60 | <para><link linkend="ControlSensing"><citetitle>Sensing and Control: Tempo and Pitch estimation</citetitle></link></para> |
| 61 | </refsect1> |
| 62 | |
| 63 | <refsect1> |
| 64 | <title>Credits</title> |
| 65 | <para> |
| 66 | <simplelist> |
| 67 | <member>Author: V Lazzarini;</member> |
| 68 | <member>August 2012</member> |
| 69 | </simplelist> |
| 70 | </para> |
| 71 | </refsect1> |
| 72 | </refentry> |