scale2

scale2 — Arbitrary signal scaling with optional smoothing.

Description

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

Syntax

kscl scale2 kinput, kmin, kmax[, kimin, kimax][ihtime]

Initialisation

ihtime -- Optional; Half time value for internal port filter for smoothing. Default is no smoothing.

Performance

kin -- Input value. Can originate from any k-rate source and should be in the range kimin to kimax. If it is larger than kimax it is treated as kimax, and if less than kimin then it is treated as kimin.

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] Warning
The argument order is minimum before maximum, which differs from scale but it consistent with other opcodes that use a range.

Examples

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

Example 930. Example of the scale2 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	=	44100
ksmps	=	10
nchnls	=	2

/*--- ---*/

	instr	1	; scale test

kmod	ctrl7	1, 1, 0, 1
	printk2	kmod

kout	scale2	kmod, -127, 0
	printk2	kout

	endin

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

i1	0	8888

e
</CsScore>
</CsoundSynthesizer>


See Also

gainslider, logcurve, expcurve scale

Credits

Author: John ffitch after David Akbari
December
2020