Skip to content

scalearray

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

Syntax

scalearray(karray, kmin, kmax[, kleft, kright])
scalearray karray, 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.

Replacing scalet

scalet is the deprecated k-rate name. Replace scalet(kArray, kmin, kmax, kleft, kright) with scalearray(kArray, kmin, kmax, kleft, kright). Both modify the same array in place on each control cycle.

The left index is inclusive and the right index is exclusive. Defaults select the whole vector. scalearray also supports an i-rate array form for initialization-time scaling.

Examples

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

Example of the scalearray opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-n 
</CsOptions>
<CsInstruments>
0dbfs = 1
;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

Array opcodes

Credits

Author: John ffitch
October 2011

New in Csound version 5.14

Renamed in Csound version 6.00