How to Create Memory Block

Home Forums General Programming How to Create Memory Block

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #538
    dasfaker
    Keymaster
      • Topics: 80
      • Replies: 793
      • Total: 873
      • ★★★

      I need to create a Memory Block and pass it a string as data, but it seems that loadFromHexString and append aren’t working.

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

        It should work in a basic way but as usual there were some issues (mostly because i changed the way objects and tables are passed from/to lua). I the next nightly this will work for example:
        [code:3ndddjk1]
        >>> t = {0xff, 0xff, 0xf0}

        >>> tt = CtrlrLuaObjectWrapper(t)

        >>> mb = CtrlrLuaMemoryBlock()

        >>> mb:append(tt)

        >>> console (mb:toHexString(4))
        fffff0
        [/code:3ndddjk1]

        #3786
        Tronic
        Participant
          • Topics: 7
          • Replies: 45
          • Total: 52

          better to use your code?
          I am using this:
          [code:1xii8agf]– Create MemoryBlock
          data = MemoryBlock(0,true)[/code:1xii8agf]

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

            MemoryBlock will not work since the last nightly, u need to use CtrlrLuaMemoryBlock (i need to make the api more consistent in naming scheme).

            You can construct the memory block as you like the 0,true just means the initial size is zero, if you expect a certain size in the future you should pre-allocate that data for better performance, if it will be a 8k block of data do CtrlrLuaMemoryBlock (8192,true) the true,false just means if zero out that memory if you won’t zero it out (the second parameter is false) it will be just some junk from memory in there.

            #3788
            Widy75
            Participant
              • Topics: 10
              • Replies: 61
              • Total: 71

              is there a way to store such a memory block or hex string inside a panel
              and recall them later

              i need this for
              usecase:
              if i press a button i call a function to get all modulators and store the values in the memory block and save the memory block inside the panel
              then i can edit a patch on the synth .. and if i want i can recall the last stored patch. pressing one button to call a function to read out memory block
              and set the value back to the modulators

              also multimode handling of synth even from a single panel could be handled in this way …. just update the active one .. store the others voices in memory blocks and for sending snapshots or on startup jurst read out the right mem blocks stroed with the panels and create the right sysex ( by the most synths just a start pattern and the data blocks for each voice ) …..

              panel:setGlobalVariable only works with index and a value as int… is there a way to handle a array as value or a memory block.
              i also try modulator:getProperty to filter out only modulators which sending modulatorExcludeFromSnapshot … but this also wont work .. or im doing it in the wrong way <img decoding=” title=”Smile” />

              lg widy

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

                You can set any property that’s not a property defined in ctrlr and it will be saved with the panel (or a modulator), you can do
                [code:3jklti8w]
                panel:setProperty ("myVeryCustomProperty", "my even more custom piece of data")
                [/code:3jklti8w]
                it will be saved with the panel and you can re-read it, just remember it’s only strings/ints/bools so convert your memory blocks to a hex string (i forgot to add base64 encoding but hexString should be enough)

                #3790
                Widy75
                Participant
                  • Topics: 10
                  • Replies: 61
                  • Total: 71

                  hm <img decoding=” title=”Smile” />

                  tried build 920 .. mem block seems to work
                  but if i call setProperty i got an error
                  Callback Error myMethod … attempt to call methods setProperty (a nil value)

                  myMethod is called by a button pressed
                  [code:15e4pbex]
                  myMethod = function(modulator, newValue)
                  console("called")
                  modulator:getVstIndex() –working
                  panel:getNumModulators() –working
                  modulator:setProperty("myVeryCustomProperty", "my even more custom piece of data",false) –not working
                  panel:setProperty("myVeryCustomProperty", "my even more custom piece of data") –not working

                  my_property = "myCusomProperty"
                  my_value = "simple string"
                  console(string.format("Property:%s , Value:%s",my_property,my_value))
                  panel:setProperty(my_property,my_value) –not working
                  end
                  [/code:15e4pbex]

                  hm i did it in the wrong way or the method are not exported

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

                    setPropertyString or setPropertyInt i wrote just an idea not actual code, sorry

                    #3792
                    Widy75
                    Participant
                      • Topics: 10
                      • Replies: 61
                      • Total: 71

                      ah thx working .. nice <img decoding=” title=”Smile” />
                      lg widy

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • The forum ‘Programming’ is closed to new topics and replies.
                    There is currently 0 users and 79 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