Saving a Preset Sequence of SynthDefs

It’s a hard problem in general. Probably the most ready made thing that exists for this is in general is the TreeSnapshot class in Scott’s NodeSnapshot quark. See related discussions here e.g. how to use it. I haven’t looked to see if if has a permanent store function (it’s a large class). It has a storeOn method but I don’t know if it deserializes well.

It’s not clear to me what your problem with Ndefs was, but for those there’s NdefPreset in the JITLibExtensions quark that’s perhaps useful. It already has a storeToDisk option (inherited from ProxyPreset), but it won’t save entire sets of Ndefs, from what I see. It’s still your responsibility to iterate over the Ndefs of interest, in the order of dependencies, especially when restoring them.

By the way, the Archive class is generally useful for saving stuff and having it
restored on sclang startup, but it’s just persistent dictionary basically, it won’t
do any other magic.

The example you have posted has a problem that it won’t work properly if the order of clicking is different than the obvious one because you’re not enforcing any Synth execution order, so the filters can actually execute ahead of the audio, depending on the order of clicking. See \addToHead etc in Synth or Ndef sources slots how to fix that.

Merely collecting the state of the buttons in a list however is a simple matter:

~vals = [a, b, c].collect(_.value)

To restore them with those values, triggering their action too, assuming the buttons are instantiated

~buts = [a, b, c];
~buts.do { |but, i| but.valueAction_(~vals[i]) }

But generally you don’t want the state of the gui to be the place where that kind of info is stored, especially other things like synth parameters. Read about model-view-controller.