{
   "name" : "Part-Aleatoric Sample Machine",
   "author" : "nathan",
   "ancestor_list" : [],
   "description" : "This piece is a demonstration of the Part-Aleatoric Sample Machine, a project I am working on to explore possible interfaces between human and non-human listening. In the PASM, a computer uses chance principles to select samples for playback and apply effects; a human performer decides how long each sample is played for, and also operates a simple sine wave oscillator.\r\n\r\nThe samples used in the piece were recorded at Linton Falls, North Yorkshire, and can be downloaded from http://afternoondust.co.uk/blog/140201_1630-water-piece.",
   "labels" : [
      "sampler",
      "aleatoric"
   ],
   "id" : "1-4VF",
   "is_private" : null,
   "code" : "/* 140201_1630 (water piece)\r\n\r\nby Nathan Thomas\r\nnathan@afternoondust.co.uk\r\nhttp://www.afternoondust.co.uk\r\n\r\nThis piece is a demonstration of the Partly-Aleatoric Sample Machine v1.\r\n\r\nDon't forget to update the paths to the audio samples on lines 23-26.\r\n\r\nCreative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License:\r\nhttp://creativecommons.org/licenses/by-nc-sa/3.0/\r\n\r\n*/\r\n\r\n\r\n(\r\nServer.default = s = Server.internal;\r\ns.boot;\r\n)\r\n\r\n// Load samples\r\na = Buffer.read(s, \"path/to/audio/samples/linton_falls_02.wav\");\r\nb = Buffer.read(s, \"path/to/audio/samples/linton_falls_gutter_01.wav\");\r\nc = Buffer.read(s, \"path/to/audio/samples/linton_falls_gutter_02.wav\");\r\nd = Buffer.read(s, \"path/to/audio/samples/linton_falls_tap_01.wav\");\r\n\r\n// Create SynthDefs\r\n(\r\n\t// Sample playback SynthDef\r\n\tSynthDef(\"playbuf\", { arg bufnum, outBus=0, gate=1;\r\n\t\tvar sig, env;\r\n\t\tenv = EnvGen.kr(Env.asr(0,1,0),gate, doneAction:2);\r\n\t\tsig = PlayBuf.ar(2,bufnum,BufRateScale.kr(bufnum)) * env;\r\n\t\tOut.ar(outBus, sig)\r\n\t}).add;\r\n\r\n\t// Effect SynthDefs\r\n\r\n\tSynthDef(\"hipass\", { arg inBus, freq = 3200;\r\n\t\tvar sig, filter;\r\n\t\tsig = In.ar(inBus,2);\r\n\t\tfilter = BHiPass.ar(sig, freq, 1,1);\r\n\t\tOut.ar(0,filter)\r\n\t}).add;\r\n\r\n\tSynthDef(\"lopass\", { arg inBus, freq = 200;\r\n\t\tvar sig, filter, norm;\r\n\t\tsig = In.ar(inBus,2);\r\n\t\tfilter = BLowPass.ar(sig, freq, 1,1);\r\n\t\tnorm = Normalizer.ar(filter,0.4);\r\n\t\tOut.ar(0,norm)\r\n\t}).add;\r\n\r\n\tSynthDef(\"reverb\", { arg inBus, roomSize=0.6, damp=0.4;\r\n\t\tvar sig, reverb;\r\n\t\tsig = In.ar(inBus,2);\r\n\t\treverb = FreeVerb2.ar(sig[0],sig[1], mix:0.5, room:roomSize,damp:damp, mul:1);\r\n\t\tOut.ar(0,reverb)\r\n\t}).add;\r\n\r\n\t// Synth line SynthDef\r\n\tSynthDef(\"synth\", { arg outBus=0, gate=1, freq=770;\r\n\t\tvar synth, env;\r\n\t\tenv = EnvGen.kr(Env.adsr(10,6,1,6),gate,doneAction:2);\r\n\t\tsynth = SinOsc.ar([freq,1700],Rand(0,0.3),0.1) * env;\r\n\t\tOut.ar(outBus,synth!2)\r\n\t}).add;\r\n\r\n\t// Create effect busses\r\n\tk = Bus.audio(s,2);\r\n\tl = Bus.audio(s,2);\r\n\tm = Bus.audio(s,2);\r\n\r\n)\r\n\r\n// Begin sample playback\r\n(\r\n\tz = Synth(\\hipass,[\\inBus,m]);\r\n\tu = Synth.before(z, \\lopass,[\\inBus,l]);\r\n\tt = Synth.before(u, \\reverb,[\\inBus,k]);\r\n\tx = Synth.before(t, \\playbuf, [\\bufnum, [a,b,c,d].choose, \\outBus, [0,k,l,m].choose]);\r\n)\r\n\r\n// Change samples (freeing synths and creating new ones prevents noise when switching sample buffers)\r\n(\r\n\tx.set(\\gate,0); z.free; u.free; t.free;\r\n    z = Synth(\\hipass,[\\inBus,m]);\r\n\tu = Synth.before(z, \\lopass,[\\inBus,l]);\r\n\tt = Synth.before(u, \\reverb,[\\inBus,k]);\r\n\ty = Synth.before(t, \\playbuf, [\\bufnum, [a,b,c,d].choose, \\outBus, [0,k,l,m].choose]);\r\n)\r\n\r\n// Change samples 2\r\n(\r\n\ty.set(\\gate,0); z.free; u.free; t.free;\r\n\tz = Synth(\\hipass,[\\inBus,m]);\r\n\tu = Synth.before(z, \\lopass,[\\inBus,l]);\r\n\tt = Synth.before(u, \\reverb,[\\inBus,k]);\r\n\tx = Synth.before(t, \\playbuf, [\\bufnum, [a,b,c,d].choose, \\outBus, [0,k,l,m].choose]);\r\n)\r\n\r\n// Synth part with optional effect routing\r\nw = Synth(\"synth\",[\\freq, [770,900,1400].choose]);\r\nw.set(\\gate,0);\r\nw.set(\\outBus,l);\r\nw.set(\\outBus,k);\r\nw.set(\\outBus,m);\r\n\r\n// Free sample playback and effect synths\r\nx.free; z.free; u.free; t.free;\r\n// Free effect busses\r\nm.free; l.free; k.free;\r\n\r\n\r\ncurrentEnvironment.clear;"
}
