Help Tried to index memoryblocks..

Home Forums General Programming Help Tried to index memoryblocks..

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #11902
    zeoka
    Participant
      • Topics: 73
      • Replies: 466
      • Total: 539
      • ★★★

      Hi i try to index many memoryblocks to have multiple usages with them
      ( in this case a button to send a midi message)
      – i’ ve a method with sound = print(..
      that gives error : At line[-1]: [C] No such operator defined

      – and other method with sound = …
      that gives error : At line[-1]: [C] std::exception:’unable to make cast’

      i think i’m near but a thing is not correct
      please if anyone see…..

      It’s seems lua editor has a problem with long lines because i can’t see the end of memoryblocs in Bank2()….. may be it is the exception ?
      The script was made in TXT file and pasted in Bank2 because i couldn’t in lua

      • This topic was modified 10 years, 8 months ago by zeoka.
      • This topic was modified 10 years, 8 months ago by zeoka.
      • This topic was modified 10 years, 8 months ago by zeoka.
      Attachments:
      You must be logged in to view attached files.
      #11923
      zeoka
      Participant
        • Topics: 73
        • Replies: 466
        • Total: 539
        • ★★★

        Ok i get it

        mytable = function(mod, value)
        
        send2mem = panel:getModulatorByName("modulator-2")
           sndmp = send2mem:getValue()
        ptchslct = panel:getModulatorByName("modulator-1"):getValue() 
        Bank2()
        
        if sndmp == 1 then 
        bk2 = factory2001[ptchslct + 1]
        -- just a text 
        panel:getLabelComponent("modulator-3"):setText (bk2:toHexString(1))
        -- the midi
        
        m = CtrlrMidiMessage(bk2:toHexString(1))
        panel:sendMidiMessageNow(m)
        
         
        end
        
        end

        but
        i send a full midi message with f0 and f7
        and i need to remove the six first bytes of my messages to replace by variables
        so my question is how to add variables at the begining of “bk2” data ?
        tried :
        bk2full = f0,(bk2),f7
        or
        bk2full = string.format(f0%sf7,bk2)
        m = CtrlrMidiMessage(bk2full:toHexString(1))

        I really can’t figure how to rebuild data….

        #11938
        zeoka
        Participant
          • Topics: 73
          • Replies: 466
          • Total: 539
          • ★★★

          I get it

          mytable = function(mod, value)
          
          send2mem = panel:getModulatorByName("modulator-2")
             sndmp = send2mem:getValue()
          ptchslct = panel:getModulatorByName("modulator-1"):getValue() 
              byte = {}
           byte[1] = 240
           byte[2] = 62
           byte[3] = 16
           byte[4] = 0
           byte[5] = panel:getModulatorByName("modulator-4"):getValue()
           byte[6] = panel:getModulatorByName("modulator-5"):getValue()
           byte[7] = panel:getModulatorByName("modulator-6"):getValue()
               syx = MemoryBlock (byte)
                     Bank2()
          --trigger btn
          if sndmp == 1 then 
               bk2 = factory2001[ptchslct + 1]
           fullmsg = MemoryBlock(string.format("%s %s", syx:toHexString(1),bk2:toHexString(1)))
          -- just a temp text to see 
                     panel:getLabelComponent("modulator-3"):setText(string.format("%s %s", syx:toHexString(1),bk2:toHexString(1)))
          -- the midi
                 m = CtrlrMidiMessage(fullmsg:toHexString(1))
                     panel:sendMidiMessageNow(m)
          end
          
          end

          I ve just copied formula used for text info into a new memoryblock..

          a entire day for that

          #11951
          msepsis
          Participant
            • Topics: 219
            • Replies: 732
            • Total: 951
            • ★★★

            a entire day for that

            yeah those are rough days but they’re usually followed with a lot of things falling into place faster than you had planned… hopefully that’s what you’re experiencing now 🙂

            Stupid question: I notice when you convert to a hex string you’re adding a 1 between the parenthesis.. what’s the difference between:
            (blah:toHexString()) and (blah:toHexString(1))? I don’t think I’ve ever put anything within the “()” when converting like that.

            Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen

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

              It’s a grouping parameter, 1 means one-byte then space, 2 means 2 bytes then space etc.

              #11954
              zeoka
              Participant
                • Topics: 73
                • Replies: 466
                • Total: 539
                • ★★★

                Yes
                Without : this is for a byte
                and with : this is for user data

                I start to like LUA tables i will use them more…
                for receive patch ,save mod to custom Library , send patch properly to synth when ctrlr snapshots change

                msepsis wrote :
                yeah those are rough days but they’re usually followed with a lot of things falling into place faster than you had planned… hopefully that’s what you’re experiencing now 🙂
                Yeah next step is draw and all mouse actions but i have to do a lot before

                • This reply was modified 10 years, 8 months ago by zeoka.
                #11979
                zeoka
                Participant
                  • Topics: 73
                  • Replies: 466
                  • Total: 539
                  • ★★★

                  Hi this is an simple example to have an index variable :

                  bufftype = panel:getModulatorByName(“modulator-5”):getValue()
                  typval = ptchtype:getValue()
                  if typval == 0 then
                  if bufftype == 0 then byte[6] = 48
                  elseif bufftype == 1 then byte[6] = 64
                  elseif bufftype == 2 then byte[6] = 65
                  elseif bufftype == 3 then byte[6] = 66 end
                  elseif typval >= 1 then
                  if bufftype <= 1 then byte[6] = (bufftype *32) + 32 end end end this is the byte 6 of "syx" memoryblock seen above.This script is added to the script above , instead of previous line + to the attached mod The cool thing with tables :it's they can be used several times for multiple purposes. EX in theory the same table can receive a patch from a device and from a file or ctrlr snapshots

                  • This reply was modified 10 years, 8 months ago by zeoka.
                Viewing 7 posts - 1 through 7 (of 7 total)
                • The forum ‘Programming’ is closed to new topics and replies.
                There is currently 0 users and 118 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