scalearray
Prev | Orchestra Opcodes and Operators | Next

## scalearray

scalearray — Scales the values in a range of a vector (one dimensional array).

## Description

The scalearray opcode scales a subregion of a vector to a given minimum/maximum.

## Syntax

    scalearray tarray, kmin, kmax[, kleft, kright]

## Performance

karray -- array for operation.

kmin, kmax -- target minimum and maximum values.

kleft, kright -- range of table to use, defaulting to 0 and size of the vector.

## Examples

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

Example 928. Example of the scalearray 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>
    ;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
               printks    "kArr in maximum range 0..100:\n", 0
    kIndx      =          0
      until kIndx == 10 do
    kNum       random     0, 100
    kArr[kIndx] =         kNum
               printf     "kArr[%d] = %10f\n", kIndx+1, kIndx, kNum
    kIndx      +=         1
      od
    ;scale numbers 0...1 and print them out again
               scalearray kArr, 0, 1
    kIndx      =          0
               printks    "kArr in range 0..1\n", 0
      until kIndx == 10 do
               printf     "kArr[%d] = %10f\n", kIndx+1, kIndx, kArr[kIndx]
    kIndx      +=         1
      od
               turnoff
    endin
    </CsInstruments>
    <CsScore>
    i1 0 0.1
    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

maxarray, minarray, sumarray,

## Credits

Author: John ffitch
October 2011

New in Csound version 5.14

Renamed in Csound version 6.00

Prev | Up | Next
scale2 | Home | scanhammer