Page 1 of 1
Any way to get Sin or other math function?
Posted: Mon Jun 23, 2008 10:34 am
by Neutron
i just want to get a sin function with the simple math operators? or maybe with the FM operator.
i aint no math genius, but i think it might be possible.
Posted: Mon Jun 23, 2008 12:22 pm
by Warp69
You could use polynomial approximation, like taylor series :
sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! - ...................................
You could optimize the coefficients with the Remez/Remes exchange algorithm - you will then get :
sin((pi/2)*x) = 1.5707963268 * x - 0.6459640619 * x^3 + 0.0796915849 * x^5 - 0.0046768800 * x^7 + 0.0001530302 * x^9
Remeber that x have the following range [-1 ; 1]
Or
Use the "fx LFO" module with the following parameters :
f = 0
Sel = 0
Gain = Max (2147483647)
WF = 1
RC = 3
RC = 3
P1 = Variable [-2147483647 ; 2147483647]
P2 = Same as the above
P1 = x, out1 = sin(x)
I used the above for the calculation of the width parameter in my reverbs.
Cheers
Posted: Mon Jun 23, 2008 12:37 pm
by Neutron
wow that LFO method looks great! i will try that tonight
thank you very much!
Posted: Mon Jun 23, 2008 12:43 pm
by Warp69
I was hoping you would use the correct solution i.e. polynomial approximation and not the dirty LFO trick...............................
Cheers
Posted: Mon Jun 23, 2008 12:56 pm
by Neutron
Using a dirty hack of an existing device IS the "proper way"

if it responds fast enough anyways. otherwise i might have no choice.
Posted: Mon Jun 23, 2008 2:23 pm
by hifiboom
polynomial approximation
quite dsp heavy, isn`t it?
it would be cool to have a realtime interpolated table and a SC SDK table tool to generate tables for different functions.
Posted: Mon Jun 23, 2008 6:10 pm
by Neutron
well that idea didnt work. i need to be able to input the signal i want to do the math on in realtime, and that only works with async.
yes a lookup table would be a great atom, as would "opamp", "resistor" and "capacitor" to go with "diode"
when im feeling a bit smarter maybe ill try that polynomial approximation. but i think it would be a mess.
Posted: Tue Jun 24, 2008 1:24 am
by Warp69
Neutron wrote:well that idea didnt work. i need to be able to input the signal i want to do the math on in realtime, and that only works with async.
Well it updates for every 14 samples.
If you need sample based calculation then polynomial approximation is the right solution.
Neutron wrote:when im feeling a bit smarter maybe ill try that polynomial approximation. but i think it would be a mess.
Someone is apparently lazy, eh?
Here's an example of a polynomial approximation :
www.relab.dk/Sin.rar
I dont know what you need it for or the range of the parameters. Try connect the module to the Raw Tri osc and see the behaviour of the module.
Cheers
Posted: Tue Jun 24, 2008 6:11 am
by Neutron
I just would like to understand how it works. i have been reading about them, and it seems like quite a few other functions could be made with polynomial approximations, as long as the DSP use is ok. ill have a look tonight thanks!
Posted: Tue Jun 24, 2008 7:38 am
by hifiboom
yes a lookup table would be a great atom
something I really really miss in sdk. (sync lookup table )
there is the waveshaper atom, but it just has 128 entries and is not really highest quality.
Posted: Tue Jun 24, 2008 5:31 pm
by Neutron
This is great!
The wave made by "approximation" looks a lot better than i thought it would after reading about that method.
Tests so far indicate it will work for what i want to do do!