Saving "Presets"?

Hi, I’m trying to write something that creates an array of data from a multislider (for example) then writes it as a “preset” in a separate file, perhaps a CSV with one line per “preset”.

Is there an idiomatic SuperCollider way to do this? I don’t want to reinvent the wheel or stumble into an antipattern. Hints as to useful classes, libraries or quarks would be appreciated. Thanks!

Hi! I assume you have the values stored in a collection somewhere? I’m not sure if anyone has anything better, but I use the_collection.cs to get a compile string for the collection, then I write that to a file. To load, I load from that file’s string a la "/my/cool/file".load() which will give me that collection again, and then I reapply the slider values.

1 Like

If you don’t care too much about it being human readable, just use writeArchive and readArchive:

a = Array.fill(400, {rrand(0,2200)});

a.writeArchive("/Users/spluta1/Documents/SC/test");

b = Object.readArchive("/Users/spluta1/Documents/SC/test");

b.postln;

Sam

6 Likes

That’s actually more readable than I expected, thanks!

Hi, if you are looking for something that can make:

  1. a gui for you based on the arguments of your Ndef
  2. store every values of your sliders
  3. morph between presets

I suggest you to look at the:

https://pustota.basislager.org/_/sc-help/Help/Classes/NdefPreset.html

2 Likes

Excellent - this sounds like precisely what I need, and I don’t have to reinvent the wheel. Thank you so much!

I would have never thought to look at something called JITLibExtensions, expecting it to save control values. There’s a bit of a discoverability problem with Quarks. When I browse Quarks in the IDE there’s no info on what they do, sometimes not even if you click through to visit the repository.

I’m a learner like you, and I compleatly agree, it would be nice to find a way to highlight what is already available.
I discover the Ndefpreset thing, just because a friend of mine told me…
It’s a pity! It would be nice, now that everyone has moved here and the mailing-list has been “archived”, to make a thread dedicated to the content and functionality of the various Quarks.

Just a suggestion :slight_smile:

1 Like

VarGui from miSCellaneous_lib quark has save and load functionality, see Ex. 6 of the helpfile “VarGui shortcut builds”. For a quick intro to VarGui see “Tour 1” of “Introduction to miSCellaneous”.

1 Like

I’d like to see a meta-search-engine that indexes the builtin help files, the Quarks by keyword, sccode.org, and probably some other stuff I can’t think of at the moment. Oh yes, this forum! :mag:

See, this turned out to be an embarrassment of riches, all hidden behind obscure Quark names like miSCellaneous_lib and JITLibExtensions. Thank you, this one looks especially well suited to my needs.