Math Metadevice

I’ve asked for this before, but I only think it’s fair, now that we can do proper math in the modulation panel, that we should be able to do it in effect chains. Any chance we can see this for 3.0 final? This seems like it should be dead easy. This is really important for Doofer madness, guys ;)

like the formula device? :)

Where is this formula device you speak of? :o

It is still hidden by default and needs to be unlocked though wizardry, but the might Kraken once made an inertia device with it;

<?xml version="1.0" encoding="UTF-8"?>  
<filterdeviceclipboard doc_version="0"><br>
  <deviceslot type="FormulaMetaDevice"><br>
    <customdevicename>Inertial Slider</customdevicename><br>
      <formulaparagraph>OUTPUT - (OUTPUT - A) * power_inertia(B, 0.025, 0.5)</formulaparagraph><br>
      <functionsparagraph>function power_inertia(inertia, min, max)</functionsparagraph><br>
      <functionsparagraph> inertia = 1.0 - inertia</functionsparagraph><br>
      <functionsparagraph> inertia = inertia * inertia * inertia</functionsparagraph><br>
      <functionsparagraph> return min + inertia * (max - min)</functionsparagraph><br>
      <visualization>Device only</visualization><br>
      <visualization>Device only</visualization><br>
      <visualization>Device only</visualization><br>
      <visualization>Device only</visualization><br>
      <visualization>Device only</visualization><br>
      <visualization>Device only</visualization><br>

Paste in your chain of choice to make it work, click the expandable icon in the bottom right for more info, insert your own stuff.

 <?xml version="1.0" encoding="UTF-8"?>  
<filterdeviceclipboard doc_version="0"><br>
  <deviceslot type="FormulaMetaDevice"><br>

Holy crap I found it… why on earth isn’t this in the metadevice list?

Because it was never officially finished. It’s still very much an experimental device that’s prone to making the universe implode (maybe).

I’m presuming it doesn’t have access to the internal Renoise variables and such?

It has access to a few useful properties from the transport and current pattern, but otherwise it’s a self-contained environment with no knowledge of the rest of the song structure.

Taken from the device’s [?] help:

--[[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  
 OUTPUT : Output parameter from previous run  
--[[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  

I think it is better to list the situations where it will crash Renoise.
Perhaps there is a visible pattern in that so the device can be stabilized and thus made official.

I’m sure a divide by zero will crash ;) … in all honesty, can’t you just sloppily catch errors from this device and ignore them, passing on whatever the previous output value was (or, if there is none, 0)?