logcurve — This opcode implements a formula for generating a normalised logarithmic curve in range 0 - 1. It is based on the Max / MSP work of Eric Singer (c) 1994.


Generates a logarithmic curve in range 0 to 1 of arbitrary steepness. Steepness index less than 1.0 would result in Not-a-Number errors and cause unstable behavior, so it is treated as if it were 1.

The formula used to calculate the curve is:

log(x * (y-1)+1) / (log(y)

where x is equal to kindex and y is equal to ksteepness.


kout logcurve kindex, ksteepness


kindex -- Index value. Expected range 0 to 1.

ksteepness -- Steepness of the generated curve. Values closer to 1.0 result in a straighter line while larger values steepen the curve.

kout -- Scaled output.


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

Example 544. Example of the logcurve opcode.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

; Select audio/midi flags here according to platform
; Audio out   Audio in    Silent
-odac           -iadc     -d    ;;;realtime output

sr	=	48000
ksmps	=	100
nchnls	=	2

		instr	1	; logcurve test

kmod	phasor	1/p3

kout	logcurve kmod, p4

	printks "kmod = %f  kout = %f\\n", 0.1, kmod, kout



i1	0	10 2
i1	10	10 30
i1	20	10 0.5


See also

Linear and Exponential Generators


Author: David Akbari
Range check introduced in 6.16 by John ffitch