Hi Rack Developers,
During my ongoing work on the OrangeLine DEJAVU module, I stumbled over the question which part of the module state should be held just as member variables of my module or better held in JSON storage to be restored after a patch (re)load or preset load.
The general question to be answered is whether it is expected that a module continues to work after exiting VCV Rack and reopening or saving and reloading the patch as if this never would have happened.
The consequences are quite important:
If answer to that question is NO, then continuing a performance after interrupting it, is not really possible. Wearing the hat of a perfectionist, I would like to have a patch being able to continue just from the point I closed VCV Rack after restarting it.
If the answer is YES, then any use of a member variable of a module might be a no go. If a variable would be necessary to carry information of any kind of state between one process() call to the next one, this state is lost after exiting and reloading, compromising the continuation of the patch. Otherwise, the member variable could just be a local variable of the the process() method.
Holding all state information in JSON storage will for some modules drastically increase the amount of data to save and restore when saving, and loading a patch. Especially the auto-save might impact the performance of Rack as a whole. Also to file size of patches and presets might be increased quite a lot.
As an example:
DEJAVU holds 16 x 2 + 4 + 1 = 37 pseudo random generator states. The pseudo random generators using a proven mathematical model developed by smarter guys than me but each one holds state information in an array of 624 unsigned longs. Storing this state information with JSON would just use up 8 x 624 Bytes which about 5K. 5K times 37 would give a file size of nearly 200K for storing one DEJAVU state. I can think about some workaround to reduce it but this would cost me quite a lot of work and maybe performance penalties.
I’m really interested how other developers out there are thinking about this topic in general.