max
Prev | Orchestra Opcodes and Operators | Next

## max

max — Produces a signal that is the maximum of any number of input signals.

## Description

The max opcode takes any number of a-rate, k-rate or i-rate signals as input (all of the same rate), and outputs a signal at the same rate that is the maximum of all of the inputs. For a-rate signals, the inputs are compared one sample at a time (i.e. max does not scan an entire ksmps period of a signal for its local maximum as the max_k opcode does).

## Syntax

    amax max ain1, ain2 [, ain3] [, ain4] [...]

    kmax max kin1, kin2 [, kin3] [, kin4] [...]

    imax max iin1, iin2 [, iin3] [, iin4] [...]

## Performance

ain1, ain2, ... -- a-rate signals to be compared.

kin1, kin2, ... -- k-rate signals to be compared.

iin1, iin2, ... -- i-rate signals to be compared.

## Examples

Here is an example of the max opcode. It uses the file max.csd.

Example 571. Example of the max opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac   ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o max.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1

    k1   oscili 1, 10.0, 1			;combine 3 sinusses
    k2   oscili 1, 1.0, 1			;at different rates
    k3   oscili 1, 3.0, 1
    kmax max   k1, k2, k3
    kmax = kmax*250				;scale kmax
    printk2 kmax				;check the values

    aout vco2 .5, 220, 6			;sawtooth
    asig moogvcf2 aout, 600+kmax, .5 	;change filter around 600 Hz
         outs asig, asig

    endin

    </CsInstruments>
    <CsScore>
    f1 0 32768 10 1

    i1 0 5
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

min, maxabs, minabs, maxaccum, minaccum, maxabsaccum, minabsaccum, max_k

## Credits

Author: Anthony Kozar
March 2006

New in Csound version 5.01; i-rate version new in 6.04

Prev | Up | Next
massign | Home | maxabs