maxaccum — Accumulates the maximum value of audio signals.
maxaccum compares two audio-rate variables and stores the maximum value between them into the first.
aAccumulator -- audio variable to store the maximum value
aInput -- signal that aAccumulator is compared to
The maxaccum 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 max opcode. Its semantics are similar to vincr since aAccumulator is used as both an input and an output variable, except that maxaccum keeps the maximum value instead of adding the signals together. maxaccum performs the following operation on each pair of samples:
if (aInput > aAccumulator) aAccumulator = aInput
aAccumulator 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 clear 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.