// title: ScoreClock, Patterns, RT/NRT and server-side resources // author: jamshark70 // description: // A quick demo of one way to allocate server-side resources (SynthDefs, Buffers) that works in RT/NRT with minimal modification. // // You'll need Jonatan Liljedahl's ScoreClock quark: // // // // Mac OSX / Linux // // Quarks.install("ScoreClock"); // // // // Windows, see http://swiki.hfbk-hamburg.de/MusicTechnology/883 // code: ( p = Pbind( \instrument, \bufGrainPan, \bufnum, b, \time, Pwhite(0.1, 0.3, inf), \start, Pwhite(0.0, b.duration - Pkey(\time), inf) * b.sampleRate, \pan, Pwhite(-1.0, 1.0, inf), \delta, Pkey(\time) * Pexprand(0.8, 1.25, inf) ); q = Pseq([ (play: { // initialization event SynthDef(\bufGrainPan, { |start, time, bufnum, pan, rate = 1, amp = 1, attack = 0.001, decay = 0.02, outbus| var sig; sig = PlayBuf.ar(1, bufnum, rate * BufRateScale.kr(bufnum), 1, start, 0) * EnvGen.kr(Env.linen(attack, time, decay), doneAction:2); Out.ar(outbus, Pan2.ar(sig, pan, amp)); }).add; // NOTE: Mac OSX/Windows users need to change this for the actual location b = Buffer.read(s, Platform.systemAppSupportDir +/+ "sounds/a11wlk01.wav"); s.sync }, delta: 0), p ]); f = { // cleanup func b.debug("freeing").free }; ) s.reboot; // RT ( r = q.play; c = SimpleController(r).put(\stopped, { c.remove; f.value }); ) r.stop; // should free the buffer // NRT ( ScoreClock.beginScore; Pfindur(10, q).play(ScoreClock); // cleanup not needed since NRT server dies anyway ScoreClock.makeScore.recordNRT(PathName.tmp +/+ "osc.osc", thisProcess.platform.recordingsDir +/+ "test2.aiff", options: ServerOptions.new.numOutputBusChannels_(2), duration: 10, action: { "done".postln }); )