Home › Forums › General › Programming › solved: Complex expressions variables
Tagged: complex expressions, global variables, global.k0, split bytes
- This topic has 12 replies, 3 voices, and was last updated 9 years, 2 months ago by GunniKonn.
-
AuthorPosts
-
February 10, 2015 at 10:16 pm #37720
This is the expressionbox expression from the Complex expressions panel:
On1:
setGlobal (0, setBit (global.k0, 4, modulatorValue))
On2:
setGlobal (0, setBit (global.k0, 5, modulatorValue))
This works very well, the modulators modify their own bit as required.
Then I need more variables, and needed to move higher up in the global variables, so I try this:
On1:
setGlobal (10, setBit (global.ka, 4, modulatorValue))
On2:
setGlobal (10, setBit (global.ka, 5, modulatorValue))
At first glance it seems to work, but then I see that the variable is written over, so I never get both bits set at the same time. I wonder if this is because global.ka is wrong syntax?
I have tried global.kA, global 10 without luck, I have tried this too:On1:
setGlobal (16, setBit (global.o0, 4, modulatorValue))
On2:
setGlobal (16, setBit (global.o0, 5, modulatorValue))
same problem, they always write over the entire byte with zero bits and the set their own bit, I only get them to work correctly with global.0 up to global.9.
Please someone help me, I am out of ideas.
I am using CTRLR version 5.3.62
- This topic was modified 9 years, 2 months ago by GunniKonn.
February 10, 2015 at 11:30 pm #37724k0, k1, k2…
February 11, 2015 at 7:51 am #37738Thanks for the reply dasfaker, let me make myself more clear:
k0, k1.. up to k9 are working fine, but then how do we continue counting on through the 64 global variables of the panel? ka? kA? k10? none of these are seem to work correctly.
February 11, 2015 at 11:56 am #37754I’ll have a check.
February 11, 2015 at 1:55 pm #37762Instead of k0 kf etc just use a number, this number is the index of the global variable so anything 0-63 will work, right now that’s how many are used (you can use more but they won’t be remembered).
If you need more let me know.
February 11, 2015 at 5:56 pm #37773Thank you atom, I have allocated 53 global variables so far, one per each byte that shares modulators.
the above solves this case I posted with setting a single bit, unfortunately it does not work with range of bits, which I do like this and it works fine:
setGlobal (7, setBitRangeAsInt (global.k7, 4, 3, modulatorValue))
what the global.k7 does is get the actual value of the variable, and then does the bit set job. This is equivalent to:
setGlobal (7, setBitRangeAsInt (getBitRangeAsInt(global.k7, 0, 8), 4, 3, modulatorValue))
(I verified this to give exactly the same results)
Again this is limited to the range k0 to k9, if I do a getBitRangeAsInt on anything higher (ka, kb, o0, o1, etc., apparently it does not return the value correctly.
See the attached panel for demonstration.Attachments:
You must be logged in to view attached files.February 11, 2015 at 6:24 pm #37779Well i did a small fix, now anything k23 will be interpreted correctly. Just remember that the number after k is a hex number so 23 is decimal 35 f is 16 etc.
February 11, 2015 at 10:29 pm #37794Well i did a small fix, now anything k23 will be interpreted correctly. Just remember that the number after k is a hex number so 23 is decimal 35 f is 16 etc.
Excellent, I will test it on the next nightly win build, no hurry. Thank you for the fast response.
February 12, 2015 at 6:30 pm #37839I just tried this out in the 5.3.82 nightly, now it is only the first variable (k0) that behaves correctly and consequent, the other (k1 and up) do not.
Attachments:
You must be logged in to view attached files.February 13, 2015 at 10:58 am #37870I spent some more time experimenting and strangely, there is some inconsistency, sometimes the getBitRangeAsInt gets value, sometimes nothing, once when I was trying to use ka it consistently returned me the value of k0, maybe I am making it worse when experimenting giving the variables different names?
Are we talking naming them like this?
0 1 2 3... 9 10 11 12.. ..15 16 17 18.... k0 k1 k2 k3.. k9 ka kb kc.. ..ke kf o0 o1.....
or continuing counting on k´s:
k0 k1… .. k29 k30 k31… ?
I was trying both of these but soon it started doing strange behavior, the first clue that it is going bad is the uiLabel box stops responding to the changes.
February 13, 2015 at 11:15 am #37872I uploaded a second nightly yesterday and maybe that helps. In terms of naming there is only k,l,m,n nothing more.
February 13, 2015 at 12:05 pm #37877Great, k,l,m,n! that explains a lot! I was using k,o,p,n that idea I got from the edit sysexformula selection way back and it stuck to my mind.
Attachments:
You must be logged in to view attached files.February 13, 2015 at 10:16 pm #37909I just changed all my o’s and p’s to l and m and started testing, l and m’s were overwriting again, only k worked, then I tried going higher up on the k’s, global k10, and global k3f and these worked perfectly, based on this I assume the entire range of 64 globals is working in the k range, it is easier to handle too, since the global.kx number is just the hex format of the decimal number, very nice and clean in my opinion. Now I will go ahead and apply these all over the panel, thank you for implementing this into the midi message box, it opens for a lot of possibilities.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.