Restore global cable's last data on DAW load
-
Another edge case, I'm manually implementing NAM and using a scriptPanel drop callback to pass the file to the node via a Global Cable. It works perfectly fine in a DAW, but if I save/load the project it doesn't restore the model path:
inline function sendNAMCableData() { local path = pnlAmpNAMLoader.get("text"); local file = FileSystem.fromAbsolutePath(path); local json = file.loadAsObject(); namCable.sendData(json); } inline function pnlAmpNAMLoaderDrop(f) { if(f.drop) { pnlAmpNAMLoader.set("text", f.fileName); sendNAMCableData(); pnlAmpNAMLoader.repaint(); } }
I've tried calling this
sendNAMCableData()
on init (at the end) like this:if (isDefined(Amp.namCable) && isDefined(Amp.pnlAmpNAMLoader)) Amp.sendNAMCableData();function onNoteOn() // nope
I can only assume the cable and/or the panel isn't defined yet, is there a way to force the cable to re-send the data on DAW reload, or just save the data inside the cable somehow?
-
@iamlamprey the global cables don't have a persistent data model so you need to implement this on your own - the simplest solution would be a hidden panel that stores a JSON that contains the global cable value (and is updated asynchronously when the cable changes).
-
@Christoph-Hart Lol was compiling exactly that as you posted, working now