User-Defined Opcode Database

gainslider

Logarithmic gain slider

Download UDO File

Description

This opcode implements a logarithmic gain curve which is based on the gainslider~ object from Cycling 74 Max / MSP.

Syntax

kout gainslider kin

Performance

kin -- expected range from 0-152. A range from 0-127 will give you a range of -inf to -0.0 dB. A range of 0-152 will give you a range from -inf to +18.0 dB.

kout -- scaled output.

Code

		opcode	gainslider, k, k
kin	xin

kout	=	(0.000145 * exp(kin * 0.06907))

	xout	kout

		endop

Examples

		instr	1 ; midi controlled gain slider of realtime input

kvol	ctrl7	1, 7, 0, 127
kgs  gainslider  kvol

ain	in

aout	=	ain * kgs

	out	aout

		endin

Credits

David Akbari, 2005


Previous Home Next
flip   ExpCurve