| 1 | |
| 2 | <refentry id="maxabsaccum"> |
| 3 | <indexterm id="IndexMaxabsaccum"><primary>maxabsaccum</primary></indexterm> |
| 4 | <refentryinfo><title>Signal Modifiers:Comparators and Accumulators</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>maxabsaccum</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>maxabsaccum</refname> |
| 13 | <refpurpose> |
| 14 | Accumulates the maximum of the absolute values of audio signals. |
| 15 | </refpurpose> |
| 16 | </refnamediv> |
| 17 | |
| 18 | <refsect1> |
| 19 | <title>Description</title> |
| 20 | <para> |
| 21 | <emphasis>maxabsaccum</emphasis> compares two audio-rate variables and stores the maximum of their absolute values into the first. |
| 22 | </para> |
| 23 | </refsect1> |
| 24 | |
| 25 | <refsect1> |
| 26 | <title>Syntax</title> |
| 27 | <synopsis><command>maxabsaccum</command> aAccumulator, aInput</synopsis> |
| 28 | </refsect1> |
| 29 | |
| 30 | <refsect1> |
| 31 | <title>Performance</title> |
| 32 | <para> |
| 33 | <emphasis>aAccumulator</emphasis> -- audio variable to store the maximum value |
| 34 | </para> |
| 35 | |
| 36 | <para> |
| 37 | <emphasis>aInput</emphasis> -- signal that aAccumulator is compared to |
| 38 | </para> |
| 39 | |
| 40 | <para> |
| 41 | The <emphasis>maxabsaccum</emphasis> opcode is designed to accumulate the maximum value from among many audio signals that may be in different note instances, different channels, or otherwise cannot all be compared at once using the <emphasis>maxabs</emphasis> opcode. <emphasis>maxabsaccum</emphasis> is identical to <emphasis>maxaccum</emphasis> except that it takes the absolute value of aInput before the comparison. Its semantics are similar to <emphasis>vincr</emphasis> since <emphasis>aAccumulator</emphasis> is used as both an input and an output variable, except that <emphasis>maxabsaccum</emphasis> keeps the maximum absolute value instead of adding the signals together. <emphasis>maxabsaccum</emphasis> performs the following operation on each pair of samples: |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | <literallayout> |
| 46 | if (abs(aInput) > aAccumulator) aAccumulator = abs(aInput) |
| 47 | </literallayout> |
| 48 | </para> |
| 49 | |
| 50 | <para> |
| 51 | <emphasis>aAccumulator</emphasis> will usually be a global audio variable. At the end of any given computation cycle (k-period), after its value is read and used in some way, the accumulator variable should usually be reset to zero (perhaps by using the <emphasis>clear</emphasis> opcode). Clearing to zero is sufficient for <emphasis>maxabsaccum</emphasis>, unlike the <emphasis>maxaccum</emphasis> opcode. |
| 52 | </para> |
| 53 | </refsect1> |
| 54 | |
| 55 | <refsect1> |
| 56 | <title>Examples</title> |
| 57 | <para> |
| 58 | Here is an example of the maxabsaccum opcode. It uses the file <ulink url="examples/maxabsaccum.csd"><citetitle>maxabsaccum.csd</citetitle></ulink>. |
| 59 | <example> |
| 60 | <title>Example of the maxabsaccum opcode.</title> |
| 61 | <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> |
| 62 | <xi:include href="examples-xml/maxabsaccum.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 63 | </example> |
| 64 | </para> |
| 65 | </refsect1> |
| 66 | |
| 67 | <refsect1> |
| 68 | <title>See also</title> |
| 69 | <para><link linkend="SigmodCompaccum"><citetitle>Comparators and Accumulators</citetitle></link></para> |
| 70 | </refsect1> |
| 71 | |
| 72 | <refsect1> |
| 73 | <title>Credits</title> |
| 74 | <para> |
| 75 | <simplelist> |
| 76 | <member>Author: &nameanthony;</member> |
| 77 | <member>March 2006</member> |
| 78 | </simplelist> |
| 79 | </para> |
| 80 | |
| 81 | <para>New in Csound version 5.01</para> |
| 82 | </refsect1> |
| 83 | </refentry> |