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
rad(x) : Convert to radians
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
2 Likes

hi, could you help me on what the logic would be in writing a formula device which, say, cycles a LFO 4 times (say, a sinewave) for the length of the pattern. and if the pattern is 512 rows or 4 rows, it will always cycle 4 times.

or even just one time. iā€™d really appreciate it. btw, are you on discord or elsewhere? i really need to get more information and maybe a call.

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)

1 Like

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.

1 Like

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?

1 Like

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.

Did you find out anything new since this post was made?

Iā€™m currently digging into some signal processing stuff and would love to try more things in the Formula device. More examples would be very appreciated, even user made ones.

Anyone?

1 Like

formula device only outputs a modulation signal, at tick rate - afaik. Not usable for audio rate signal processing, unfortunately.

I have a few examples, though. Will post them here shortly. Although Iā€™m sure there are many here in the forum who understand how to utilize the formula device much more deeply than I do
3 sin.xrdp (888 Bytes)
perlin noise.xrdp (2.3 KB)
zen quant.xrdp (1.1 KB)
here are a few examples

3 Likes

thanks, will add them to my formula research folder
i keep meaning to make Paketti address the Formula device but i just havenā€™t had the time because thereā€™s so much other stuff to add :slight_smile:

Thank you very much for the examples!

Iā€™ll study those. Anything is appreciated <3

1 Like

@untilde
so i rescued my formula ā€œmanualā€ and added some of these forum links to it and the krakengore inertial slider and that spring slider someone else made. iā€™m currently trying to see what else could be done and how.
my idea is that these should be stored inside the tool and loaded with a button, and hopefully eventually itā€™ll result in some more ideas.

i still canā€™t seem to do a single thing, like a simple thing, like have A control the bpm for instance.
just so i could understand simple things

it just throws me how i canā€™t for the life of me figure out the simplest things with this. it feels like iā€™m back in 2010 trying to comprehend lua.

the buttons actually type to the formula itself.

hi
so i, while fooling around with making all dialogs close with a specific shortcut, ended up rewriting the formula manual part of Paketti. then i took a look at it and realized it should actually have buttons for writing formulas to the current row). so hereā€™s what i have now:
formuladevice

when you boot up the formula ā€œmanualā€, it will create a formula device if not already there.
iā€™m slowly adding stuff like Inertial Slider and Spring Slider and some formula forum links, with the hopes thisā€™ll kick me into working on this in a better way.

ok, inertial slider + springslider have been formatted to the correct capitalisationā€¦ phew.

itā€™s such a jungle here. textfiles + xml stuff that are old, some are clipboard stuff, some presetā€¦ some doing xdrp stuff, some sharing txt + xml + forum clips.

so iā€¦ letā€™s see.

hereā€™s something then. now i just need to feed @slujr sent xrdps into this and store them as presets and eventually write my own thing.

i wanted to do BPM=BPM+A but it didnā€™t do anything.

ok, letā€™s start with this.
i load this in, and i get:

ok, now what? i read and re-read. ā€œset a value with Input Aā€ ā†’ to me, means, i move the A slider.
if playhead is stopped, itā€™ll output 0, right?
if playhead is playing, itā€™ll output Value of A, right?
butā€¦ where? where does it go? :slight_smile:
ā€¦ EDIT: okay, i get it. if playing, then A goes to ā€œout of formulaā€, aka where the ā€œHelpā€ text ends. i wonder if i could use this to write to the pattern selection or something.

ok, so, in this example, A / B / C are not set to anything, right? so iā€™m guessing i should maybe rename them to or , so people would then not think about that.

actually, this is the first one that definitely utterly makes sense to me. itā€™s a really nice thing!
now, if i wanted to reverse it, would i just go NUMLINES/LINES ?

ok so itā€™s definitely not just switching LINES/NUMLINES and then it goes from max to min (end of pattern).
so looks like, maybe my next question is, @uncle_c - if i wanted to reverse this, what would i do in the formula editor?

@OopsIFly attn

  1. renoise.song isnā€™t available from the formula device. Itā€™s a meta device to control DSP parameters by a formula. The target parameter to control is set under ā€œDest.ā€ (like in all meta devices).
  1. Since the formula should return a normalized value (0-1), reversing the effect of LINE/NUMLINES would be done with 1-LINE/NUMLINES. Example: Instead of returning 0.1 it would then return 0.9 - in effect ā€œreversingā€ the movement of the output.
2 Likes

thanks for the 1-LINE/NUMLINES

that makes total sense. i appreciate it.
how would i then make it ramp down by "4 repeats of the pattern2?

I would do:
1 - LINE * 4 % NUMLINES / NUMLINES

4 being the number of periods per pattern.

@joule
hmm what iā€™m seeing now is that it does 4 repeats of the ramp down by 1 pattern.

butā€¦ what i was looking for, was 4 repeats of the pattern, until the ramp ramps down