Page 1 of 1
Posted: 03 Dec 2011, 13:14
by Fléau
Hello,
I'd like to isolate all the button from a hid device.
Made this solution and it work:

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.
Posted: 07 Dec 2011, 23:39
by 23fx23
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....
Posted: 08 Dec 2011, 11:16
by Fléau
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?
Posted: 08 Dec 2011, 11:53
by 23fx23
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

Posted: 08 Dec 2011, 12:47
by caco
Does this do what you want?
download here
Posted: 08 Dec 2011, 19:46
by Fléau
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.
Posted: 09 Dec 2011, 12:08
by caco
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

Posted: 10 Dec 2011, 10:34
by Fléau
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.
Posted: 10 Dec 2011, 15:09
by 23fx23
thanks caco! this can be useful for me too
Posted: 10 Dec 2011, 22:42
by senso
congrats caco!!