scale
Prev | Orchestra Opcodes and Operators | Next

## scale

scale — Arbitrary signal scaling.

## Description

Scales incoming value to user-definable range. Similar to scale object found in popular dataflow languages.

## Syntax

    kscl scale kinput, kmax, kmin[, kimax, kimin]

## Performance

kin -- Input value. Can originate from any k-rate source as long as that source's output is in range kimin to kimax.

kmin -- Minimum value of the resultant scale operation.

kmax -- Maximum value of the resultant scale operation.

kimin -- Optional; Minimum of the incoming value range, defaulting to zero.

kimax -- Optional; Maximum of the incoming value range, defaulting to one.

| Warning
Take care with the order of the arguments which has maximum before minimum

## Examples

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

Example 891. Example of the scale 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
    ; Audio out   Audio in    Silent
    -odac           -iadc     -d    ;;;realtime output
    </CsOptions>
    <CsInstruments>

    sr	=	22050
    ksmps	=	10
    nchnls	=	2

    /*--- ---*/

    	instr	1	; scale test

    kmod	ctrl7	1, 1, 0, 1
    	printk2	kmod

    kout	scale	kmod, 0, -127
    	printk2	kout

    	endin

    /*--- ---*/
    </CsInstruments>
    <CsScore>

    i1	0	8888

    e
    </CsScore>
    </CsoundSynthesizer>

## See Also

gainslider, logcurve, expcurve

## Credits

Author: David Akbari
October
2006
John ffitch
Modified to add input range vaue in 2020

Prev | Up | Next
sandpaper | Home | scalearray