Page 1 of 1
Posted: 18 Oct 2010, 13:48
by caco
Hello Usiners
I have uploaded a test version of a new user module for doing mathematics with. It is a math expression parser that takes a mathematical formula as an input and calculates it for you. The module also has four user inputs labeled a,b,c,d for your variables so for example you could type in 'a+b/(c-d)' and the module will calculate the result for you. Each time a variable changes the equation is recalculated. Your equation is converted to bytecode so it is pretty efficient calculation as well.
I will do a wiki page once it is working correctly but for the moment you can do most standard math operations (+-/* etc), trigonometry (sin, cos etc), power(^), exponentials (exp) etc etc. You can also access the host samplerate using sr, bloc size using BLOC and use units such as milli (m), micro (u), kilo (k) etc.
There are more examples in the download.
For the moment your equation needs to be formatted correctly so that no whitespace is present in it and no additional lines. If the equation is not recognized then an error message is written in Usine's console output. Let me know if you spot any bugs.
Download here
Posted: 18 Oct 2010, 14:04
by senso
just incredible, will be very useful!
thanks+++
Posted: 18 Oct 2010, 14:10
by nay-seven
impressive ! definitively useful !
a big thanks caco !
Posted: 18 Oct 2010, 14:13
by senso
maybe a wiki with a list predefined constants and functions will be useful?
I know that it's not so funny to create a wiki...
Posted: 18 Oct 2010, 14:23
by caco
A wiki is definitely important and I will write one once module is finished, this is just a test version to check it works nicely for other people first. Is a bit more complicated than I planned so want to check stability first and make sure I have done no mistakes...
Posted: 18 Oct 2010, 14:48
by ethnix73
Yeah!
Thanks a lot...
Can give you a little help for the wiki if you want....
Posted: 18 Oct 2010, 14:56
by bsork
Thanks, Caco! Very useful

Posted: 18 Oct 2010, 15:33
by nay-seven
2 modules VS 6 Modules...you win...

( extract from morphusine addon )
thanks !
Posted: 18 Oct 2010, 16:06
by caco
Awesome, glad to hear it is working okay for people

Posted: 18 Oct 2010, 21:03
by senso
2 modules VS 6 Modules...you win.
yes but we have to test the CPU load and memory.
I think this module is more suitable for special or complex formula's
Posted: 18 Oct 2010, 21:14
by 23fx23
what a clever and useful idea, thanks caco!
woa mean we can even dynamically change formula changing the textfield? with a listbox text out ie.mmm sound awesome...
keep the great work man !
Posted: 18 Oct 2010, 22:28
by Clearscreen
This is great! Thanks for sharing!

Posted: 19 Oct 2010, 09:38
by caco
23fx23 wrote:what a clever and useful idea, thanks caco!
woa mean we can even dynamically change formula changing the textfield? with a listbox text out ie.mmm sound awesome...
keep the great work man !
Yes, I should have added an example of that. For example connect the text output of a combo box into the equation input and add your equations to the combo box as comma text. You can then pick whichever equation you want
senso wrote:yes but we have to test the CPU load and memory.
I think this module is more suitable for special or complex formula's
Yes one equation module probably uses more memory than one standard math module although it is surprisingly light so it may work out lighter once a few math modules are used. It would be interesting to work out at what point it would be better for memory use to use standard modules or my equation module.
CPU load should be pretty good too as your equation gets converted into bytecode and any constants get pre-calculated so only the changes need re-evaluating. Maybe worth doing some comparisons using standard modules and my equation module to test when to use which?
Posted: 22 Oct 2010, 09:33
by caco
Since there have been no bug reports i am presuming equation works okay and have uploaded it the add-on section
I've also added a wiki page
here describing all the functions and constants that Equation currently recognises.
Unfortunately I couldn't add the pow (^) funtion to the wiki page as the wiki thinks the ^ symbol is a table header when I type it in, any wiki experts know how to get around this?
Posted: 22 Oct 2010, 10:23
by woodslanding
wow, this is incredibly useful, thanks!!!
Posted: 22 Oct 2010, 10:47
by senso
yes great job!!
thanks
Posted: 22 Oct 2010, 11:02
by ethnix73
@caco:
i've added the pow function if you want to complete the description.
P.S: for using non-parsed blocks in the wiki, you can usually use the tags code or file, but strangely here it's a better way to use the tag html, from a graphically point of view...
Posted: 22 Oct 2010, 12:17
by caco
Thanks for the wiki help ethnix73, I have updated the Equation's page with the pow description now and also added about Equation writing error messages into Usine's console to warn if your formula contains errors, unrecognized symbols etc.
Posted: 22 Oct 2010, 15:15
by multiphone
Hello Caco,
I really enjoy your new module. I have thought about this log time ago.
I test that with my approach.
Thanks
Posted: 23 Oct 2010, 18:38
by Floego
Hello Caco, I just created the spanish wikihelp of your module.

Posted: 24 Oct 2010, 21:56
by caco
Awesome, thanks Floego

Posted: 26 Oct 2010, 12:56
by ethnix73
caco, a little suggestion:
it seems that your user module adds some latency in comparison with Usine math modules....
For example, using three different A/B modules is calculated faster than your equation module.
Don't know if this is due to the sdk or your module?
Posted: 26 Oct 2010, 13:13
by senso
probably the CallBackType should be set to 'immediate' in the user module?
Posted: 26 Oct 2010, 13:56
by caco
senso wrote:probably the CallBackType should be set to 'immediate' in the user module?
Okay, I have altered the CallBackType to immediate and uploaded the new version, hopefully this should remove the latency as the CallBackType was previously set to 'normal'.
Posted: 31 Oct 2010, 11:51
by ethnix73
Thanks caco, i will test it ....
Posted: 01 Nov 2010, 22:46
by ethnix73
Perfect
Thanks a lot caco...
A really usefull one!
Posted: 17 Nov 2010, 20:16
by ethnix73
Hi caco,
A little request:
Don't know if it would be a lot of work, but could your module be compatible with arrays, like math modules are?
Posted: 18 Nov 2010, 09:32
by caco
ethnix73 wrote:Hi caco,
A little request:
Don't know if it would be a lot of work, but could your module be compatible with arrays, like math modules are?
Not sure, presumably if the math modules can do it and the SDK allows it then it should be possible. I will take a look when I next get some free time for coding

Posted: 11 Sep 2011, 17:37
by Floego
Hello caco,
I have been using your module for quite a while and found interesting the 'if then else' expression for doing iterations and loops. So for people lazy with scripting (like me), the equation module can save the day.
It would be great to show some examples on how to do loops with the module (and keep the intermediate results from showing),
equation really works wonders

Posted: 11 Sep 2011, 23:00
by caco
A good idea Floego, post your examples here everybody and lets see what cool ideas we can come up with
ethnix73 - I am so sorry, I completely forgot about your requests to be able to process arrays, I will dig out my code and take a look at it soon!
Posted: 12 Sep 2011, 02:07
by kloz
can't download... :s
says the link is wrong or outdated !
...peace
Posted: 12 Sep 2011, 03:27
by Floego
kloz wrote:can't download... :s
says the link is wrong or outdated !
...peace
Try to download directly from the Usine browser add-ons

Posted: 12 Sep 2011, 03:28
by Floego
caco wrote:A good idea Floego, post your examples here everybody and lets see what cool ideas we can come up with
ethnix73 - I am so sorry, I completely forgot about your requests to be able to process arrays, I will dig out my code and take a look at it soon!
Ok, I'll post it tomorrow, thanks caco!

Posted: 12 Sep 2011, 08:54
by nay-seven
@Kloz : just tested, works fine here from here and from Usine ?
Posted: 12 Sep 2011, 11:02
by caco
Okay, especially for ethnix73 here is a beta of Equation v1.1 that can take arrays
download
Posted: 12 Sep 2011, 18:24
by kloz
nay-seven wrote:@Kloz : just tested, works fine here from here and from Usine ?
got it now.....thanks !!!
don't know what happened before....maybe firefox going crazy !
Posted: 12 Sep 2011, 18:33
by senso
brilliant!
Posted: 13 Sep 2011, 05:15
by Floego
Ok, I made an example of iteration with the equation module
Iteration with equation module
if anyone can enhance the basic idea, please do so.

Posted: 13 Sep 2011, 09:27
by caco
That is awesome Floego, I had never even thought about using the equation module as a counter like that before. Your idea has so many possibilities for manipulating arrays of data like that, for example my first thought on seeing your patch was that it could be used to create arrays containing waves to be used as LFOs

Posted: 13 Sep 2011, 09:29
by nay-seven
Really cool Floego but don't have always a sine ( if i down and up the fader) and i suppose there's also a refresh issue..?
Posted: 13 Sep 2011, 15:08
by Floego
Thanks
caco! and yes it could be used for creating rather complex waveforms! As I said before, equation is a great module

I have not tested the new version but I will soon.
Thanks
nay!

there are many things that need improving in this example: the refresh issue is caused for the time used for calculating the iteration, I just let the plot to be drawn only once the iteration is completed, but that could be changed. The shape is not always a sine if it doesn't have enough data to make it (lower resolution, low number of sample points). Or maybe are you talking about an error in the iteration?.
I think this module could be connected to the 23fx23 one "array to wavform oscillator" to get a sound output?
Posted: 20 Sep 2011, 21:59
by bsork
Once again: Thanks, Caco! This one has proven to be even more useful than I thought

.
Beside the fact that writing a code snippet is often quicker than adding and connecting modules, it looks like I'm saving a tiny bit of CPU with statements that would otherwise take a handful of modules. My guess is that the fewer callbacks involved is the cause.
And - of course - the patches can look a lot "cleaner" and therefore also easier to maintain.
Posted: 21 Sep 2011, 09:35
by caco
Thanks bsork
For smaller equations Usine's modules will be significantly quicker than the equation module but there is a point where more complex formulas then become quicker with the equation module instead and will possibly use less memory too. For example, on my computer one equation module uses around the same amount of memory as four of Usine's A+B modules.
Posted: 21 Sep 2011, 10:22
by ethnix73
Thanks caco for the last version
