1. First steps in Reaktor Core - Native Instruments
1. First steps in Reaktor Core - Native Instruments
1. First steps in Reaktor Core - Native Instruments
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
9.3. Numerical operations<br />
Float<strong>in</strong>g po<strong>in</strong>t addition, multiplication, subtraction, absolute value, and negation<br />
are generally the least CPU-<strong>in</strong>tensive float operations. Integer addition,<br />
subtraction and negation are the least CPU-<strong>in</strong>tensive <strong>in</strong>teger operations. Integer<br />
absolute value is also more or less OK. DN Cancel currently uses pla<strong>in</strong><br />
addition, as you may remember.<br />
Float division, and <strong>in</strong>teger multiplication and division are significantly more<br />
CPU <strong>in</strong>tensive on average.<br />
It is advisable to group your operations <strong>in</strong> a way that the most CPU <strong>in</strong>tensive<br />
ones get evaluated as rarely as possible. For example, if you need to compute<br />
normalized frequency by divid<strong>in</strong>g the frequency <strong>in</strong> Hz by the sampl<strong>in</strong>g rate it<br />
could be reasonable to compute the reciprocal of the sampl<strong>in</strong>g rate first and<br />
multiply the frequency by the result:<br />
In the above structure, the division will be performed only when the sample<br />
rate changes, which should be pretty rare. Changes to the frequency will trigger<br />
only multiplication.<br />
Compare that to the more straightforward implementation of the same formula:<br />
where the division would be executed <strong>in</strong> response to every change of frequency.<br />
9.4. Conversions between floats and <strong>in</strong>tegers<br />
Generally, avoid all unnecessary conversions between float and <strong>in</strong>teger numbers.<br />
Depend<strong>in</strong>g on the platform such conversions could use significant amounts of<br />
CPU. The conversions that are necessary to do are OK, of course.<br />
Although the follow<strong>in</strong>g structure might work as expected, <strong>in</strong> fact, there are<br />
two unnecessary conversions between <strong>in</strong>teger and float types:<br />
REAKTOR CORE – 141