{
   "author" : "Schemawound",
   "name" : "The Tunnel",
   "ancestor_list" : [],
   "description" : "This code contains three sections, the first defines the synthdef. \r\nThe second starts up the synth and the GUI for playing with the presets live.\r\nThe third is used to render out the completed album version of the song.\r\n\r\nThe song can be downloaded as part of the free compilation 'Far, Far Away', released by Waxen Wings. \r\nhttp://waxenwings.bandcamp.com/album/far-far-away\r\n\r\nI have written a blog post detailing the code and the revisions it went through\r\nhttp://schemawound.tumblr.com/post/21065032399/the-tunnel\r\n\r\nOr if you are lazy and just want to hear it\r\nhttp://soundcloud.com/schemawound/the-tunnel-1",
   "labels" : [
      "noise",
      "drone"
   ],
   "code" : "/*\r\nThis code contains three sections, the first defines the synthdef. \r\nThe second starts up the synth and the GUI for playing with the presets live.\r\nThe third is used to render out the completed album version of the song.\r\n\r\nThe song can be downloaded as part of the free compilation 'Far, Far Away', released by Waxen Wings. \r\nhttp://waxenwings.bandcamp.com/album/far-far-away\r\n\r\nI have written a blog post detailing the code and the revisions it went through\r\nhttp://schemawound.tumblr.com/post/21065032399/the-tunnel\r\n\r\nOr if you are lazy and just want to hear it\r\nhttp://soundcloud.com/schemawound/the-tunnel-1\r\n*/\r\n\r\n(//----------Tunnel SynthDef----------\r\n\tSynthDef(\\TheTunnel, {\r\n\t\t|\r\n\t\t\tout = 0,\t\t\t\t\tamp = 1,\t\t\t\t\tlfo1Speed = 0.1,\t\t\t\tlfo1Depth = 100,\t\t\tlfo2Speed = 0.25,\t\t\r\n\t\t\tlfo2Depth = 600,\t\t\tosc1Freq = 7,\t\t\t\tloSineFreq = 30,\t\t\t\tloSineAmp = 0.5,\t\t\tclip1Amp = 6,\t\t\r\n\t\t\tclipModFreq = 500,\t\tclip2Amp = 6,\t\t\t\tverbLfoSpeed = 0.014, \t\tverbLfoDepth = 1, \t\tverbRoom = 1, \r\n\t\t\tverbDamp = 0.5\r\n\t\t|\r\n\t\tvar loSine = SinOsc.ar(loSineFreq, 0, loSineAmp);\r\n\t\t//Osc1\r\n\t\tvar osc1 = SinOsc.ar(osc1Freq);\r\n\t\t//Osc2\r\n\t\tvar lfo1 = LFSaw.ar(lfo1Speed, 0, 0.5, 0.5); //Make positve only\r\n\t\tvar osc2 = SinOsc.ar(lfo1 * lfo1Depth);\r\n\t\t//Osc3\r\n\t\tvar lfo2 = LFSaw.ar(lfo2Speed, 0, 0.5, 0.5); //Make positve only\r\n\t\tvar osc3 = SinOsc.ar(lfo2 * lfo2Depth);\r\n\t\t//Sum and Clip\r\n\t\tvar clip1 = ((osc1 * osc2 * osc3) * clip1Amp).distort * SinOsc.ar(clipModFreq);\r\n\t\t//Output\r\n\t\tvar output = (clip1 * clip2Amp).distort * 0.5 + loSine;\r\n\t\tvar verbLfo = (SinOsc.ar(verbLfoSpeed) * 0.5 + 0.5) * verbLfoDepth;\r\n\t\tvar verb1 = FreeVerb.ar(output, verbLfo, verbRoom, verbDamp, amp);\r\n\t\tOut.ar(out, verb1!2 * 0.5);\r\n\t}, [0, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]).add; \r\n)\r\n\r\n(\r\n\t//----Start Synth----\r\n\t~tunnelSynth = Synth(\\TheTunnel);\r\n\t\r\n\t//----Preset----\r\n\t~tunnelPreset = ();\r\n\t~tunnelPreset.current = 0;\r\n\t~tunnelPreset.list = [\r\n\t\t//\t\t\tamp,\tlfo1Speed,\tlfo1Depth,\tlfo2Speed,\tlfo2Depth,\tosc1Freq,\tloSineFreq,\tloSineAmp,\tclip1Amp,\tclipModFreq,\tclip2Amp,\tverbLfoSpeed,\tverbLfoDepth,\tverbRoom,\tverbDamp\r\n\t\t/*00*/\t[\t1, \t\t0.1,\t\t100, \t\t0.25, \t\t600, \t\t7, \t\t\t30, \t\t\t0.5,\t\t6, \t\t\t500, \t\t\t6, \t\t\t0.014,\t\t\t1, \t\t\t\t1, \t\t\t0.5\t\t\t],\r\n\t\t/*01*/\t[\t1, \t\t30.756,\t628.79, \t0.25, \t\t600, \t\t35.412, \t11.8, \t\t\t0.5,\t\t6, \t\t\t500, \t\t\t6, \t\t\t0.151, \t\t0.204, \t\t1, \t\t\t1\t\t\t],\r\n\t\t/*02*/\t[\t1,\t\t48.345,\t446.41, \t45.021,\t694.56, \t14.97, \t42.53, \t\t0.14,\t\t1.833, \t168.49,\t\t1, \t\t\t0.014, \t\t0.314, \t\t1, \t\t\t0\t\t\t],\r\n\t\t/*03*/\t[\t1.163,\t0.507, \t1000, \t\t6.285, \t317.08, \t34.579, \t31.77, \t\t0.5, \t\t3.672, \t44.59, \t\t3.492, \t0.316, \t\t0.49, \t\t\t0.461, \t1\t\t\t],\r\n\t\t/*04*/\t[\t1.392,\t0.507, \t288.03,\t0.67, \t\t317.08, \t10.449, \t88.06, \t\t0.37, \t\t2.557, \t44.59, \t\t3.492, \t0.155, \t\t1, \t\t\t\t1, \t\t\t1\t\t\t],\r\n\t\t/*05*/\t[\t0.575,\t100, \t\t1000, \t\t96.903, \t1000, \t\t50, \t\t88.06, \t\t1.22, \t\t6, \t\t\t127.37, \t\t6, \t\t\t0.167, \t\t0.493, \t\t1, \t\t\t1\t\t\t],\r\n\t\t/*06*/\t[\t3.2, \t1, \t\t\t101.3, \t1.5, \t\t74.79, \t11.691, \t5.2, \t\t\t0, \t\t\t3.225, \t49.8, \t\t\t2.754, \t0.51, \t\t\t0.494, \t\t0.784, \t0.497\t\t],\r\n\t\t/*07*/\t[\t2.505,\t0.001, \t80.79, \t100, \t\t306.59, \t11.691, \t5.2, \t\t\t0, \t\t\t3.225, \t49.8, \t\t\t3.734, \t0.273, \t\t0.656, \t\t0.784, \t0.889\t\t],\r\n\t\t/*08*/\t[\t0.9,\t71.939, \t631.92, \t72.476,\t427.99, \t17.475, \t96.68, \t\t0.56, \t\t4.298, \t496.15, \t\t5.649, \t0.804, \t\t0.694, \t\t0.303, \t0.461\t\t],\r\n\t\t/*09*/\t[\t0.6,\t34.043, \t650.05, \t29.176,\t480.98, \t30.836, \t66.66, \t\t1.13, \t\t2.401, \t205.91, \t\t2.664, \t0.173, \t\t0.778, \t\t0.517, \t0.88\t\t],\r\n\t\t/*10*/\t[\t0.54,\t22.558, \t217.5,\t\t91.033,\t520.13,\t3.484,\t\t84.09,\t\t\t1.59, \t\t2.731,\t\t259.07, \t\t5.919,\t\t0.571, \t\t0.988, \t\t0.133, \t0.0\t\t\t]\r\n\t];\r\n\t~tunnelPreset.load = { |ev| \r\n\t\tvar current = ev.current;\r\n\t\t~tunnelSynth.set(\\amp, ev.list[current][0]);\r\n\t\t~tunnelSynth.set(\\lfo1Speed, ev.list[current][1]);\r\n\t\t~tunnelSynth.set(\\lfo1Depth, ev.list[current][2]);\r\n\t\t~tunnelSynth.set(\\lfo2Speed, ev.list[current][3]);\r\n\t\t~tunnelSynth.set(\\lfo2Depth, ev.list[current][4]);\r\n\t\t~tunnelSynth.set(\\osc1Freq, ev.list[current][5]);\r\n\t\t~tunnelSynth.set(\\loSineFreq, ev.list[current][6]);\r\n\t\t~tunnelSynth.set(\\loSineAmp, ev.list[current][7]);\r\n\t\t~tunnelSynth.set(\\clip1Amp, ev.list[current][8]);\r\n\t\t~tunnelSynth.set(\\clipModFreq, ev.list[current][9]);\r\n\t\t~tunnelSynth.set(\\clip2Amp, ev.list[current][10]);\r\n\t\t~tunnelSynth.set(\\verbLfoSpeed, ev.list[current][11]);\r\n\t\t~tunnelSynth.set(\\verbLfoDepth, ev.list[current][12]);\r\n\t\t~tunnelSynth.set(\\verbRoom, ev.list[current][13]);\r\n\t\t~tunnelSynth.set(\\verbDamp, ev.list[current][14]);\r\n\t};\r\n\r\n\t//----------Tunnel GUI----------\r\n\t~tunnelWindow = Window( \"The Tunnel\", Rect( 128, 230, 110, 140)); \r\n\t~tunnelWindow.view.decorator = FlowLayout( ~tunnelWindow.view.bounds );\r\n\t~tunnelPreset.list.do({|each, count| (Button(~tunnelWindow, 30@30).states = [[count]]).action = {(~tunnelPreset.current = count).load;};});\r\n\t~tunnelWindow.front;\r\n\t~tunnelWindow.onClose = {~tunnelSynth.free;};\r\n\r\n\t//Kill the gui if the user kills the sound\r\n\tCmdPeriod.doOnce({\r\n\t\t~tunnelWindow.close;\r\n\t});\r\n)\r\n\r\n(//---------Perform Song----------\r\n\t~tunnelTask = Task({\r\n\t\t~tunnelSynth.free;\r\n\t\ts.recChannels = 2;\r\n\t\ts.recHeaderFormat = \"AIFF\";\r\n\t\ts.recSampleFormat = \"int24\";\r\n\t\ts.prepareForRecord(\"C:\\\\Users\\\\Jennifer\\\\Jon\\\\Code\\\\thetunnel.aiff\");\r\n\t\ts.record;\r\n\t\t~tunnelSynth = Synth(\\TheTunnel, [\\amp, 0]); \t1.wait;\r\n\t\t~tunnelSynth.set(\\amp, 1);\t\t\t\t\t\t128.wait;\r\n\t\t~tunnelSynth.set(\\amp, 0.7);\r\n\t\t~tunnelSynth.set(\\clip1Amp, 100); \r\n\t\t~tunnelSynth.set(\\clip2Amp, 100);\t\t\t\t30.wait;\r\n\t\t(~tunnelPreset.current = 2).load;\t\t\t\t15.wait;\r\n\t\t(~tunnelPreset.current = 6).load;\t\t\t\t30.wait;\r\n\t\t~tunnelSynth.set(\\amp, 0);\t\t\t\t\t\t35.wait;\r\n\t\t~tunnelSynth.free;\r\n\t\ts.stopRecording;\r\n\t});\r\n\t~tunnelTask.play;\r\n)",
   "id" : "1-3wM",
   "is_private" : null
}
