{
   "description" : "an installation-setup",
   "ancestor_list" : [],
   "author" : "nufets",
   "name" : "The City Breathing",
   "code" : "// An installation piece\r\n// (c) Stefan Nussbaumer 2011 - licensed under Creative Commons: https://creativecommons.org/licenses/by-sa/3.0/\r\n// sampled sound (street-noise) gets ganulated and played back spread over an arbitrary number of speakers\r\n// the audience interacts with the installation via a microphone\r\n// you will need to install the following quarks in order to run the piece:\r\n// CVCenter: Quarks.install(\"CVCenter\")\r\n// wslib: Quarks.install(\"wslib\")\r\n// audio-files can be downloaded here (as soon as they get approved...):\r\n// http://www.freesound.org/people/nufets/sounds/150201/\r\n// http://www.freesound.org/people/nufets/sounds/150200/\r\n// http://www.freesound.org/people/nufets/sounds/150199/\r\n\r\n(\r\ns.waitForBoot {\r\n\tc = Condition.new;\r\n\tt = TempoClock().permanent_(true);\r\n\tCVCenter.use(\\tempo, #[0.5, 5, \\exp], 1.0, tab: \\traffic); \r\n\tb = Buffer.readDir(\"/Volumes/satellite/Music/road_to_nowhere/rtn_samples_mono/\", server: s, notify: true);\r\n\r\n\t(\r\n\tSynthDef(\\grainer, { |bufnum, out=0, ratio=1, start, end, atk, sus, rel, level=1, curve=(-4), gate=1, pos=0, width=1, orientation=0.5|\r\n\t\tvar in, env, times, outs;\r\n\t\tenv = Env.linen(atk, sus, rel, level, curve);\r\n\t\tin = BufRd.ar(1, bufnum, Phasor.ar(\r\n\t\t\t0, BufRateScale.kr(bufnum) * ratio, start, end\r\n\t\t));\r\n\t\tOut.ar(out, PanAz.ar(4, in, pos, width: width, orientation: orientation) * EnvGen.ar(env, gate, doneAction: 2));\r\n\t}).add\r\n\t);\r\n\t\r\n\t(\r\n\tSynthDef(\\audience, { |in=0, amp=1.0, atk=0.01, rel=0.01, median=4, ampThresh=0.01, clarity=1, lagAmp=1, lagPitch=1, lagHasPitch=1|\r\n\t\tvar sig, ampltd, pitch, hasPitch;\r\n\t\tsig = SoundIn.ar(in, amp);\r\n\t\tampltd = AmplitudeMod.kr(sig, atk, rel);\r\n\t\t#pitch, hasPitch = Pitch.kr(sig, 20, median: median, ampThreshold: ampThresh, clar: clarity);\r\n\t\tSendReply.kr(Impulse.kr(10), 'audience-noise', [ampltd, pitch, hasPitch].lag([lagAmp, lagPitch, lagHasPitch]));\r\n\t}).add\r\n\t);\r\n\t\r\n\ts.sync;\r\n\t\r\n\t~audience = Synth(\\audience, [\\in, 0]);\r\n\t\r\n\tCVCenter.use(\\audAmp, #[0.1, 1.5].asSpec, 0.0, \\audience);\r\n\tCVCenter.use(\\audPitch, #[20, 5000, \\exp].asSpec, 20.0, \\audience);\r\n\tCVCenter.use(\\audClar, #[0.0, 2.0].asSpec, 0.0, \\audience);\r\n\t\r\n \t~resp.remove;\r\n\t~resp = OSCresponderNode(nil, 'audience-noise', { |t, r, msg| \r\n\t\t[CVCenter.at(\\audAmp), CVCenter.at(\\audPitch), CVCenter.at(\\audClar)].do({ |cv, i|\r\n\t\t\tcv.value_(msg[i+3])\r\n\t\t});\r\n\t\t~response = msg[3..];\r\n\t}).add;\r\n\t\r\n\t~rt = {\r\n\t\tloop {\r\n\t\t\tt.tempo_(CVCenter.at(\\tempo).value * CVCenter.at(\\audAmp).value * 10);\r\n\t\t\t0.1.wait;\r\n\t\t}\r\n\t}.fork(AppClock);\r\n\t\r\n\tt.tempo.postln\r\n\r\n\t(\r\n\t~increase = CVCenter.use(\\increase, #[0.1, 10.0], 1.0, \\traffic);\r\n\t~decrease = CVCenter.use(\\decrease, #[0.1, 10.0], 1.0, \\traffic);\r\n\r\n\tPdef(\\grain,\r\n\t\tPbind(\r\n\t\t\t\\instrument, \\grainer,\r\n\t\t\t\\bufnum, Pfunc({ ~buf = b.choose; ~buf.bufnum }),\r\n\t\t\t\\ratio, (Pxrand(ScaleInfo.scales.choose, inf) * CVCenter.use(\\detune, #[1, 0.1].asSpec, 0, \\traffic) * CVCenter.at(\\audPitch)/500).trace(prefix: 'pitch :'),\r\n\t\t\t\\start, Pfunc({ rand(~buf.numFrames) }),\r\n\t\t\t\\end, Pfunc({ rand(~buf.numFrames) }),\r\n\t\t\t\\dur, Pn(\r\n\t\t\t\tPseg(\r\n\t\t\t\t\tPwrand([\r\n\t\t\t\t\t\t0.1, 0.2, \r\n\t\t\t\t\t\tPseq((1/7)!7, 1), \r\n\t\t\t\t\t\tPseq((1/3)!3, 1), \r\n\t\t\t\t\t\t0.5, \r\n\t\t\t\t\t\tPxrand([0.7, 0.3], 1)\r\n\t\t\t\t\t], [1, 10, 5, 8, 3].normalizeSum, inf), \r\n\t\t\t\t\tPseq([~increase, ~decrease], inf), \r\n\t\t\t\t\trepeats: 1\r\n\t\t\t\t) * CVCenter.at(\\audAmp).reciprocal,\r\n\t\t\t\tinf\r\n\t\t\t)/*.trace(prefix: 'dur: ')*/,\r\n\t\t\t\\atk, 0.001.rrand(Pkey(\\dur)/4),\r\n\t\t\t\\sus, 0.001.rrand(Pkey(\\dur)/4),\r\n\t\t\t\\rel, Pkey(\\dur)-Pkey(\\atk)-Pkey(\\sus),\r\n\t\t\t\\level, CVCenter.use(\\sampAmp, \\amp.asSpec, tab: \\traffic),\r\n\t\t\t\\curve, Pwhite(-4.0, 4.0),\r\n\t\t\t\\pos, CVCenter.use(\\pos, \\pan.asSpec, tab: \\traffic)+CVCenter.at(\\audPitch),\r\n\t\t\t\\width, Pn(CVCenter.use(\\width, #[0.06, 0.2223].asSpec, tab: \\traffic) * (CVCenter.at(\\audAmp) + 0.5 * 30), inf)/*.trace(prefix: 'width: ')*/,\r\n\t\t\t\\orientation, CVCenter.use(\\ori, #[0, 1].asSpec, tab: \\traffic)+CVCenter.at(\\audClar)/*.trace(prefix: 'ori: ')*///,\r\n\t\t)\r\n\t)\r\n\t);\r\n\tPdef(\\grain).play(t);\r\n\t\r\n\t(\r\n\tPdef(\\audience, \r\n\t\tPbind(\r\n\t\t\t\\instrument, ~audience,\r\n\t\t\t\\type, \\set,\r\n\t\t\t\\args, #[lagAmp, lagPitch, lagHasPitch],\r\n\t\t\t\\dur, Pwhite(0.01, 1.0),\r\n\t\t\t#[lagAmp, lagPitch, lagHasPitch], Ptuple([CVCenter.at(\\audAmp) * 7, CVCenter.at(\\audPitch) / 200, CVCenter.at(\\audClar) * 7], inf).collect({ |all| all.scramble }).trace(prefix: 'ptuple: ')\r\n\t\t)\r\n\t)\r\n\t);\r\n\tPdef(\\audience).play(t);\r\n}\r\n)",
   "is_private" : null,
   "id" : "1-2Z2",
   "labels" : [
      "noise",
      "city",
      "street",
      "interactive"
   ]
}
