Welcome to %s forums

BrainModular Users Forum

Login Register

decimal to byte converter

I need help on a Patch
Post Reply
Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 03 Dec 2011, 13:14

Hello,
I'd like to isolate all the button from a hid device.
Made this solution and it work:
Image
BUT the cpu can raise 2.5% !!!
that's too much for a simple A/N converter...

Maybe i've missed an existing module?
Did someone scripted something like that?
Should this topic be moved to 'Suggestions & improvements' (if no better solution)?

Thanks.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 07 Dec 2011, 23:39

note 2.5 percent is relative to global percent, it's not absolute percent, but sure there must be a lighter solution..
some new 'bit operators' exist now in math folder you could check , but i don't have the knowledge on how to use them in that case,
binary is still very abstract for me:p

there is certaily a simpler and lighter script formula as well, but need a 'binary' expert to answer....

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 08 Dec 2011, 11:16

Thanks 23fx23.
So you mean that if i have a 10% global load of CPU, 2.5% in the patch is 0.25% of cpu?
I don't think it can be done with bit operator.
here are two method:
http://www.wikihow.com/Convert-from-Decimal-to-Binary
i did this patch with the second one, will try with the first one but it should be painfull.
I have a friend who is pascal language able, is usine script language exactly the same?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 08 Dec 2011, 11:53

yeah, normally cpu usage work like this.
im not expert in pascal but it seems indeed very close. iwas thinking there was some embeded functions to do this, but maybe not and need to script using one of the two method you mention. i will try to have a look, im interested in that as well, but really no time those days :(

caco
Member
Posts: 306
Contact:

Unread post by caco » 08 Dec 2011, 12:47

Does this do what you want?

download here

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 08 Dec 2011, 19:46

yes caco, that's it, and it's more cpu friendly.
but it can't works due the the fact the array is resized dynamicaly:
the first array value is the last bit, so two solution here:
a static array ( 8 output ( 128 64 32 16 8 4 2 1)) and it'll work,
or inverting the order of the bits ( first array value: first bit) and keep it dynamic.

(bug: noticed that the val0 of the array is always empty).

you should share it as an addon cause it is THE 'hid device' module's decoder.

thanks caco and 23 for the help/support.

Berenice's brother aka fléau.

caco
Member
Posts: 306
Contact:

Unread post by caco » 09 Dec 2011, 12:08

I have fixed a bug in the user module that meant it could add in an extra zero to the output and uploaded the new version as an add-on/

berenice / fléau - The reason for it being dynamic is the size of the ouput will vary based on the input, e.g for an input of 25 the output is 11001 but for 2050 it would be 100000000010. What you could do though is use my user module to get the binary output then use Usine's SwapArray module to invert the order of the bits so the first bit is then stored in the first index of the array which I think may solve your problem :)

Fléau
Member
Posts: 99
Contact:

Unread post by Fléau » 10 Dec 2011, 10:34

Working well now,
the problem with the precedent version was if integer was 128, 64, 32, 16, 8, 4, 2 or 1
the result was the same: a 1 at val1 output and you had to decode it with the array size.

CPU now at 0.02% in the same workspace !
now able to easily make cheap "midi" controller in usine

Nice one caco.

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 10 Dec 2011, 15:09

thanks caco! this can be useful for me too

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

Unread post by senso » 10 Dec 2011, 22:42

congrats caco!!

Post Reply

Who is online

Users browsing this forum: No registered users and 69 guests