Quantcast

Problems running SuperCollider from the command line, OSX.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Problems running SuperCollider from the command line, OSX.

RobotFun
Hi All,

I'm not an expert with SuperCollider and am struggling to run some SuperCollider Code from the command  line (I want to do this as this is part of an integrated system for a robot. Short answer, running SC and my code needs to be automated).

So, here is my command line command (tried with.sc, .scd, and .txt file extension):
$ exec ./sclang test.txt

This is the contents of test.txt:

(
s = Server.local.boot;

Task({
//Wait for Server to boot
6.wait;

//This does give me a tone, good.
{SinOsc.ar()}.play;

var greeting; //This does not work, I get a parse error!?
}).play;
)


Now, here I am stumped. Why am I unable to declare a variable?! The above is only a test. My end goal is to load two files that I know work (as they work if I use the GUI) using this method which I have also tested via the GUI:

(
var inputFile;

"Loading NaoSqueak Synth Defs...".postln;
inputFile = File("/Users/rread/Dropbox/PhD/Code/SuperCollider Tests/naoSqueakSynthDef.txt","r");
inputFile.readAllString.interpret;
inputFile.close;
"NaoSqueak Synth Defs Loaded!".postln;

"Loading NaoSqueak Listener Application...".postln;
inputFile = File("/Users/rread/Dropbox/PhD/Code/SuperCollider Tests/naoSqueakListenerApp.txt","r");
inputFile.readAllString.interpret;
inputFile.close;
"NaoSqueak Listener Application Loaded!".postln;
"".postln;
)


Clearly I'm missing something rather fundamental and vital. Can anyone help?

Thanks,

R.

P.S. Here are the files that I want to run (attached)!

naoSqueakSynthDef.txt
naoSqueakListenerApp.txt
loadNaoSqueak.txt
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Problems running SuperCollider from the command line, OSX.

RobotFun
This is now solved...

(
var loadFilesFunc = {
        var inputFile;

        "Loading NaoSqueak Synth Defs...".postln;
        inputFile = File("/Users/rread/Dropbox/PhD/Code/SuperCollider Tests/naoSqueakSynthDef.txt","r");
        inputFile.readAllString.interpret;
        inputFile.close;
        "NaoSqueak Synth Defs Loaded!".postln;

        "Loading NaoSqueak Listener Application...".postln;
        inputFile = File("/Users/rread/Dropbox/PhD/Code/SuperCollider Tests/naoSqueakListenerApp.txt","r");
        inputFile.readAllString.interpret;
        inputFile.close;
        "NaoSqueak Listener Application Loaded!".postln;
        "".postln;
};

//Load the Server and when booted, run the command above.
s = Server.local;
s.doWhenBooted({loadFilesFunc.value;},100,{false});
s.boot;
)
Loading...