solved: Complex expressions variables

Home Forums General Programming solved: Complex expressions variables

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #37720
    GunniKonn
    Participant
      • Topics: 5
      • Replies: 27
      • Total: 32

      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.
      #37724
      dasfaker
      Keymaster
        • Topics: 80
        • Replies: 793
        • Total: 873
        • ★★★

        k0, k1, k2…

        #37738
        GunniKonn
        Participant
          • Topics: 5
          • Replies: 27
          • Total: 32

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

          #37754
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

            I’ll have a check.

            #37762
            atom
            Keymaster
              • Topics: 159
              • Replies: 2945
              • Total: 3104
              • ★★★★★

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

              #37773
              GunniKonn
              Participant
                • Topics: 5
                • Replies: 27
                • Total: 32

                Thank 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.
                #37779
                atom
                Keymaster
                  • Topics: 159
                  • Replies: 2945
                  • Total: 3104
                  • ★★★★★

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

                  #37794
                  GunniKonn
                  Participant
                    • Topics: 5
                    • Replies: 27
                    • Total: 32

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

                    #37839
                    GunniKonn
                    Participant
                      • Topics: 5
                      • Replies: 27
                      • Total: 32

                      I 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.
                      #37870
                      GunniKonn
                      Participant
                        • Topics: 5
                        • Replies: 27
                        • Total: 32

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

                        #37872
                        atom
                        Keymaster
                          • Topics: 159
                          • Replies: 2945
                          • Total: 3104
                          • ★★★★★

                          I uploaded a second nightly yesterday and maybe that helps. In terms of naming there is only k,l,m,n nothing more.

                          #37877
                          GunniKonn
                          Participant
                            • Topics: 5
                            • Replies: 27
                            • Total: 32

                            Great, 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.
                            #37909
                            GunniKonn
                            Participant
                              • Topics: 5
                              • Replies: 27
                              • Total: 32

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

                            Viewing 13 posts - 1 through 13 (of 13 total)
                            • The forum ‘Programming’ is closed to new topics and replies.
                            There is currently 0 users and 54 guests online
                            No users are currently active
                            Forum Statistics
                            Threads: 2,495, Posts: 17,374, Members: 77,605
                            Most users ever online was 12 on January 22, 2019 3:47 pm
                            Ctrlr