Welcome to %s forums

BrainModular Users Forum

Login Register

Equation user module

Discussions about add-ons, announcements
Post Reply
caco
Member
Posts: 306
Contact:

Unread post by caco » 18 Oct 2010, 13:48

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

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 18 Oct 2010, 14:04

just incredible, will be very useful!
thanks+++

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 18 Oct 2010, 14:10

impressive ! definitively useful !
a big thanks caco !

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 18 Oct 2010, 14:13

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...

caco
Member
Posts: 306
Contact:

Unread post by caco » 18 Oct 2010, 14:23

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...

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 18 Oct 2010, 14:48

Yeah!

Thanks a lot...

Can give you a little help for the wiki if you want....
Seb.Dub

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 18 Oct 2010, 14:56

Thanks, Caco! Very useful :)
Bjørn S

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 18 Oct 2010, 15:33

2 modules VS 6 Modules...you win...:)
Image
( extract from morphusine addon )
thanks !

caco
Member
Posts: 306
Contact:

Unread post by caco » 18 Oct 2010, 16:06

Awesome, glad to hear it is working okay for people :)

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 18 Oct 2010, 21:03

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

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 18 Oct 2010, 21:14

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 !

Clearscreen
Member
Posts: 482
Location: Australia
Contact:

Unread post by Clearscreen » 18 Oct 2010, 22:28

This is great! Thanks for sharing! :D

caco
Member
Posts: 306
Contact:

Unread post by caco » 19 Oct 2010, 09:38

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?

caco
Member
Posts: 306
Contact:

Unread post by caco » 22 Oct 2010, 09:33

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?

woodslanding
Member
Posts: 1327
Contact:

Unread post by woodslanding » 22 Oct 2010, 10:23

wow, this is incredibly useful, thanks!!!
Custom Ryzen 5900x MATX build, Win10, Fireface UFX, touchscreen
Custom 2 manual midi keyboard
Usine, Kontakt, Reaktor, Synthmaster, Byome, Arturia, Soundtoys, Unify

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 22 Oct 2010, 10:47

yes great job!!
thanks

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 22 Oct 2010, 11:02

@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...
Seb.Dub

caco
Member
Posts: 306
Contact:

Unread post by caco » 22 Oct 2010, 12:17

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.

multiphone
Member
Posts: 303
Contact:

Unread post by multiphone » 22 Oct 2010, 15:15

Hello Caco,

I really enjoy your new module. I have thought about this log time ago.

I test that with my approach.

Thanks
HB

Lines / Points / Squares

http://www.hervebirolini.com/

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 23 Oct 2010, 18:38

Hello Caco, I just created the spanish wikihelp of your module. :)

caco
Member
Posts: 306
Contact:

Unread post by caco » 24 Oct 2010, 21:56

Awesome, thanks Floego :)

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 26 Oct 2010, 12:56

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?
Seb.Dub

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 26 Oct 2010, 13:13

probably the CallBackType should be set to 'immediate' in the user module?

caco
Member
Posts: 306
Contact:

Unread post by caco » 26 Oct 2010, 13:56

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'.

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 31 Oct 2010, 11:51

Thanks caco, i will test it ....
Seb.Dub

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 01 Nov 2010, 22:46

Perfect :)

Thanks a lot caco...

A really usefull one!
Seb.Dub

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 17 Nov 2010, 20:16

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?
Seb.Dub

caco
Member
Posts: 306
Contact:

Unread post by caco » 18 Nov 2010, 09:32

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 :)

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 11 Sep 2011, 17:37

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 :cool:

caco
Member
Posts: 306
Contact:

Unread post by caco » 11 Sep 2011, 23:00

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!

kloz
New member
Posts: 6
Contact:

Unread post by kloz » 12 Sep 2011, 02:07

can't download... :s

says the link is wrong or outdated !

...peace

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 12 Sep 2011, 03:27

kloz wrote:can't download... :s

says the link is wrong or outdated !

...peace
Try to download directly from the Usine browser add-ons :)

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 12 Sep 2011, 03:28

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! :)

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 12 Sep 2011, 08:54

@Kloz : just tested, works fine here from here and from Usine ?

caco
Member
Posts: 306
Contact:

Unread post by caco » 12 Sep 2011, 11:02

Okay, especially for ethnix73 here is a beta of Equation v1.1 that can take arrays :)

download

kloz
New member
Posts: 6
Contact:

Unread post by kloz » 12 Sep 2011, 18:24

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 !

User avatar
senso
Site Admin
Posts: 4424
Location: France
Contact:

Unread post by senso » 12 Sep 2011, 18:33

brilliant!

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 13 Sep 2011, 05:15

Ok, I made an example of iteration with the equation module
Iteration with equation module

Image

if anyone can enhance the basic idea, please do so. :)

caco
Member
Posts: 306
Contact:

Unread post by caco » 13 Sep 2011, 09:27

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 :)

User avatar
nay-seven
Site Admin
Posts: 5684
Location: rennes France
Contact:

Unread post by nay-seven » 13 Sep 2011, 09:29

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..?

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 13 Sep 2011, 15:08

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! :cool: 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?

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 20 Sep 2011, 21:59

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.
Bjørn S

caco
Member
Posts: 306
Contact:

Unread post by caco » 21 Sep 2011, 09:35

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.

ethnix73
Member
Posts: 604
Location: France, Caen
Contact:

Unread post by ethnix73 » 21 Sep 2011, 10:22

Thanks caco for the last version :cool:
Seb.Dub

Post Reply

Who is online

Users browsing this forum: No registered users and 106 guests