The Recording Synth

The recorder, which is writing audio into the previously allocated 20 buffers, is a simple SynthDef (http://supercollider.sourceforge.net/docs/ServerArchitecture/SynthDef.html), that gets instantiated for each comment to read. In order not to consume to much cpu resp. not to pile up Synths it is written in a way that automatically frees the Synth as soon there is no input-sound for more than 2 secs.

(
SynthDef(\sampleIn,{ arg out=0,bufnum=0;
    var in;
    in = AudioIn.ar(3);
    // DetectSilence.ar(in, 0, 1, 2); // automatically free the synth if there's no audio for more than 2 seconds - not necesary any more as the snth gets freed from within the calling script
    RecordBuf.ar(in, bufnum);
}).load(s);
)

Once above code has been executed, the SynthDef will be compiled in a file (a .scsyndef by default in the directory synthdefs in the build directory of SC. As long as you keep your .scsyndefs in that directory you may instantiate them from within any SC-code, given your Server (local, internal or some other on the network) is running.
Unless otherwise stated, the content of this page is licensed under GNU Free Documentation License.