Skip to content

Instantly share code, notes, and snippets.

@moxuse
Created October 22, 2011 14:24
Show Gist options
  • Save moxuse/1306057 to your computer and use it in GitHub Desktop.
Save moxuse/1306057 to your computer and use it in GitHub Desktop.
Non realtime SCSynth Render Server Client
"SC_SYNTHDEF_PATH".setenv("PATH FOR synthDefFiles");
(
o = OSCReceiver("/assign", nil);
OSCReceiverFunction("/assign", "gf", {|msg|
var graphFnc,time,second,scoreFile,pathToSoundDir,isFile,skip;
skip = false;
pathToSoundDir = "PATH FOR soundFiles dir";
time = Date.getDate.format("%Y%m%d%H%M%S");
second = Date.getDate.format("%M%S")++(10.rand).asString;
w = "{Out.ar(0," + msg +")}";
try{
graphFnc = w.compile.value;
d = SynthDef(name:time,ugenGraphFunc:graphFnc).writeDefFile("PATH FOR synthDefFiles dir");
}{|error| [\catch, error].postln;
w.postln;
skip = true;
};
if(skip!=true,{
scoreFile = "PATH FOR commandOscFiles dir" ++ time ++".osc";
f = File( scoreFile ,"w");
c = [ 0.2, [\s_new, time, second.asInteger, 0, 0]].asRawOSC;
f.write(c.size); // each bundle is preceeded by a 32 bit size.
f.write(c); // write the bundle data.
c = [ 10.0, [\n_free, second.asInteger]].asRawOSC;
f.write(c.size);
f.write(c);
c = [ 10.2, [0]].asRawOSC;
f.write(c.size);
f.write(c);
f.close;
try{
("./scsynth -N "++ scoreFile ++ " _ " ++ pathToSoundDir ++ time ++ ".aiff 44100 AIFF int16 -o 2").unixCmd;
}{|error| [\catch2, error].postln;
};
isFile = File.exists("PATH FOR soundFiles dir"++ time++".aiff");
isFile.postln;
});
});
o.start;
)
o.stop;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment