## Math function for modular

Device/Module Wishlist

Original topic on PlanetZ: https://forums.scopeusers.com/viewtopic.php?t=16297

####

Posted: Sat Jul 02, 2005 2:17 am
by JLS
Hi all SDK user
Tip for new modules
Basic Math function ( +,-,/,*,sin,cos,tan,lin,exp,..........)
Logical Function ( and,or,xor.......)
More Gate function
For better controling and modulation
( Like Ni Reaktor and Nord Modular )
Very thanks this

####

Posted: Sun Jul 03, 2005 9:39 am
by at0m
There's some basic math modules already, in different forms:
- an adder sums, if you invert one side it will subtract.
- a ringmodulator divides, a divider multiplies (check it out;)
- sine: Flexor's saw2trisin, when it's set to sine, will make a linear signal into sinus, make 90' phase offset and it's a cosinus.
I found some C algo's to make 16bit precision lin/log from 32bit integer, which wasn't really usefull for our purpose. If anyone finds a way to calculate more precise logarithm, we'd be happy to read it - any language would do, as long as it works for integer and not float.
For the gate function, have you tried Flexor's Val Freezer? There's some logic functions in Modular, but they're Gate logic indeed, not the full 'maths' logic. These would be very possible to make IMHO.
A small step forward?

####

Posted: Sun Jul 03, 2005 10:37 am
by JLS
Hi Atom
sorry my very bad english
few experiments:
1. add module 1+1=1 , 1+3=2 ( not working only aproximate function )
2. add module + invertor 10-2=4 ( not working )
3. ring modulator ( only chaotic number )
Sorry NOT WORKING MATH FUNCTION

####

Posted: Mon Jul 04, 2005 12:59 am
by at0m
That's indeed no straightforward maths, but that's how it works. SFP works with a 32bit number, 2^32. -2^31<0<2^31 . To make it more complex, that is not all correct: There is no zero. There is 2^31 negative values, and 2^31 positive values, making for a total 2^32, 32bit, resolution. This makes for one number offset in many situations that will become more clear (and frustrating;) as you play with it and need exact results. Also, on every addition you loose a bit of resolution: 2^31+2^31=2^31 here It's funny maths, that's for sure. But if you get to know it a bit better, it becomes more workeable. You can compensate for it, it will only save some screen space in a patch if made in DP. Modular provides you with the same maths stuff as the SDK or DP. Creating more complex and correct math algorithms is quite difficult. People with experience in that specialised maths area don't come walking up to you everyday, let alone someone that can create atoms/modules for sharc DSP and makes music with it. Or do they?
Check out j9k again too, he made a comparator and a couple other math functions that work with audio signals.
A little bit more explanation on trigonometric functions (from very far down memory lane):
* sin a = cos (a-90')
* tg = sin / cos
These can relatively easy be made with the modules we have. More complex functions can be found on the web for lower bitdepths, as used in mobile telephony or speech analysis/synthesis applications, that info is available online and may give you an impression of the problems working with fixed point binary math.
Maybe ReD_MuZe can create some maths modules for the upcoming Flexor2 pack...
_________________
more has been done with less

####

Posted: Mon Jul 04, 2005 2:41 am
by JLS
Hi Atom
Thanks this very big info
Yes J9k modules very interesting
Flexor 1.5 is mega modular ( i love it )
Little question Flexor 2 release day ?
Thanks Kamil