# Formula documentation?

Is there a formula documentation that is more complete than this?

``````--[[ Input variables ---------------- ]]--
A : First input parameter [0..1]
B : Second input parameter [0..1]
C : Third input parameter [0..1]
--
--[[ Math constants ----------------- ]]--
PI : Pi constant
TWOPI : Two Pi constant
INF : Plus infinity (huge number)
--
--[[ Musical variables -------------- ]]--
SRATE : Actual sampling rate
BEATS : Current position in beats
SAMPLES : Current position in samples
PLAYING : Play or stopped
BPM : Beats per minute
LPB : Lines per beat
TPL : Ticks per line
SPL : Samples per line
LINE : Line number in current pattern (integer)
LINEF : Line number in current pattern (fractional)
NUMLINES : Number of lines in current pattern
TICK : Tick number in current line
TICKCOUNTER : Absolute tick count
SEQPOS : Current pattern index in sequencer
--
--[[ Functions ---------------------- ]]--
abs(x) : Absolute value
acos(x) : Arc cosine
asin(x) : Arc sine
atan(x) : Arc tangent
ceil(x) : Round number to ceil
cos(x) : Cosine
cosh(x) : Hyperbolic cosine
deg(x) : Convert to degrees
exp(x) : Exponential (e^x)
floor(x) : Round number to floor
fmod(x) : Modulo operator for float numbers
frexp(x) : Split value in fraction and exponent
ldexp(x) : Float representation for a normalised number
lin2db(x): Convert a 0..1 number to its decibel value
db2lin(x): Convert a decibel value to its 0..1 normalised value
log(x) : Natural logarithm of a number
log10(x) : Logarithm base 10 of a number
max(a, b [, c[, ...]]) : Maximum of two or more numbers
min(a, b [, c[, ...]]) : Minimum of two or more numbers
mod(x) : Modulo operator
modf(x) : Integral and fractional parts of a number
pow(x, n): Nth power of x
random([a [, b [, c]]]) : Random value
randomseed(x): Seed the random number generator
sin(x) : Sine
sinh(x) : Hyperbolic sine
sqrt(x) : Square root
tan(x) : Tangent
tanh(x) : Hyperbolic tangent
``````

What else do you need?

i was thinking it might be possible for there to be more documentation and since my textfile is from 2009 or 2011, maybe there had been more examples added, or more definitions added.
i am trying to go through the posts that mention formulas, to find out examples, etc, but so far no go. especially since the amount of presets for the formula device is severely limited:

ok, hereâ€™s what i had, and hereâ€™s what the â€śHelpâ€ť documentation gave, diff (left = old, right = new)

Hey there!

I believe renoise scripting (and thus also the formula device) operate on the programming languange lua 5.1.

So any tutorial that teaches you correct lua 5.1, like those on www.lua.org, will help you learning how to code for the device. Just on the formula device you have no libraries other than unprefixed math and the internal variables in the help window.

The formula device itself works likeâ€¦first the whole code window is executed once, and all variables and functions are read. Then for each tick in song the formula paragraph is called to produce the (0â€¦1) result value of the formula paragraph. You can call functions and use variables from the code paragraph in the formula, that is the meaning of the bigger code window. The A,B and C parameters are the three input sliders, with these you can control your formulas. All code is just lua code, and you can test the code i.e. in scripting terminal or another lua environment, you just need to wrap your functions like math etc. to test your code and simulate inputs. Thatâ€™s the only way to debug your code btw, I hope this gets better in future.

Thatâ€™s about it. Iâ€™m a formula device nerd and love using it and writing code for it, if you have any questions, send me some message, Iâ€™m always glad to help when itâ€™s okay when my code is shared with others.

Can the formula device apply slight modulation to a sinusoidal LFO, imprinting (for want of a better word) a random lfo to have a â€śnoisyâ€ť sinusoidal modulation signal output? Im interested in long, slow â€śanalogâ€ť modulation of a source for example - like semi predictable, noisy drift as one example? I know we cant do audio rate but is that possible? Or would i be better off with the meta mixer?

Yes, definitely you can program that. You can just use a sine wave and add another noise drift generator on top of it - it can calculate tick by tick, and if you want it to be precise you can measure the current tick to calculate the data right. You can code any lua algorithm to drive your LFO! And youâ€™re right, to fake such a thing you can also try to use LFO and meta mixer with another noise LFO.

1 Like

Thanks for the reply. Time to learn my first ever line of Lua lol.