stateData

Home Forums General Programming stateData

Viewing 20 posts - 21 through 40 (of 48 total)
  • Author
    Posts
  • #36160
    atom
    Keymaster
      • Topics: 159
      • Replies: 2945
      • Total: 3104
      • ★★★★★

      This feature is in all types that Ctrlr supports, if there is some different behavior you need to let me know what exactly is different and i’ll have a look.

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

        Ok
        I open ctrlr in maschine 2.2
        I load the panel
        I’ve my uiLabel with “SDFG” text and a “global data” custom comp that is “attached” to another uiLabel to memorise,update and load global data.

        I save it in maschine instrument format

        Then I rename “SDFG2” , change “global volume” so that change the “global hex “uiLabel and save it in maschine format

        Now I can load maschine instrument presets and that works fine
        (name of program and global setting are loaded,panels are not reloaded multiple times )
        EXCEPT for the midi ports (I’ve set them to none) so I don’t have error now
        but that means set the midi ports each time presets are loaded

        But The main problem is all the state data doesn’t work in instances

        always the first state (when instance is done) is loaded
        whatever maschine instruments (with differents prog names and global settings) I save….

        I precise I’ve also a uiLabel that “returns” the 2 statedata var() to see what happens. Ctrlr 5.3.57

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

          Hello Atom

          Just tried the 5.3.77
          restricted instances is still have stateData() not working

          I think (my 2 cents theory) some codes are not here(the save option is not there on
          the window bar menu so i think codes attached are not there) and nothing happen
          the maschine file doesn’t take the data

          With ctrlr.dll there is no problem

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

            I did a small fix for thix yesterday, check out the next nightly when it comes out, maybe it will fix the isse.

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

              yup !

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

                Hi
                This is working fully now !

                The maschine file is always 14 kb , the data is not uptated in my UIlabel that monitors the state data but this is working now. I can remove it now

                Thank you

                #40591
                dasfaker
                Keymaster
                  • Topics: 80
                  • Replies: 793
                  • Total: 873
                  • ★★★

                  I’m facing a strange problem passing data from StateData to memory blocks.

                  In the console I put the following code:

                  Part1CommonSyx:loadFromHexString(myStateData:getProperty("Part1Common"))
                  console(Part1CommonSyx:toHexString(1))
                  Part2CommonSyx:loadFromHexString(myStateData:getProperty("Part2Common"))
                  console(Part2CommonSyx:toHexString(1))
                  Part3CommonSyx:loadFromHexString(myStateData:getProperty("Part3Common"))
                  console(Part2CommonSyx:toHexString(1))

                  and I get the correct result:
                  f0 41 10 6a 12 01 00 10 00 01 00 00 03 06 08 7f 40 38 f7
                  f0 41 10 6a 12 01 00 11 00 01 01 00 04 01 00 7f 40 76 f7
                  f0 41 10 6a 12 01 00 12 00 01 00 00 01 01 00 40 40 13 f7

                  But if I print again the two memoryBlocks, now the result is this:

                  console(Part1CommonSyx:toHexString(1))
                  console(Part2CommonSyx:toHexString(1))
                  console(Part3CommonSyx:toHexString(1))

                  f0 41 10 6a 12 01 00 12 00 01 00 00 01 01 00 40 40 13 f7
                  f0 41 10 6a 12 01 00 12 00 01 00 00 01 01 00 40 40 13 f7
                  f0 41 10 6a 12 01 00 12 00 01 00 00 01 01 00 40 40 13 f7

                  Part1CommonSyx and Part2CommonSyx are now equal to Part3CommonSyx. For some reason, the last string assigned to the last memoryBlock is assigned to the first and second memoryBlock.

                  Any idea of what’s going on?

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

                    Well for start:
                    Part3CommonSyx:loadFromHexString(myStateData:getProperty(“Part3Common”))
                    console(Part2CommonSyx:toHexString(1))

                    you are writing to Part3CommonSyx and printing Part2CommonSyx.

                    Also i don’t see how the data can be altered on it’s own, unless your lua code modifies those parts of memory somehow and during the time you print them something changes this memory segments.

                    #40933
                    dasfaker
                    Keymaster
                      • Topics: 80
                      • Replies: 793
                      • Total: 873
                      • ★★★

                      Finlay solved the issue (forgot to post it here). The above had a typo.

                      I was wrongly assuming that loadFromHexString was replacing the existing data in the MemoryBlocks, but in reality it was adding data at the end, leaving the existing data unaltered. I just needed to initialize the MB before loading the string to get the expected values.

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

                        Hi
                        I would create a node per property then I could call them by index and name the prop
                        string.format(“%x”,myvalue) ,that way I never need to call a name and I can do a loop

                        But not sure about property
                        I started something but it seems I’m wrong
                        I believe the node name and the property name is the same but not sure

                        I added after “SINGLE” identifier as ctrlr wants an extra value
                        The formula in not the same in juce
                        edit:
                        I’ve done :

                        myMethod = function(stateData)
                        stateData:addChild("SINGLE",0,nil)
                        stateData:addChild("MULTI",1,nil)
                        
                         for r = 0,47 
                          do if r <= 3 
                             or r >= 16
                           then s = string.format("Buffer%x",r)
                                stateData:getChild(0):addChild(s,r,nil)
                                t =  stateData:getChild(0):getChild(r)
                                t:setProperty(s,string.format("Hello%x",r),nil) 
                            end
                         end
                         for r = 0,47 
                          do s = string.format("Buffer%x",r)
                             stateData:getChild(1):addChild(s,r,nil)
                             t =  stateData:getChild(1):getChild(r)
                             t:setProperty(s,string.format("Hello%x",r),nil) 
                         end
                        
                        end

                        but still the same error

                        • This reply was modified 9 years ago by zeoka.
                        Attachments:
                        You must be logged in to view attached files.
                        #43883
                        zeoka
                        Participant
                          • Topics: 73
                          • Replies: 466
                          • Total: 539
                          • ★★★

                          Anyone oO ?

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

                            The first argument in this error message is an indication of the type it’s executed on (something like “this” parameter, you don’t pass it in, it’s already there).

                            You should do something like

                            parent = ValueTree("parent")
                            parent:setProperty ("parent_property_name", "value", nil)
                            child = ValueTree("child")
                            child:setProperty ("childs_property_name", "value", nil)
                            parent:addChild (child, -1, nil)
                            xml = parent:createXml()
                            console (xml:createDocument("", false, false, "", 0))

                            -1 means just append the next node, i wouldn’t attempt to index those nodes without further reading and testing this, i don’t know what happens when you remove them and add new ones, there are some JUCE internals that i don’t know that could mangle those numbers for you.

                            make sure you know what you are doing.

                            • This reply was modified 9 years ago by atom.
                            #44551
                            zeoka
                            Participant
                              • Topics: 73
                              • Replies: 466
                              • Total: 539
                              • ★★★

                              Thank you
                              I get the structure , a node is not automatically a value tree , that was wrong to believe that Now I would add more nodes but I am getting wrong with getProperty

                              because the var() returned or inserted by setProperty() prefer so much to be a string ! impossible to get the property value if it is a memoryblock

                              in the picture k is nil if the value is in memoryblock form but a string only
                              MySingle[?] are valid memoryblocks
                              what I’m missing ?

                              Attachments:
                              You must be logged in to view attached files.
                              #44587
                              zeoka
                              Participant
                                • Topics: 73
                                • Replies: 466
                                • Total: 539
                                • ★★★

                                Ok I get it
                                Atom this is a powerful function
                                Thank you

                                Attachments:
                                You must be logged in to view attached files.
                                #63553
                                daimondamps
                                Participant
                                  • Topics: 8
                                  • Replies: 80
                                  • Total: 88

                                  Hi,
                                  maybe you can help me with this?
                                  I’m trying to save state data with a example script(called when DAW save state):

                                  KIPRString=""
                                  SaveStateData = function(stateData)
                                  
                                  stateData:setProperty("KIPRenc64", 1234, nil)
                                  end

                                  Script for loading data:

                                  function LoadStateData(stateData)
                                  
                                  KIPRString=stateData:getProperty("KIPRenc64")
                                  
                                  end

                                  And it is working.
                                  But when I close and reopen the panel I have following error (and the method is disabled):
                                  What: C
                                  Namewhat: method
                                  Name: setProperty
                                  Error message: No matching overload found, candidates:
                                  void setProperty(CtrlrLuaObject&,Identifier const&,var const&,bool)
                                  At line [-1]: [C]

                                  Ctrlr debug log
                                  Log started: 21 Nov 2015 9:15:23pm
                                  
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_base
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_table
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_string
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_math
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_io
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_debug
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_package
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_os
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_bit
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luaopen_usb
                                  [INFO    ][21:15:23:000193]: CtrlrLuaManager::createLuaState luabind open
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaState luabind bind_class_info
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_base
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_table
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_string
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_math
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_debug
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_package
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luaopen_bit
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luabind open luaStateAudio
                                  [INFO    ][21:15:23:000194]: CtrlrLuaManager::createLuaStateAudio luabind bind_class_info luaStateAudio
                                  [INFO    ][21:15:23:000203]: CtrlrLuaManager::ctor create debugger
                                  [INFO    ][21:15:23:000447]: CtrlrLuaMethodManager::call Loader
                                  [INFO    ][21:15:23:000451]: CtrlrLuaMethodManager::call LoadStateData
                                  [INFO    ][21:15:23:000452]: CtrlrLuaMethodManager::call SaveStateData
                                  [LUA ERR ][21:15:25:000055]: Callback error: [SaveStateData] 
                                  At line [-1]: [C]
                                  What: C
                                  Namewhat: method
                                  Name: setProperty
                                  Error message: No matching overload found, candidates:
                                  void setProperty(CtrlrLuaObject&,Identifier const&,var const&,bool) 
                                  At line [-1]: [C]
                                  What: C
                                  Namewhat: method
                                  Name: setProperty
                                  Error message: No matching overload found, candidates:
                                  void setProperty(CtrlrLuaObject&,Identifier const&,var const&,bool).
                                  Method disabled
                                  [INFO    ][21:15:25:000055]: CtrlrLuaMethodManager::call ExportKIPRfile
                                  [WARN    ][21:15:27:000208]: CtrlrPanelMIDIInputThread::run stopping
                                  [WARN    ][21:15:27:000707]: CtrlrPanelMIDIInputThread::run stopping
                                  
                                  

                                  Any idea whats wrong?

                                  • This reply was modified 8 years, 5 months ago by daimondamps.
                                  • This reply was modified 8 years, 5 months ago by daimondamps.
                                  #63559
                                  dasfaker
                                  Keymaster
                                    • Topics: 80
                                    • Replies: 793
                                    • Total: 873
                                    • ★★★

                                    Cannot try it right now, but try with KIPRString=stateData:getPropertyInt(“KIPRenc64”), as you are storing an integer value

                                    #63566
                                    daimondamps
                                    Participant
                                      • Topics: 8
                                      • Replies: 80
                                      • Total: 88

                                      Thanks dasfaker, but getPropertyInt not working.
                                      Besides SaveStateData method is disabled when panel is loading.
                                      I’ve tried to use string to store but with the same error.

                                      SaveStateData = function(stateData)
                                      
                                      stateData:setProperty("KIPRenc64", "StringToStore", nil)
                                      end

                                      I’ve tried what(stateData) in console and it gives me :

                                      >>> what(stateData)
                                      Object type [nil]
                                      -----------------------------------------------------------------
                                      
                                      Members:
                                      
                                      Attributes:
                                      
                                      -----------------------------------------------------------------
                                      
                                      • This reply was modified 8 years, 5 months ago by daimondamps.
                                      #63609
                                      daimondamps
                                      Participant
                                        • Topics: 8
                                        • Replies: 80
                                        • Total: 88

                                        EDIT:
                                        I’ve renamed (removed and created again) my SaveStateData(stateData) to savedata(stateData)
                                        and now is working 🙂
                                        Something must went wrong with name SaveStateData for the method.

                                        Sometimes I just need to sleep with the problem to solve it:D

                                        #69048
                                        goodweather
                                        Participant
                                          • Topics: 45
                                          • Replies: 550
                                          • Total: 595
                                          • ★★★

                                          The panel tree is not flushed to disk with every save, it’s only updated in memory, if you want to flush it to disk you do save ctrlr state (this is the equivalent of saving your project when host ctrlr as a VST). This is done for performance reasons.

                                          Hi Atom and dasfaker,
                                          can we be more precise here?
                                          Let’s imagine we have a user of a panel and the developer has foreseen a way to store some key values (last used sound and bank for example) in statedata.
                                          What should the programmer do (what to write and where) to secure that this data is saved when the user close the panel or quit Ctrlr and what should the programmer do to secure that this is loaded into variables and that the variables containing the key values can be used at panel opening.
                                          I think that with that precision, the statedata read/write will be better understood.
                                          Thx to both!

                                          #69049
                                          dasfaker
                                          Keymaster
                                            • Topics: 80
                                            • Replies: 793
                                            • Total: 873
                                            • ★★★

                                            Ctrlr: Closing the panel don’t save the stateData. You should do Ctrl+Alt+S (save Ctrlr state) or close Ctrlr with the panel opened to save stateData

                                            Exported Instance Standalone: Closing the instance saves stateData

                                            Exported Instance VST: Saving the DAW project save the stateData.

                                            The state of every modulator is saved in those cases. If you need to store other data (memoryBlocks, variables…) you need to use “Called when Ctrlr state is saved” to store data and “Called when Ctrlr is loaded” to retrieve data.

                                            • This reply was modified 8 years ago by dasfaker.
                                          Viewing 20 posts - 21 through 40 (of 48 total)
                                          • The forum ‘Programming’ is closed to new topics and replies.
                                          There is currently 0 users and 119 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