Home › Forums › General › Programming › How to Create Memory Block
- This topic has 8 replies, 4 voices, and was last updated 12 years, 3 months ago by Widy75.
-
AuthorPosts
-
January 14, 2012 at 6:37 pm #538
I need to create a Memory Block and pass it a string as data, but it seems that loadFromHexString and append aren’t working.
January 14, 2012 at 8:24 pm #3785It 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]January 14, 2012 at 11:56 pm #3786better to use your code?
I am using this:
[code:1xii8agf]– Create MemoryBlock
data = MemoryBlock(0,true)[/code:1xii8agf]January 15, 2012 at 12:02 am #3787MemoryBlock 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.
January 15, 2012 at 12:54 am #3788is there a way to store such a memory block or hex string inside a panel
and recall them lateri 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 modulatorsalso 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 ” title=”Smile” />lg widy
January 15, 2012 at 1:06 am #3789You 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)January 15, 2012 at 8:52 am #3790hm ” 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 workingmy_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
January 15, 2012 at 3:02 pm #3791setPropertyString or setPropertyInt i wrote just an idea not actual code, sorry
January 15, 2012 at 8:40 pm #3792ah thx working .. nice ” title=”Smile” />
lg widy -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.