[SC boffins reqd] Can SuperDirt be installed in the SC startup.scd process (to simplify amount of tidal install steps)?

During a bit of a brainstorming session on discord re the complexity of managing the Win installs, I had a thought that it might be possible to move the SuperDirt install step into the SuperCollider startup.scd file

The problem as I've learned during the building of the ansible tool, is that the quark install likes to fork it's process and carry on past that step regardless of the outcome - so it needs to be held up before continuing (a wait loop)

I've discovered a bit of documentation on the Condition object which looked helpful, and on using a Routine to check it's state/trigger it to re-check.

I have a bit of code that seems like it should be close to working, I was wondering if there were any other more knowledgable SuperCollider-ers in the area that could help get it over the line (or rule it out completely)?

I have an overly simplified startup.scd that just needs to confirm that the SuperDirt class is defined after the SuperDirt quark is installed - but the routine is not holding up the file execution (it's like it's being evaluted as a block rather than in serial):

(
s.reboot { // server options are only updated on reboot

	// boot the server and start SuperDirt
	s.waitForBoot {
		(
			c = Condition.new(Quarks.isInstalled("SuperDirt"));

			Routine {
				if (Quarks.isInstalled("SuperDirt"),
					{ "SuperDirt already installed".postln },
					{ Quarks.install("https://github.com/musikinformatik/SuperDirt.git")}
				);
				loop {
					if (c.test,
						{"SuperDirt Installed".postln; c.signal},
						{1.wait}
					);
					c.wait;
				};
			}.play;

			~dirt = SuperDirt(2, s);
		)
	};
	s.latency = 0.3; // increase this if you get "late" messages

};
)

I've got a response on the SuperCollider discord channel - it's possible to obfuscate the SuperDirt class by loading it in a separate file altogether, eg:

    if(Quarks.isInstalled("SuperDirt").not) {
        "installing Superdirt".postln;
        Quarks.install("SuperDirt");
        thisProcess.recompile;
    } {
        "SuperDirt is ready".postln;
        "/tmp/bla.scd".load;
    };

works, but raises the issue of file path conventions cross-platform.
If there's a concept of a running directory I can just drop a file in and provide no path prefix, that would be good.
Alternatively, SC does some file IO stuff, so it may be a matter of rewriting startup.scd after the initial installation?

It's getting real close - for some reason the Download is being pre-empted by the Quarks.install process, so I just need to work that out.

Then i just need to see if I can download and clobber the existing startup.scd with the superdirt startup.scd template...

var sd_startup = (thisProcess.platform.userConfigDir +/+ "superdirt_startup.scd");

if(Quarks.isInstalled("SuperDirt").not) {
    "...installing Superdirt".postln;
    Download.new("https://raw.githubusercontent.com/musikinformatik/SuperDirt/develop/superdirt_startup.scd", sd_startup,
        {\huzzah.postln;},
        {\error.postln;},
        {|rec, tot| [rec, tot].postln});
    Quarks.install("SuperDirt");
    //Get startup.scd reference
    thisProcess.recompile;
} {
    "...Starting SuperDirt".postln;
    sd_startup.load;
};

I got there - this downloads and installs the quark, downloads and installs the template superdirt startup.scd file, and does an in-place replacement of the startup.scd so it looks "normal" from that point on

I need to test on win here, and it would be great if someone with a mac could test on osx (@HighHarmonics ?)

Stick this in a blank startup.scd (you can open SC, file -> open startup file, copy and paste it in then restart sc)

var sd_startup = (thisProcess.platform.userConfigDir +/+ "sd_startup.scd");
var startup = (thisProcess.platform.userConfigDir +/+ "startup.scd");

if(Quarks.isInstalled("SuperDirt").not) {
	Quarks.install("SuperDirt");
	thisProcess.recompile;
} {
	Download.new("https://raw.githubusercontent.com/musikinformatik/SuperDirt/develop/superdirt_startup.scd", sd_startup,
		{
			File.delete(startup);
			File.copy(sd_startup, startup);
			File.delete(sd_startup);
			startup.load;
		},
		{\error.postln;},
		{|rec, tot| [rec, tot].postln});
};

Sure. I'll test this as soon as I can.

1 Like

Thanks! Confirmed working on Windows btw :slight_smile:

That's really awesome. It is a great step forward in order to simplify installation. Great work @cleary. It would be nice to document this even if it doesn't end up being the default method for install.

1 Like