# What Is The Formula Device?

please could someone explain what the formula device is, what it does, and why people are so intrigued by it and what they hope to accomplish with it?

please dont ive “yes well you just a+b+x ! see how cool!” , i dont know what a b and x are! (except letters etc, but let’s just not go there!)
actual real-life examples would be nice

Edit: Added the Kazakore Formula Device empty thingo as a spoiler, so one doesn’t need to hunt around the forum to find it…

[details=“Click to view contents”]<?xml version="1.0" encoding="UTF-8"?>

true

false

Init

false

true

Mixer

0.5

Device only

1.0

Device only

0.0

Device only

0.5

Device only

1.0

Device only

true

true

true

Init

true

true

A

B

C

true

1

0.0

Device only

0.0

Device only

0.0

Device only

-1

Device only

-1

Device only

-1

Device only

[/details]

Did you see the tiny “?” button top right? Click it as a start, this will show you the built in variables.

Edit: Sry, no real-life examples, I didn’t do much with it, but it’s just a little bit of programming – I know you can do that! yep. but what do they mean.
i recognize some of the lua api transport functions (playing, samplerate, etc).

``````--[[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

``````

im not much of a meta device user so, i just dont actually understand what this is supposed to route and from where to where (i’m fairly sure i comprehended correctly that there can be 3 inputs. inputs of what? who? where?? audio inputs? in-coming data from a separate meta device?)

Yes exactly, routed in from other meta devices, and the output is whatever the formula evaluates to. Just route it somewhere else with the “Dest.” thingy.
You can define custom functions by clicking on “User”.

I heard it’s a bit of LUA, but I don’t think you may use the API from that device. (But don’t know exactly)

I found those useful for doing things depending on where you are in the pattern, song, etc.:

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

So… the current (hidden) Formula Device could be usd to route a LFO to the LPB or the BPM?
so one could modulate them with an lfo?
how would that be done?

Short story. I tried the formula device once. It crashed renoise. I never dared trying it again.

I think Jonas reported some of the bugs with it and some of them were fixed. Not sure if they got fixed for 2.7.2…
Anyway,

the formula device is still classed by the devs as ‘highly alpha and experimental’. so there is reasonable probability it will crash your Renoise. that means you should avoid using it in any worthwhile track for the moment.
for some real-life experiences with the device in actual attempts at making tracks, check out the DDRC 23: https://forum.renoise.com/t/dead-dog-renoise-competition-round-23/33843

hmm, went through this 2 page thread and i’m none the wiser.’

putting an A into the Formula portion, and binding the formula device to trackvolpan’s Vol, then moving A seems to control the volume.

but are BPM/LPB read-only, i.e. only accessible as numbers? Or could A be made to control BPM?

Cool… About a little bit of programming, I do see the User there and one could write to that… if one knew what to write.
So far it seems that the formula device does not directly have access to the transport ( LPB / BPM ), or if it does, it’s not dead-obvious (=obvious enough) to me.
This would be really swell for controlling an arpeggiator metadevice’s parameters tho.

sorry, meant ‘actual attempts at making tracks’, not ‘threads’. bit tired i suppose. editted the post.

what i meant was not so much that that thread shows you examples of formulas, but rather examples of experiences with usage of the device itself. in other words, it was an attempt to underline my comment on the alpha-ness of the device by providing you with a thread of people trying to use it in tracks and failing because of crashes etc.

i don’t have any real-life examples of formulas etc for the device because i suck at math and therefore have trouble making something proper with that device.

Don’t think so. All you can do is route the result of the formula to some other DSP chain device.

Maybe some interesting thing to do with it is complex automations over a longer time period, without writing down automation explicitely in the Automation tab.

You can create something of a kin to automation lanes or LFOs by entering formulas, with three controllable variables (A, B & C) a lot of built in functions and variables (pattern/song postistion etc) and more programmable via LUA.

So you could use it to create a simple automation that builds through an entire track with a few simple commands or use it to completely mash and modulate something by combing say a signal follower with trigonometric functions and much more.

Is there any possibility to directly address the audio stream with the math device, for example for programming a little synth?

maybe through a workaround using the dc offset device?

Hm, but what about also reading the audio stream, for example for processing it with some dsp math?

Is the formula device script based or compiled c++?

The formula device is a native C++ compiled device, so there is not much that can be tweaked outside the core dev-circle here.

Thanks for the info, I just asking because of theoretical performance of the formula device. So it would be theoretically possible to manipulate the audio stream with it… the formula device embed a stripped down lua interpreter so what you actually see there is plain lua. in fact in the user tab you can define your own lua functions and initializations, to be used in the formula itself.

i will soon collect some useful recipes i have here to explain its use cases.