summaryrefslogtreecommitdiff
path: root/opcodes/maxaccum.xml
blob: cfe238429850025936248b6f39815c7c39d89727 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<refentry id="maxaccum">
<indexterm id="IndexMaxaccum"><primary>maxaccum</primary></indexterm>
  <refentryinfo><title>Signal Modifiers:Comparators and Accumulators</title></refentryinfo>
  <refmeta>
    <refentrytitle>maxaccum</refentrytitle>
  </refmeta>


 
  <refnamediv>
    <refname>maxaccum</refname>
    <refpurpose>
      Accumulates the maximum value of audio signals.
          </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      <emphasis>maxaccum</emphasis> compares two audio-rate variables and stores the maximum value between them into the first.  
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis><command>maxaccum</command> aAccumulator, aInput</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>aAccumulator</emphasis> -- audio variable to store the maximum value
    </para>

    <para>
      <emphasis>aInput</emphasis> -- signal that aAccumulator is compared to
    </para>

    <para>
      The <emphasis>maxaccum</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>max</emphasis> opcode.  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>maxaccum</emphasis> keeps the maximum value instead of adding the signals together.  <emphasis>maxaccum</emphasis> performs the following operation on each pair of samples:
    </para>

    <para>
      <literallayout>
            if  (aInput > aAccumulator)  aAccumulator = aInput
      </literallayout>
    </para>

    <para>
      <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).  Care must be taken however if aInput is negative at any point, in which case the accumulator should be initialized and reset to some large enough negative value that will always be less than the input signals to which it is compared.
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="minaccum"><citetitle>minaccum</citetitle></link>, 
      <link linkend="maxabsaccum"><citetitle>maxabsaccum</citetitle></link>, 
      <link linkend="minabsaccum"><citetitle>minabsaccum</citetitle></link>, 
      <link linkend="max"><citetitle>max</citetitle></link>, 
      <link linkend="min"><citetitle>min</citetitle></link>, 
      <link linkend="maxabs"><citetitle>maxabs</citetitle></link>, 
      <link linkend="minabs"><citetitle>minabs</citetitle></link>, 
      <link linkend="vincr"><citetitle>vincr</citetitle></link>,
      <link linkend="clear"><citetitle>clear</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: &nameanthony;</member>
        <member>March 2006</member>
      </simplelist>
    </para>

    <para>New in Csound version 5.01</para>
  </refsect1>
</refentry>