Executing from commandline, execution order, headless autostart

hello there,

i’ve been building a supercollider script to run on a headless rpi as a standalone instrument, now my very basic code currently is setting up a bunch of busses, initializing fixed values, defining synthdefs, create groups, create synths in the groups and connect midi controls.

now when i run the code from the ide step-by-step it works like i intend it to, but when i try to run the whole file at once or just start sclang from the commandline it gets thrown off with the problem of “*** ERROR: SynthDef input not found”, despite the fact that all synthdefs are added before synths are created in the file.

is there some guide out there on how to properly structure autostart-projects or some way of controlling the order of the interpretation of the code?

should i put all synthdefs in a seperate file and load that before i load the “main program”? if necessary i can add code, but it’s still quite an unruly mess.

thanks for reading thus far,

Did you put your function calls in a Routine (maybe look at s.waitForBoot) and add an s.sync after loading the SynthDefs? The server is probably just taking a second to load the Defs and is trying to execute the rest of the code before they are loaded.


1 Like

Echoing @Sam_Pluta recommendation. I do this type of setup a lot, and have a basic template for my scripts that goes something like:

( /*boot and setup*/ );
s.waitForBoot {
    ( /*post-boot setup*/ );
    ( /* synthdefs etc*/ );
    ( /* routines, patterns, controls */ );

Thanks a lot to both of you! This is exactly what i was thinking must exist, but didn’t know what to search for!

I will test it tonight and edit the thread if it’s solved. now really looking forward to getting home

edit: yep, works perfectly! solved.

1 Like