{
   "description" : "",
   "ancestor_list" : [],
   "name" : "A Convolution Reverb: Stereo with Reverse Option",
   "author" : "prko",
   "code" : "(\r\nfork{ \r\n\tvar path, inSrc, irL, irR, convTime, fftsize, bufsizeL, bufsizeR, irSpctrmL, irSpctrmR, convolver;\r\n\t\r\n\tpath= Platform.resourceDir; // path!\r\n\t\r\n\t\"preparing buffers.. \".post;\r\n\tinSrc= Buffer.readChannel(s, path+/+\"sounds/a11wlk01.wav\", channels:0); // your file! \r\n\t/*\r\n\tirL= Buffer.readChannel(s, path++\"\", channels:0); // IR left\r\n\tirR= Buffer.readChannel(s, path++\"\", channels:0); // IR right\r\n\t*/\r\n\t\r\n\t/* Test IRs */\r\n\t// test IRs begin. -->\r\n\t// synthesise the honourable 'Dan Stowell' impulse response */\r\n\t~ir= [1] ++ 0.dup(100) ++ (\r\n\t\t(1, 0.99998 .. 0)\r\n\t\t.collect {|f|\r\n\t\t\tf = f.squared.squared;\r\n\t\t\tf = if(f.coin) { 0 }{ f.squared };\r\n\t\t\tf = if(0.5.coin) { 0 - f } { f }\r\n\t\t} * 0.1\r\n\t);\r\n\t~irNorm = ~ir.normalizeSum;\r\n\tirR = Buffer.loadCollection(s, ~irNorm);\r\n\tirL = Buffer.loadCollection(s, ~irNorm);\r\n\t// <-- test IRs end.\r\n\t\r\n\t/* reverse IRs */\r\n\t\"finished.. \\nreverting IR buffers.. \".post;\r\n\t// irL.loadToFloatArray(action: { |array| irL.sendCollection(array.reverse) });\r\n\t\t\t// Only the right channel buffer is reversed for tests.\r\n\tirR.loadToFloatArray(action: { |array| irR.sendCollection(array.reverse) });\r\n\t\r\n\ts.sync;\r\n\t\r\n\t/* Increase the number 1 at the end of the following line if the sound is broken */\r\n\tconvTime= inSrc.duration+([irL.duration, irR.duration].sort[1]) + 1;\r\n\t\r\n\tfftsize= 2048;\r\n\tbufsizeL= PartConv.calcBufSize(fftsize, irL);\r\n\tirSpctrmL= Buffer.alloc(s, bufsizeL, 1);\r\n\tirSpctrmL.preparePartConv(irL, fftsize);\r\n\tbufsizeR= PartConv.calcBufSize(fftsize, irR);\r\n\tirSpctrmR= Buffer.alloc(s, bufsizeR, 1);\r\n\tirSpctrmR.preparePartConv(irR, fftsize);\r\n\t\r\n\ts.sync;\r\n\t\r\n\tirL.free; irR.free;\r\n\t\r\n\t\"finished..\\nconvolution is started.\".postln;\r\n\ts.record;\r\n\t\r\n\tconvolver= { \r\n\t\tvar in, conv, mix;\r\n\t\tin = PlayBuf.ar(1, inSrc.bufnum, BufRateScale.kr(inSrc.bufnum));\r\n\t\tconv = PartConv.ar (\r\n\t\t\tin,\r\n\t\t\tfftsize,\r\n\t\t\t[irSpctrmL.bufnum, irSpctrmR.bufnum],\r\n\t\t\t0.2 // Adjust the number to get a proper amplitude. \r\n\t\t);\r\n\t\tmix = (in * 0) + (conv * 1); // mix!\r\n\t\tOut.ar( 0, mix ) \r\n\t}.play;\r\n\t\r\n\tconvTime.wait;\r\n\t\r\n\tconvolver.free;\r\n\t\r\n\ts.stopRecording;\r\n\t\r\n\tinSrc.free; irSpctrmL.free; irSpctrmR.free;\r\n}\r\n)",
   "is_private" : null,
   "id" : "1-5am",
   "labels" : [
      "convolution",
      "reverse",
      "ir"
   ]
}
