minarray
Prev | Orchestra Opcodes and Operators | Next

## minarray

minarray — returns the minimum value in an array.

## Description

The minarray opcode returns the minimum value in a k-rate array, and optional its index.

## Syntax

    kmin [,kindx] minarray karray

## Performance

kmin -- variable for result.

kindx -- position (index) of result in array.

karray -- array for reading.

## Examples

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

Example 608. Example of the minarray 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
    -n
    </CsOptions>
    <CsInstruments>
    ksmps = 32
    ;example by joachim heintz

               seed       0

    instr 1
    ;create an array with 10 elements
    kArr[]     init       10
    ;fill in random numbers and print them out
    kIndx      =          0
      until kIndx == 10 do
    kNum       random     -100, 100
    kArr[kIndx] =         kNum
               printf     "kArr[%d] = %10f\n", kIndx+1, kIndx, kNum
    kIndx      +=         1
      od
    ;investigate minimum number and print it out
    kMin, kMinIndx minarray kArr
               printf     "Minimum of kArr = %f at index %d\n", kIndx+1, kMin, kMinIndx
               turnoff
    endin
    </CsInstruments>
    <CsScore>
    i1 0 0.1
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

maxarray, sumarray, scalearray,

## Credits

Author: John ffitch
October 2011

New in Csound version 5.14

Revised in Csound version 6.00 to work on multidimensional arrays

Prev | Up | Next
mincer | Home | mirror