Home › Forums › General › Programming › stateData
- This topic has 47 replies, 6 voices, and was last updated 7 years, 11 months ago by Possemo.
-
AuthorPosts
-
January 20, 2015 at 11:21 am #36160
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.
January 20, 2015 at 5:56 pm #36181Ok
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 loadedBut 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
February 9, 2015 at 6:44 pm #37645Hello Atom
Just tried the 5.3.77
restricted instances is still have stateData() not workingI 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 dataWith ctrlr.dll there is no problem
February 11, 2015 at 11:59 am #37756I did a small fix for thix yesterday, check out the next nightly when it comes out, maybe it will fix the isse.
February 12, 2015 at 12:10 am #37803yup !
February 16, 2015 at 3:03 pm #38065Hi
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
March 16, 2015 at 4:47 pm #40591I’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 f7But 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 f7Part1CommonSyx 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?
March 20, 2015 at 2:21 pm #40917Well 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.
March 20, 2015 at 4:29 pm #40933Finlay 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.
April 13, 2015 at 1:01 pm #43673Hi
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 loopBut 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 sureI 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.April 16, 2015 at 11:36 am #43883Anyone oO ?
April 17, 2015 at 4:24 pm #44049The 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.
April 23, 2015 at 7:22 pm #44551Thank 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 getPropertybecause 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.April 23, 2015 at 11:28 pm #44587Ok I get it
Atom this is a powerful function
Thank youAttachments:
You must be logged in to view attached files.November 21, 2015 at 9:08 pm #63553Hi,
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.
November 21, 2015 at 9:46 pm #63559Cannot try it right now, but try with KIPRString=stateData:getPropertyInt(“KIPRenc64”), as you are storing an integer value
November 21, 2015 at 10:50 pm #63566Thanks 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.
November 22, 2015 at 12:22 pm #63609EDIT:
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
April 18, 2016 at 4:46 pm #69048The 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!April 18, 2016 at 5:58 pm #69049Ctrlr: 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.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.