User-Defined Opcode Database

LogCurve

Normalised logarithmic curve with variable steepness.

Download UDO File

Description

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.

Syntax

kout LogCurve kfloat, ksteepness

Performance

kfloat -- A normalised floating point value in range 0 - 1.

ksteepness -- Steepness index of the resulting curve. This should be > 1. There exists a safeguard in the opcode to help minimize errors related to Not-a-Number (NaN) as a result of having a steepness index of <= 1.

Code

opcode	LogCurve, k, kk

kfloat, ksteep	xin

if (ksteep > 1) then
	ksteep = ksteep
elseif (ksteep < 1) then
	ksteep = 1.00001
endif

kout	=	(log(kfloat * (ksteep-1)+1)/log(ksteep))

	xout	kout

		endop

Examples

sr	=	44100
kr	=	441
ksmps	=	100
nchnls	=	2
	OSCinit	4201

#include "LogCurve.udo"


		instr	1

kf1 init 0         
kf2 init 0       

kk  OSClisten "/logcurve/params", "ff", kf1, kf2

if kk =0 goto ex

kout	LogCurve	kf1, kf2

	printk2	kout

     ex:
		endin

Credits

David Akbari - 2005


Previous Home Next
ExpCurve   deflutter