/* Allpass filters and PlayBuf */ ( ~allpass = CtkSynthDef(\allpass, {arg dur, buffer, playbuffer, amp, delaytime, gain; var env, sig, tap, feedin; env = EnvGen.kr( Env([0, amp, amp, 0], [0.05, dur - 0.1, 0.05]), doneAction: 2); feedin = LocalIn.ar(1); sig = PlayBuf.ar(1, playbuffer); RecordBuf.ar(sig + (feedin * gain), buffer); tap = Tap.ar(buffer, 1, delaytime - ControlRate.ir.reciprocal); LocalOut.ar(tap); Out.ar(0, [((sig * (gain.neg)) + tap) * env, sig]); }) ) /* Here is a similar example, using AllpassC */ // AllpassC takes a decaytime (where the above example used a gain coefficient. // To convert between a decaytime to -60dB and a gain value, you can use the following formula: // // decayTime60 = (-60.dbamp.log2 * delaytime) / gain.log2) // // or: // // (0.001.log2 * 0.001) / 0.995.log2; // => 0.024011768338953 ( ~allpass2 = CtkSynthDef(\allpass2, {arg dur, playbuffer, amp, delaytime, decaytime; var env, sig, delay; env = EnvGen.kr( Env([0, amp, amp, 0], [0.05, dur - 0.1, 0.05]), doneAction: 2); sig = PlayBuf.ar(1, playbuffer); delay = AllpassC.ar(sig, delaytime, delaytime, decaytime); Out.ar(0, [ (delay * env) + sig, sig]); }) ) // create new CtkScore ~score = CtkScore.new; // create buffers and add them to the score ~buf_1 = CtkBuffer(size: 32768).addTo(~score); ~buf_2 = CtkBuffer.playbuf("~/Snd/ferry.aiff".standardizePath).addTo(~score); // add notes to the score ~allpass.new(0.0, 10).dur_(10).buffer_(~buf_1).playbuffer_(~buf_2).amp_(0.5).delaytime_(0.001).gain_(0.5).addTo(~score); ~allpass2.new(11.0, 10).dur_(10).playbuffer_(~buf_2).amp_(0.5).delaytime_(0.001).decaytime_(1.54011768338953).addTo(~score); // we need to set the control period to 1 for this example o = ServerOptions.new.numOutputBusChannels_(1).blockSize_(1); // write sound file out ~score.write("~/Desktop/allpass.aiff".standardizePath, options: o); Player.new("~/Desktop/allpass.aiff".standardizePath).gui;